mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-03 11:05:08 +00:00
support owner operation with editOwner and editALL for teams (#23625)
* support owner opertaion with editOwner and editALL for teams * remove the isAdmin condition here, as for admin there will be editALL permissionby default * fix the playwright test * used the getPrioritizedEditPermission method for permission check
This commit is contained in:
parent
d0074d748a
commit
dbf482f8da
@ -798,7 +798,7 @@ test.describe('Teams Page with Data Consumer User', () => {
|
||||
dataConsumerPage.getByTestId('edit-team-name')
|
||||
).not.toBeVisible();
|
||||
await expect(dataConsumerPage.getByTestId('add-domain')).not.toBeVisible();
|
||||
await expect(dataConsumerPage.getByTestId('edit-owner')).not.toBeVisible();
|
||||
await expect(dataConsumerPage.getByTestId('edit-owner')).toBeVisible();
|
||||
await expect(dataConsumerPage.getByTestId('edit-email')).not.toBeVisible();
|
||||
await expect(
|
||||
dataConsumerPage.getByTestId('edit-team-subscription')
|
||||
@ -969,12 +969,12 @@ test.describe('Teams Page action as Owner of Team', () => {
|
||||
state: 'detached',
|
||||
});
|
||||
|
||||
await expect(ownerUserPage.getByTestId('edit-owner')).toBeVisible();
|
||||
|
||||
await expect(ownerUserPage.getByTestId('manage-button')).not.toBeVisible();
|
||||
|
||||
await expect(ownerUserPage.getByTestId('add-domain')).not.toBeVisible();
|
||||
|
||||
await expect(ownerUserPage.getByTestId('edit-owner')).not.toBeVisible();
|
||||
|
||||
await expect(ownerUserPage.getByTestId('edit-email')).not.toBeVisible();
|
||||
|
||||
await expect(
|
||||
@ -986,6 +986,7 @@ test.describe('Teams Page action as Owner of Team', () => {
|
||||
await executionOnOwnerTeam(ownerUserPage, team, {
|
||||
domain: domain,
|
||||
email: teamDetails.updatedEmail,
|
||||
user: user.responseData.displayName,
|
||||
});
|
||||
});
|
||||
|
||||
@ -993,6 +994,7 @@ test.describe('Teams Page action as Owner of Team', () => {
|
||||
await executionOnOwnerTeam(ownerUserPage, team2, {
|
||||
domain: domain,
|
||||
email: teamDetails.updatedEmail,
|
||||
user: user.responseData.displayName,
|
||||
});
|
||||
});
|
||||
|
||||
@ -1000,6 +1002,7 @@ test.describe('Teams Page action as Owner of Team', () => {
|
||||
await executionOnOwnerTeam(ownerUserPage, team3, {
|
||||
domain: domain,
|
||||
email: teamDetails.updatedEmail,
|
||||
user: user.responseData.displayName,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
import { APIRequestContext, expect, Page } from '@playwright/test';
|
||||
import { GlobalSettingOptions } from '../constant/settings';
|
||||
import { Domain } from '../support/domain/Domain';
|
||||
import { EntityTypeEndpoint } from '../support/entity/Entity.interface';
|
||||
import { TableClass } from '../support/entity/TableClass';
|
||||
import { TeamClass } from '../support/team/TeamClass';
|
||||
import { UserClass } from '../support/user/UserClass';
|
||||
@ -22,7 +23,7 @@ import {
|
||||
toastNotification,
|
||||
uuid,
|
||||
} from './common';
|
||||
import { addOwner } from './entity';
|
||||
import { addMultiOwner, addOwner } from './entity';
|
||||
import { validateFormNameFieldInput } from './form';
|
||||
import { settingClick } from './sidebar';
|
||||
|
||||
@ -447,6 +448,7 @@ export const executionOnOwnerTeam = async (
|
||||
data: {
|
||||
domain: Domain;
|
||||
email: string;
|
||||
user: string;
|
||||
}
|
||||
) => {
|
||||
await team.visitTeamPage(page);
|
||||
@ -458,6 +460,16 @@ export const executionOnOwnerTeam = async (
|
||||
|
||||
await assignDomain(page, data.domain.responseData);
|
||||
|
||||
await addMultiOwner({
|
||||
page,
|
||||
ownerNames: [data.user],
|
||||
activatorBtnDataTestId: 'edit-owner',
|
||||
resultTestId: 'teams-info-header',
|
||||
endpoint: EntityTypeEndpoint.Teams,
|
||||
type: 'Users',
|
||||
clearAll: false,
|
||||
});
|
||||
|
||||
await addEmailTeam(page, data.email);
|
||||
|
||||
await page.getByTestId('add-placeholder-button').click();
|
||||
|
||||
@ -28,10 +28,11 @@ import {
|
||||
} from '../../../../../constants/constants';
|
||||
import { EMAIL_REG_EX } from '../../../../../constants/regex.constants';
|
||||
import { EntityType } from '../../../../../enums/entity.enum';
|
||||
import { Operation } from '../../../../../generated/entity/policies/policy';
|
||||
import { Team, TeamType } from '../../../../../generated/entity/teams/team';
|
||||
import { EntityReference } from '../../../../../generated/entity/type';
|
||||
import { useAuth } from '../../../../../hooks/authHooks';
|
||||
import { useApplicationStore } from '../../../../../hooks/useApplicationStore';
|
||||
import { getPrioritizedEditPermission } from '../../../../../utils/PermissionsUtils';
|
||||
import { DomainLabel } from '../../../../common/DomainLabel/DomainLabel.component';
|
||||
import { OwnerLabel } from '../../../../common/OwnerLabel/OwnerLabel.component';
|
||||
import TeamTypeSelect from '../../../../common/TeamTypeSelect/TeamTypeSelect.component';
|
||||
@ -49,8 +50,6 @@ const TeamsInfo = ({
|
||||
}: TeamsInfoProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { isAdminUser } = useAuth();
|
||||
|
||||
const [isEmailEdit, setIsEmailEdit] = useState<boolean>(false);
|
||||
const [showTypeSelector, setShowTypeSelector] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
@ -62,10 +61,12 @@ const TeamsInfo = ({
|
||||
[currentTeam]
|
||||
);
|
||||
|
||||
const { hasEditPermission, hasAccess } = useMemo(
|
||||
const { hasEditPermission, hasEditOwnerPermission } = useMemo(
|
||||
() => ({
|
||||
hasEditPermission: entityPermissions.EditAll && !isTeamDeleted,
|
||||
hasAccess: isAdminUser && !isTeamDeleted,
|
||||
hasEditOwnerPermission:
|
||||
getPrioritizedEditPermission(entityPermissions, Operation.EditOwners) &&
|
||||
!isTeamDeleted,
|
||||
}),
|
||||
|
||||
[entityPermissions, isTeamDeleted]
|
||||
@ -307,7 +308,10 @@ const TeamsInfo = ({
|
||||
]);
|
||||
|
||||
return (
|
||||
<Space className="teams-info-header-container" size={0}>
|
||||
<Space
|
||||
className="teams-info-header-container"
|
||||
data-testid="teams-info-header"
|
||||
size={0}>
|
||||
<DomainLabel
|
||||
headerLayout
|
||||
multiple
|
||||
@ -320,7 +324,7 @@ const TeamsInfo = ({
|
||||
<Divider className="vertical-divider" type="vertical" />
|
||||
<OwnerLabel
|
||||
className="text-sm"
|
||||
hasPermission={hasAccess}
|
||||
hasPermission={hasEditOwnerPermission}
|
||||
isCompactView={false}
|
||||
owners={owners}
|
||||
onUpdate={updateOwner}
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
*/
|
||||
import { act, fireEvent, render, screen } from '@testing-library/react';
|
||||
import { TeamType } from '../../../../../generated/entity/teams/team';
|
||||
import { useAuth } from '../../../../../hooks/authHooks';
|
||||
import { ENTITY_PERMISSIONS } from '../../../../../mocks/Permissions.mock';
|
||||
import TeamsInfo from './TeamsInfo.component';
|
||||
|
||||
@ -45,10 +44,6 @@ const mockTeam = {
|
||||
version: 1,
|
||||
};
|
||||
|
||||
jest.mock('../../../../../hooks/authHooks', () => ({
|
||||
useAuth: jest.fn().mockReturnValue({ isAdminUser: true }),
|
||||
}));
|
||||
|
||||
jest.mock('../../../../common/OwnerLabel/OwnerLabel.component', () => ({
|
||||
OwnerLabel: jest.fn().mockImplementation(() => <div>OwnerLabel</div>),
|
||||
}));
|
||||
@ -161,8 +156,6 @@ describe('TeamsInfo', () => {
|
||||
});
|
||||
|
||||
it('should not show edit button if user does not have permission', () => {
|
||||
(useAuth as jest.Mock).mockReturnValue({ isAdminUser: false });
|
||||
|
||||
mockEntityPermissions.EditAll = false;
|
||||
const { queryByTestId } = render(<TeamsInfo {...teamProps} />);
|
||||
const ownerLabel = queryByTestId('edit-email');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user