mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 06:47:02 +08:00
refactor(core): use workspace role query instead of isOwner query (#12118)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated workspace permission handling to use a unified role field within workspace data instead of separate admin and owner flags. - Permission checks now rely on the workspace role for determining admin and owner status. - **Chores** - Removed deprecated queries and types related to admin and owner status. - Cleaned up internal logic and variable naming for improved consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -83,7 +83,7 @@ const AccountMenu = () => {
|
||||
const openSignOutModal = useSignOut();
|
||||
const serverService = useService(ServerService);
|
||||
const userFeatureService = useService(UserFeatureService);
|
||||
const isAdmin = useLiveData(userFeatureService.userFeature.isAdmin$);
|
||||
const isAFFiNEAdmin = useLiveData(userFeatureService.userFeature.isAdmin$);
|
||||
|
||||
const onOpenAccountSetting = useCallback(() => {
|
||||
track.$.navigationPanel.profileAndBadge.openSettings({ to: 'account' });
|
||||
@@ -111,7 +111,7 @@ const AccountMenu = () => {
|
||||
>
|
||||
{t['com.affine.workspace.cloud.account.settings']()}
|
||||
</MenuItem>
|
||||
{isAdmin ? (
|
||||
{isAFFiNEAdmin ? (
|
||||
<MenuItem
|
||||
prefixIcon={<AdminIcon />}
|
||||
data-testid="workspace-modal-account-admin-option"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Permission } from '@affine/graphql';
|
||||
import {
|
||||
backoffRetry,
|
||||
effect,
|
||||
@@ -43,8 +44,8 @@ export class WorkspacePermission extends Entity {
|
||||
);
|
||||
|
||||
return {
|
||||
isOwner: info.isOwner,
|
||||
isAdmin: info.isAdmin,
|
||||
isOwner: info.workspace.role === Permission.Owner,
|
||||
isAdmin: info.workspace.role === Permission.Admin,
|
||||
isTeam: info.workspace.team,
|
||||
};
|
||||
} else {
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
deleteWorkspaceMutation,
|
||||
getWorkspaceInfoQuery,
|
||||
getWorkspacesQuery,
|
||||
Permission,
|
||||
ServerDeploymentType,
|
||||
} from '@affine/graphql';
|
||||
import type {
|
||||
@@ -339,8 +340,8 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
|
||||
if (!cloudData && !localData) {
|
||||
return {
|
||||
isOwner: info.isOwner,
|
||||
isAdmin: info.isAdmin,
|
||||
isOwner: info.workspace.role === Permission.Owner,
|
||||
isAdmin: info.workspace.role === Permission.Admin,
|
||||
isTeam: info.workspace.team,
|
||||
};
|
||||
}
|
||||
@@ -355,8 +356,8 @@ class CloudWorkspaceFlavourProvider implements WorkspaceFlavourProvider {
|
||||
return {
|
||||
name: result.name,
|
||||
avatar: result.avatar,
|
||||
isOwner: info.isOwner,
|
||||
isAdmin: info.isAdmin,
|
||||
isOwner: info.workspace.role === Permission.Owner,
|
||||
isAdmin: info.workspace.role === Permission.Admin,
|
||||
isTeam: info.workspace.team,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user