From 7ff24e9c1c3c6592869557f7647ef5db53df9f2a Mon Sep 17 00:00:00 2001 From: JimmFly Date: Fri, 20 Dec 2024 02:26:17 +0000 Subject: [PATCH] fix(core): adjust admin permission (#9204) close AF-2001 AF-2002 --- .../invite-team-modal/modal-content.tsx | 3 +++ .../members/cloud-members-panel.tsx | 5 +++-- .../new-workspace-setting-detail/members/member-list.tsx | 2 +- .../members/member-option.tsx | 9 ++++++--- .../graphql/src/graphql/get-members-by-workspace-id.gql | 1 - packages/frontend/graphql/src/graphql/index.ts | 1 - packages/frontend/graphql/src/schema.ts | 1 - 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/frontend/component/src/components/member-components/invite-team-modal/modal-content.tsx b/packages/frontend/component/src/components/member-components/invite-team-modal/modal-content.tsx index 76f58b8981..8670b9c1cd 100644 --- a/packages/frontend/component/src/components/member-components/invite-team-modal/modal-content.tsx +++ b/packages/frontend/component/src/components/member-components/invite-team-modal/modal-content.tsx @@ -69,6 +69,9 @@ export const ModalContent = ({ /> ), value: 'link', + style: { + cursor: 'not-allowed', + }, }, ]} /> diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/cloud-members-panel.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/cloud-members-panel.tsx index 9f28db5a48..e0890e1e3f 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/cloud-members-panel.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/cloud-members-panel.tsx @@ -62,6 +62,7 @@ export const CloudWorkspaceMembersPanel = ({ const permissionService = useService(WorkspacePermissionService); const isOwner = useLiveData(permissionService.permission.isOwner$); const isAdmin = useLiveData(permissionService.permission.isAdmin$); + const isOwnerOrAdmin = isOwner || isAdmin; useEffect(() => { permissionService.permission.revalidate(); }, [permissionService]); @@ -233,8 +234,8 @@ export const CloudWorkspaceMembersPanel = ({ return ( <> - - {isOwner ? ( + + {isOwnerOrAdmin ? ( <> {!isTeam ? ( diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-list.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-list.tsx index b07aa9eee6..6a801c2784 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-list.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-list.tsx @@ -210,7 +210,7 @@ const MemberItem = ({
{t.t(memberStatus)} diff --git a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-option.tsx b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-option.tsx index 99aa2aacdb..10a0923d19 100644 --- a/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-option.tsx +++ b/packages/frontend/core/src/desktop/dialogs/setting/workspace-setting/new-workspace-setting-detail/members/member-option.tsx @@ -193,14 +193,17 @@ export const MemberOptions = ({ label: t['com.affine.payment.member.team.remove'](), onClick: handleRemove, show: - (isAdmin || isOwner) && - member.status === WorkspaceMemberStatus.Accepted, + (isOwner && member.status === WorkspaceMemberStatus.Accepted) || + (isAdmin && + member.status === WorkspaceMemberStatus.Accepted && + member.permission !== Permission.Owner && + member.permission !== Permission.Admin), }, { label: t['com.affine.payment.member.team.change.collaborator'](), onClick: handleChangeToCollaborator, show: - (isAdmin || isOwner) && + isOwner && member.status === WorkspaceMemberStatus.Accepted && member.permission === Permission.Admin, }, diff --git a/packages/frontend/graphql/src/graphql/get-members-by-workspace-id.gql b/packages/frontend/graphql/src/graphql/get-members-by-workspace-id.gql index e6513c32d2..29a77b7e55 100644 --- a/packages/frontend/graphql/src/graphql/get-members-by-workspace-id.gql +++ b/packages/frontend/graphql/src/graphql/get-members-by-workspace-id.gql @@ -8,7 +8,6 @@ query getMembersByWorkspaceId($workspaceId: String!, $skip: Int!, $take: Int!) { avatarUrl permission inviteId - accepted emailVerified status } diff --git a/packages/frontend/graphql/src/graphql/index.ts b/packages/frontend/graphql/src/graphql/index.ts index 9c3417caf0..cada1672ad 100644 --- a/packages/frontend/graphql/src/graphql/index.ts +++ b/packages/frontend/graphql/src/graphql/index.ts @@ -469,7 +469,6 @@ query getMembersByWorkspaceId($workspaceId: String!, $skip: Int!, $take: Int!) { avatarUrl permission inviteId - accepted emailVerified status } diff --git a/packages/frontend/graphql/src/schema.ts b/packages/frontend/graphql/src/schema.ts index 7085df1e23..a48adf3315 100644 --- a/packages/frontend/graphql/src/schema.ts +++ b/packages/frontend/graphql/src/schema.ts @@ -1844,7 +1844,6 @@ export type GetMembersByWorkspaceIdQuery = { avatarUrl: string | null; permission: Permission; inviteId: string; - accepted: boolean; emailVerified: boolean | null; status: WorkspaceMemberStatus; }>;