mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-02 03:29:03 +00:00
parent
7652baa00d
commit
87e8059c0e
@ -96,7 +96,7 @@ const DropDownList: FunctionComponent<DropDownListProp> = ({
|
|||||||
{showSearchBar && (
|
{showSearchBar && (
|
||||||
<div className="has-search tw-p-4 tw-pb-2">
|
<div className="has-search tw-p-4 tw-pb-2">
|
||||||
<input
|
<input
|
||||||
className="form-control form-control-sm search"
|
className="tw-form-inputs tw-px-3 tw-py-1"
|
||||||
placeholder="Search..."
|
placeholder="Search..."
|
||||||
type="text"
|
type="text"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@ -114,11 +114,13 @@ const DropDownList: FunctionComponent<DropDownListProp> = ({
|
|||||||
{listGroups.map((grp, index) => {
|
{listGroups.map((grp, index) => {
|
||||||
return (
|
return (
|
||||||
<div key={index}>
|
<div key={index}>
|
||||||
<span className="tw-flex tw-my-1 tw-text-grey-muted">
|
{getSearchedListByGroup(grp).length > 0 && (
|
||||||
<hr className="tw-mt-2 tw-w-full " />
|
<span className="tw-flex tw-my-1 tw-text-grey-muted">
|
||||||
<span className="tw-text-xs tw-px-0.5">{grp}</span>{' '}
|
<hr className="tw-mt-2 tw-w-full " />
|
||||||
<hr className="tw-mt-2 tw-w-full" />
|
<span className="tw-text-xs tw-px-0.5">{grp}</span>{' '}
|
||||||
</span>
|
<hr className="tw-mt-2 tw-w-full" />
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
{getSearchedListByGroup(grp).map(
|
{getSearchedListByGroup(grp).map(
|
||||||
(item: DropDownListItem, index: number) =>
|
(item: DropDownListItem, index: number) =>
|
||||||
getDropDownElement(item, index)
|
getDropDownElement(item, index)
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import { AxiosResponse } from 'axios';
|
import { AxiosResponse } from 'axios';
|
||||||
import { isEmpty } from 'lodash';
|
import { isEmpty } from 'lodash';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
import { TableDetail } from 'Models';
|
import { TableDetail } from 'Models';
|
||||||
import React, { FunctionComponent, useEffect, useState } from 'react';
|
import React, { FunctionComponent, useEffect, useState } from 'react';
|
||||||
import appState from '../../AppState';
|
import appState from '../../AppState';
|
||||||
@ -64,13 +65,51 @@ const ManageTab: FunctionComponent<Props> = ({
|
|||||||
name: team?.displayName || team.name,
|
name: team?.displayName || team.name,
|
||||||
value: team.id,
|
value: team.id,
|
||||||
group: 'Teams',
|
group: 'Teams',
|
||||||
|
type: 'team',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return user
|
if (user?.isAdmin) {
|
||||||
? [{ name: user.displayName, value: user.id }, ...teams]
|
const users = appState.users
|
||||||
: teams;
|
.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 [owner, setOwner] = useState(currentUser);
|
||||||
|
const [isLoadingTierData, setIsLoadingTierData] = useState<boolean>(false);
|
||||||
|
|
||||||
const getOwnerById = (): string => {
|
const getOwnerById = (): string => {
|
||||||
return listOwners.find((item) => item.value === owner)?.name || '';
|
return listOwners.find((item) => item.value === owner)?.name || '';
|
||||||
@ -101,7 +140,9 @@ const ManageTab: FunctionComponent<Props> = ({
|
|||||||
owner !== currentUser
|
owner !== currentUser
|
||||||
? {
|
? {
|
||||||
id: owner,
|
id: owner,
|
||||||
type: owner === listOwners[0].value ? 'user' : 'team',
|
type: listOwners.find((item) => item.value === owner)?.type as
|
||||||
|
| 'user'
|
||||||
|
| 'team',
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
const newTier = activeTier !== currentTier ? activeTier : undefined;
|
const newTier = activeTier !== currentTier ? activeTier : undefined;
|
||||||
@ -117,6 +158,7 @@ const ManageTab: FunctionComponent<Props> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getTierData = () => {
|
const getTierData = () => {
|
||||||
|
setIsLoadingTierData(true);
|
||||||
getCategory('Tier').then((res: AxiosResponse) => {
|
getCategory('Tier').then((res: AxiosResponse) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
const tierData = res.data.children.map(
|
const tierData = res.data.children.map(
|
||||||
@ -134,8 +176,10 @@ const ManageTab: FunctionComponent<Props> = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
setTierData(tierData);
|
setTierData(tierData);
|
||||||
|
setIsLoadingTierData(false);
|
||||||
} else {
|
} else {
|
||||||
setTierData([]);
|
setTierData([]);
|
||||||
|
setIsLoadingTierData(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -187,8 +231,9 @@ const ManageTab: FunctionComponent<Props> = ({
|
|||||||
</Button>
|
</Button>
|
||||||
{listVisible && (
|
{listVisible && (
|
||||||
<DropDownList
|
<DropDownList
|
||||||
|
showSearchBar
|
||||||
dropDownList={listOwners}
|
dropDownList={listOwners}
|
||||||
listGroups={['Teams']}
|
listGroups={['Users', 'Teams']}
|
||||||
value={owner}
|
value={owner}
|
||||||
onSelect={handleOwnerSelection}
|
onSelect={handleOwnerSelection}
|
||||||
/>
|
/>
|
||||||
@ -196,24 +241,28 @@ const ManageTab: FunctionComponent<Props> = ({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="tw-flex tw-flex-col">
|
<div className="tw-flex tw-flex-col">
|
||||||
{tierData.map((card, i) => (
|
{isLoadingTierData ? (
|
||||||
<NonAdminAction
|
<Loader />
|
||||||
html={
|
) : (
|
||||||
<>
|
tierData.map((card, i) => (
|
||||||
<p>You need to be owner to perform this action</p>
|
<NonAdminAction
|
||||||
<p>Claim ownership from above </p>
|
html={
|
||||||
</>
|
<>
|
||||||
}
|
<p>You need to be owner to perform this action</p>
|
||||||
isOwner={hasEditAccess || Boolean(owner)}
|
<p>Claim ownership from above </p>
|
||||||
key={i}
|
</>
|
||||||
position="left">
|
}
|
||||||
<CardListItem
|
isOwner={hasEditAccess || Boolean(owner)}
|
||||||
card={card}
|
key={i}
|
||||||
isActive={activeTier === card.id}
|
position="left">
|
||||||
onSelect={handleCardSelection}
|
<CardListItem
|
||||||
/>
|
card={card}
|
||||||
</NonAdminAction>
|
isActive={activeTier === card.id}
|
||||||
))}
|
onSelect={handleCardSelection}
|
||||||
|
/>
|
||||||
|
</NonAdminAction>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="tw-mt-6 tw-text-right">
|
<div className="tw-mt-6 tw-text-right">
|
||||||
<Button
|
<Button
|
||||||
@ -256,4 +305,4 @@ const ManageTab: FunctionComponent<Props> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ManageTab;
|
export default observer(ManageTab);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user