mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-05 21:13:14 +00:00
parent
f5cbcd0ef0
commit
0639bdc083
@ -11,7 +11,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findByTestId, render } from '@testing-library/react';
|
import { findByTestId, fireEvent, render } from '@testing-library/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
import UserCard from './UserCard';
|
import UserCard from './UserCard';
|
||||||
@ -101,4 +101,25 @@ describe('Test userCard component', () => {
|
|||||||
expect(svgIcon).toBeInTheDocument();
|
expect(svgIcon).toBeInTheDocument();
|
||||||
expect(datasetLink).toBeInTheDocument();
|
expect(datasetLink).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('If isOwner is passed it should allow delete action', async () => {
|
||||||
|
const { container } = render(
|
||||||
|
<UserCard
|
||||||
|
isActionVisible
|
||||||
|
isOwner
|
||||||
|
item={mockItem}
|
||||||
|
onRemove={mockRemove}
|
||||||
|
/>,
|
||||||
|
{
|
||||||
|
wrapper: MemoryRouter,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const remove = await findByTestId(container, 'remove');
|
||||||
|
|
||||||
|
fireEvent.click(remove);
|
||||||
|
|
||||||
|
expect(remove).toBeInTheDocument();
|
||||||
|
expect(mockRemove).toBeCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -42,6 +42,7 @@ interface Props {
|
|||||||
isIconVisible?: boolean;
|
isIconVisible?: boolean;
|
||||||
isDataset?: boolean;
|
isDataset?: boolean;
|
||||||
isCheckBoxes?: boolean;
|
isCheckBoxes?: boolean;
|
||||||
|
isOwner?: boolean;
|
||||||
onSelect?: (value: string) => void;
|
onSelect?: (value: string) => void;
|
||||||
onRemove?: (value: string) => void;
|
onRemove?: (value: string) => void;
|
||||||
}
|
}
|
||||||
@ -52,6 +53,7 @@ const UserCard = ({
|
|||||||
isIconVisible = false,
|
isIconVisible = false,
|
||||||
isDataset = false,
|
isDataset = false,
|
||||||
isCheckBoxes = false,
|
isCheckBoxes = false,
|
||||||
|
isOwner = false,
|
||||||
onSelect,
|
onSelect,
|
||||||
onRemove,
|
onRemove,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
@ -202,6 +204,7 @@ const UserCard = ({
|
|||||||
) : (
|
) : (
|
||||||
<NonAdminAction
|
<NonAdminAction
|
||||||
html={<>You do not have permission to update the team.</>}
|
html={<>You do not have permission to update the team.</>}
|
||||||
|
isOwner={isOwner}
|
||||||
permission={Operation.UpdateTeam}
|
permission={Operation.UpdateTeam}
|
||||||
position="bottom">
|
position="bottom">
|
||||||
<span
|
<span
|
||||||
@ -209,6 +212,7 @@ const UserCard = ({
|
|||||||
'tw-opacity-40':
|
'tw-opacity-40':
|
||||||
!isAdminUser &&
|
!isAdminUser &&
|
||||||
!isAuthDisabled &&
|
!isAuthDisabled &&
|
||||||
|
!isOwner &&
|
||||||
!userPermissions[Operation.UpdateTeam],
|
!userPermissions[Operation.UpdateTeam],
|
||||||
})}
|
})}
|
||||||
data-testid="remove"
|
data-testid="remove"
|
||||||
|
|||||||
@ -439,6 +439,7 @@ const TeamsPage = () => {
|
|||||||
<p>There are no users added yet.</p>
|
<p>There are no users added yet.</p>
|
||||||
{isAdminUser ||
|
{isAdminUser ||
|
||||||
isAuthDisabled ||
|
isAuthDisabled ||
|
||||||
|
isOwner() ||
|
||||||
userPermissions[Operation.UpdateTeam] ? (
|
userPermissions[Operation.UpdateTeam] ? (
|
||||||
<>
|
<>
|
||||||
<p>Would like to start adding some?</p>
|
<p>Would like to start adding some?</p>
|
||||||
@ -476,6 +477,7 @@ const TeamsPage = () => {
|
|||||||
<UserCard
|
<UserCard
|
||||||
isActionVisible
|
isActionVisible
|
||||||
isIconVisible
|
isIconVisible
|
||||||
|
isOwner={isOwner()}
|
||||||
item={User}
|
item={User}
|
||||||
key={index}
|
key={index}
|
||||||
onRemove={deleteUserHandler}
|
onRemove={deleteUserHandler}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user