From 87e8059c0e28410bd89c733e10d9028df3e9cd59 Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Sun, 19 Sep 2021 14:50:57 +0530 Subject: [PATCH] Fixed #519 As admin UI doesn't list the user or teams list (#522) --- .../src/components/dropdown/DropDownList.tsx | 14 +-- .../components/my-data-details/ManageTab.tsx | 97 ++++++++++++++----- 2 files changed, 81 insertions(+), 30 deletions(-) diff --git a/catalog-rest-service/src/main/resources/ui/src/components/dropdown/DropDownList.tsx b/catalog-rest-service/src/main/resources/ui/src/components/dropdown/DropDownList.tsx index 624e6bb6304..271c3bf0857 100644 --- a/catalog-rest-service/src/main/resources/ui/src/components/dropdown/DropDownList.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/components/dropdown/DropDownList.tsx @@ -96,7 +96,7 @@ const DropDownList: FunctionComponent = ({ {showSearchBar && (
{ @@ -114,11 +114,13 @@ const DropDownList: FunctionComponent = ({ {listGroups.map((grp, index) => { return (
- -
- {grp}{' '} -
-
+ {getSearchedListByGroup(grp).length > 0 && ( + +
+ {grp}{' '} +
+
+ )} {getSearchedListByGroup(grp).map( (item: DropDownListItem, index: number) => getDropDownElement(item, index) diff --git a/catalog-rest-service/src/main/resources/ui/src/components/my-data-details/ManageTab.tsx b/catalog-rest-service/src/main/resources/ui/src/components/my-data-details/ManageTab.tsx index 56f3e9213c2..091b9eec7be 100644 --- a/catalog-rest-service/src/main/resources/ui/src/components/my-data-details/ManageTab.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/components/my-data-details/ManageTab.tsx @@ -17,6 +17,7 @@ import { AxiosResponse } from 'axios'; import { isEmpty } from 'lodash'; +import { observer } from 'mobx-react'; import { TableDetail } from 'Models'; import React, { FunctionComponent, useEffect, useState } from 'react'; import appState from '../../AppState'; @@ -64,13 +65,51 @@ const ManageTab: FunctionComponent = ({ name: team?.displayName || team.name, value: team.id, group: 'Teams', + type: 'team', })); - return user - ? [{ name: user.displayName, value: user.id }, ...teams] - : teams; + if (user?.isAdmin) { + const users = appState.users + .map((user) => ({ + name: user.displayName, + value: user.id, + group: 'Users', + type: 'user', + })) + .filter((u) => u.value != user.id); + const teams = appState.userTeams.map((team) => ({ + name: team.displayName || team.name, + value: team.id, + group: 'Teams', + type: 'team', + })); + + return [ + { + name: user.displayName, + value: user.id, + group: 'Users', + type: 'user', + }, + ...users, + ...teams, + ]; + } else { + return user + ? [ + { + name: user.displayName, + value: user.id, + group: 'Users', + type: 'user', + }, + ...teams, + ] + : teams; + } }); const [owner, setOwner] = useState(currentUser); + const [isLoadingTierData, setIsLoadingTierData] = useState(false); const getOwnerById = (): string => { return listOwners.find((item) => item.value === owner)?.name || ''; @@ -101,7 +140,9 @@ const ManageTab: FunctionComponent = ({ owner !== currentUser ? { id: owner, - type: owner === listOwners[0].value ? 'user' : 'team', + type: listOwners.find((item) => item.value === owner)?.type as + | 'user' + | 'team', } : undefined; const newTier = activeTier !== currentTier ? activeTier : undefined; @@ -117,6 +158,7 @@ const ManageTab: FunctionComponent = ({ }; const getTierData = () => { + setIsLoadingTierData(true); getCategory('Tier').then((res: AxiosResponse) => { if (res.data) { const tierData = res.data.children.map( @@ -134,8 +176,10 @@ const ManageTab: FunctionComponent = ({ ); setTierData(tierData); + setIsLoadingTierData(false); } else { setTierData([]); + setIsLoadingTierData(false); } }); }; @@ -187,8 +231,9 @@ const ManageTab: FunctionComponent = ({ {listVisible && ( @@ -196,24 +241,28 @@ const ManageTab: FunctionComponent = ({
- {tierData.map((card, i) => ( - -

You need to be owner to perform this action

-

Claim ownership from above

- - } - isOwner={hasEditAccess || Boolean(owner)} - key={i} - position="left"> - -
- ))} + {isLoadingTierData ? ( + + ) : ( + tierData.map((card, i) => ( + +

You need to be owner to perform this action

+

Claim ownership from above

+ + } + isOwner={hasEditAccess || Boolean(owner)} + key={i} + position="left"> + +
+ )) + )}