From 6a33709ccf48586f1a8b62216688ea300b7b5dfb Mon Sep 17 00:00:00 2001 From: panteliselef Date: Tue, 5 Dec 2023 22:46:42 +0200 Subject: [PATCH] chore(clerk-js,types): Remove system delete permission for domains and memberships (#2256) The `delete` permission has been merged with `manage` --- .changeset/moody-zoos-deliver.md | 6 +++++ packages/clerk-js/src/core/test/fixtures.ts | 2 -- .../OrganizationProfile/ActiveMembersList.tsx | 2 +- .../OrganizationProfile/DomainList.tsx | 23 ++++------------- .../OrganizationProfileRoutes.tsx | 4 +-- .../VerifiedDomainPage.tsx | 5 ++-- .../OrganizationProfile/ActiveMembersList.tsx | 2 +- .../OrganizationProfile/DomainList.tsx | 25 +++++-------------- .../OrganizationProfileRoutes.tsx | 4 +-- .../VerifiedDomainPage.tsx | 5 ++-- packages/types/src/organizationMembership.ts | 2 -- 11 files changed, 27 insertions(+), 53 deletions(-) create mode 100644 .changeset/moody-zoos-deliver.md diff --git a/.changeset/moody-zoos-deliver.md b/.changeset/moody-zoos-deliver.md new file mode 100644 index 0000000000..1a8f137251 --- /dev/null +++ b/.changeset/moody-zoos-deliver.md @@ -0,0 +1,6 @@ +--- +'@clerk/clerk-js': patch +'@clerk/types': patch +--- + +Drop `org:sys_domains:delete` and `org:sys_memberships:delete` as those have now been merged with the respective `manage` ones. diff --git a/packages/clerk-js/src/core/test/fixtures.ts b/packages/clerk-js/src/core/test/fixtures.ts index cee4c65c86..e3409864b5 100644 --- a/packages/clerk-js/src/core/test/fixtures.ts +++ b/packages/clerk-js/src/core/test/fixtures.ts @@ -56,10 +56,8 @@ export const createOrganizationMembership = (params: OrgParams): OrganizationMem public_metadata: {}, role: role || 'admin', permissions: permissions || [ - 'org:sys_domains:delete', 'org:sys_domains:manage', 'org:sys_domains:read', - 'org:sys_memberships:delete', 'org:sys_memberships:manage', 'org:sys_memberships:read', 'org:sys_profile:delete', diff --git a/packages/clerk-js/src/ui.retheme/components/OrganizationProfile/ActiveMembersList.tsx b/packages/clerk-js/src/ui.retheme/components/OrganizationProfile/ActiveMembersList.tsx index f12e836c0d..e9915d9d18 100644 --- a/packages/clerk-js/src/ui.retheme/components/OrganizationProfile/ActiveMembersList.tsx +++ b/packages/clerk-js/src/ui.retheme/components/OrganizationProfile/ActiveMembersList.tsx @@ -117,7 +117,7 @@ const MemberRow = (props: { - + { - const { isAuthorizedUser: canDeleteDomain } = useGate({ permission: 'org:sys_domains:delete' }); - const { isAuthorizedUser: canVerifyDomain } = useGate({ permission: 'org:sys_domains:manage' }); - - return { - showDotMenu: canDeleteDomain || canVerifyDomain, - canVerifyDomain, - canDeleteDomain, - }; -}; - const buildDomainListRelativeURL = (parentPath: string, domainId: string, mode?: 'verify' | 'remove') => trimLeadingSlash(stripOrigin(toURL(`${parentPath}/${domainId}/${mode || ''}`))); @@ -45,19 +34,17 @@ const useMenuActions = ( parentPath: string, domainId: string, ): { label: LocalizationKey; onClick: () => Promise; isDestructive?: boolean }[] => { - const { canDeleteDomain, canVerifyDomain } = useDomainList(); + const { isAuthorizedUser: canManageDomain } = useGate({ permission: 'org:sys_domains:manage' }); const { navigate } = useRouter(); const menuActions = []; - if (canVerifyDomain) { + if (canManageDomain) { menuActions.push({ label: localizationKeys('organizationProfile.profilePage.domainSection.unverifiedDomain_menuAction__verify'), onClick: () => navigate(buildDomainListRelativeURL(parentPath, domainId, 'verify')), }); - } - if (canDeleteDomain) { menuActions.push({ label: localizationKeys('organizationProfile.profilePage.domainSection.unverifiedDomain_menuAction__remove'), isDestructive: true, @@ -88,7 +75,7 @@ export const DomainList = withGate( }, }); - const { showDotMenu } = useDomainList(); + const { isAuthorizedUser: canManageDomain } = useGate({ permission: 'org:sys_domains:manage' }); const { ref } = useInView({ threshold: 0, onChange: inView => { @@ -127,7 +114,7 @@ export const DomainList = withGate( {domainList.length === 0 && !domains?.isLoading && fallback} {domainList.map(d => { - if (!(d.verification && d.verification.status === 'verified') || !showDotMenu) { + if (!(d.verification && d.verification.status === 'verified') || !canManageDomain) { return ( } trailingComponent={ - showDotMenu ? ( + canManageDomain ? ( @@ -77,7 +77,7 @@ export const OrganizationProfileRoutes = (props: PropsOfComponent diff --git a/packages/clerk-js/src/ui.retheme/components/OrganizationProfile/VerifiedDomainPage.tsx b/packages/clerk-js/src/ui.retheme/components/OrganizationProfile/VerifiedDomainPage.tsx index 96f29ef0cf..825ff77f60 100644 --- a/packages/clerk-js/src/ui.retheme/components/OrganizationProfile/VerifiedDomainPage.tsx +++ b/packages/clerk-js/src/ui.retheme/components/OrganizationProfile/VerifiedDomainPage.tsx @@ -107,7 +107,6 @@ export const VerifiedDomainPage = withCardStateProvider(() => { }); const { isAuthorizedUser: canManageDomain } = useGate({ permission: 'org:sys_domains:manage' }); - const { isAuthorizedUser: canDeleteDomain } = useGate({ permission: 'org:sys_domains:delete' }); const { navigateToFlowStart } = useNavigateToFlowStart(); const { params, navigate, queryParams } = useRouter(); @@ -218,7 +217,7 @@ export const VerifiedDomainPage = withCardStateProvider(() => { )} /> )} - {allowsEdit && canDeleteDomain && ( + {allowsEdit && canManageDomain && ( @@ -278,7 +277,7 @@ export const VerifiedDomainPage = withCardStateProvider(() => { )} - {allowsEdit && canDeleteDomain && ( + {allowsEdit && canManageDomain && ( - + { - const { isAuthorizedUser: canDeleteDomain } = useGate({ permission: 'org:sys_domains:delete' }); - const { isAuthorizedUser: canVerifyDomain } = useGate({ permission: 'org:sys_domains:manage' }); - - return { - showDotMenu: canDeleteDomain || canVerifyDomain, - canVerifyDomain, - canDeleteDomain, - }; -}; - const buildDomainListRelativeURL = (parentPath: string, domainId: string, mode?: 'verify' | 'remove') => trimLeadingSlash(stripOrigin(toURL(`${parentPath}/${domainId}/${mode || ''}`))); @@ -45,19 +34,17 @@ const useMenuActions = ( parentPath: string, domainId: string, ): { label: LocalizationKey; onClick: () => Promise; isDestructive?: boolean }[] => { - const { canDeleteDomain, canVerifyDomain } = useDomainList(); + const { isAuthorizedUser: canManageDomain } = useGate({ permission: 'org:sys_domains:manage' }); + const { navigate } = useRouter(); const menuActions = []; - if (canVerifyDomain) { + if (canManageDomain) { menuActions.push({ label: localizationKeys('organizationProfile.profilePage.domainSection.unverifiedDomain_menuAction__verify'), onClick: () => navigate(buildDomainListRelativeURL(parentPath, domainId, 'verify')), }); - } - - if (canDeleteDomain) { menuActions.push({ label: localizationKeys('organizationProfile.profilePage.domainSection.unverifiedDomain_menuAction__remove'), isDestructive: true, @@ -88,7 +75,7 @@ export const DomainList = withGate( }, }); - const { showDotMenu } = useDomainList(); + const { isAuthorizedUser: canManageDomain } = useGate({ permission: 'org:sys_domains:manage' }); const { ref } = useInView({ threshold: 0, onChange: inView => { @@ -127,7 +114,7 @@ export const DomainList = withGate( {domainList.length === 0 && !domains?.isLoading && fallback} {domainList.map(d => { - if (!(d.verification && d.verification.status === 'verified') || !showDotMenu) { + if (!(d.verification && d.verification.status === 'verified') || !canManageDomain) { return ( } trailingComponent={ - showDotMenu ? ( + canManageDomain ? ( @@ -77,7 +77,7 @@ export const OrganizationProfileRoutes = (props: PropsOfComponent diff --git a/packages/clerk-js/src/ui/components/OrganizationProfile/VerifiedDomainPage.tsx b/packages/clerk-js/src/ui/components/OrganizationProfile/VerifiedDomainPage.tsx index 5d2e3cd86d..54a2dd7497 100644 --- a/packages/clerk-js/src/ui/components/OrganizationProfile/VerifiedDomainPage.tsx +++ b/packages/clerk-js/src/ui/components/OrganizationProfile/VerifiedDomainPage.tsx @@ -107,7 +107,6 @@ export const VerifiedDomainPage = withCardStateProvider(() => { }); const { isAuthorizedUser: canManageDomain } = useGate({ permission: 'org:sys_domains:manage' }); - const { isAuthorizedUser: canDeleteDomain } = useGate({ permission: 'org:sys_domains:delete' }); const { navigateToFlowStart } = useNavigateToFlowStart(); const { params, navigate, queryParams } = useRouter(); @@ -217,7 +216,7 @@ export const VerifiedDomainPage = withCardStateProvider(() => { )} /> )} - {allowsEdit && canDeleteDomain && ( + {allowsEdit && canManageDomain && ( @@ -277,7 +276,7 @@ export const VerifiedDomainPage = withCardStateProvider(() => { )} - {allowsEdit && canDeleteDomain && ( + {allowsEdit && canManageDomain && (