fix(core): adjust admin permission (#9204)

close AF-2001 AF-2002
This commit is contained in:
JimmFly 2024-12-20 02:26:17 +00:00
parent 0fdf2c4905
commit 7ff24e9c1c
No known key found for this signature in database
GPG Key ID: 126E0320FEB0D05C
7 changed files with 13 additions and 9 deletions

View File

@ -69,6 +69,9 @@ export const ModalContent = ({
/>
),
value: 'link',
style: {
cursor: 'not-allowed',
},
},
]}
/>

View File

@ -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 (
<>
<SettingRow name={title} desc={desc} spreadCol={!!isOwner}>
{isOwner ? (
<SettingRow name={title} desc={desc} spreadCol={!!isOwnerOrAdmin}>
{isOwnerOrAdmin ? (
<>
<Button onClick={openInviteModal}>{t['Invite Members']()}</Button>
{!isTeam ? (

View File

@ -210,7 +210,7 @@ const MemberItem = ({
</div>
<div
className={clsx(styles.roleOrStatus, {
pending: !member.accepted,
pending: member.status !== WorkspaceMemberStatus.Accepted,
})}
>
{t.t(memberStatus)}

View File

@ -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,
},

View File

@ -8,7 +8,6 @@ query getMembersByWorkspaceId($workspaceId: String!, $skip: Int!, $take: Int!) {
avatarUrl
permission
inviteId
accepted
emailVerified
status
}

View File

@ -469,7 +469,6 @@ query getMembersByWorkspaceId($workspaceId: String!, $skip: Int!, $take: Int!) {
avatarUrl
permission
inviteId
accepted
emailVerified
status
}

View File

@ -1844,7 +1844,6 @@ export type GetMembersByWorkspaceIdQuery = {
avatarUrl: string | null;
permission: Permission;
inviteId: string;
accepted: boolean;
emailVerified: boolean | null;
status: WorkspaceMemberStatus;
}>;