mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 05:25:53 +08:00
feat(core): add an entry for admin panel (#10813)

This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
} from '@affine/core/modules/dialogs';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { track } from '@affine/track';
|
||||
import { AccountIcon, SignOutIcon } from '@blocksuite/icons/rc';
|
||||
import { AccountIcon, AdminIcon, SignOutIcon } from '@blocksuite/icons/rc';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { cssVar } from '@toeverything/theme';
|
||||
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
ServerService,
|
||||
SubscriptionService,
|
||||
UserCopilotQuotaService,
|
||||
UserFeatureService,
|
||||
UserQuotaService,
|
||||
} from '../../modules/cloud';
|
||||
import { UserPlanButton } from '../affine/auth/user-plan-button';
|
||||
@@ -80,6 +81,9 @@ const UnauthorizedUserInfo = () => {
|
||||
const AccountMenu = () => {
|
||||
const workspaceDialogService = useService(WorkspaceDialogService);
|
||||
const openSignOutModal = useSignOut();
|
||||
const serverService = useService(ServerService);
|
||||
const userFeatureService = useService(UserFeatureService);
|
||||
const isAdmin = useLiveData(userFeatureService.userFeature.isAdmin$);
|
||||
|
||||
const onOpenAccountSetting = useCallback(() => {
|
||||
track.$.navigationPanel.profileAndBadge.openSettings({ to: 'account' });
|
||||
@@ -88,8 +92,16 @@ const AccountMenu = () => {
|
||||
});
|
||||
}, [workspaceDialogService]);
|
||||
|
||||
const onOpenAdminPanel = useCallback(() => {
|
||||
window.open(`${serverService.server.baseUrl}/admin`, '_blank');
|
||||
}, [serverService.server.baseUrl]);
|
||||
|
||||
const t = useI18n();
|
||||
|
||||
useEffect(() => {
|
||||
userFeatureService.userFeature.revalidate();
|
||||
}, [userFeatureService]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MenuItem
|
||||
@@ -99,6 +111,15 @@ const AccountMenu = () => {
|
||||
>
|
||||
{t['com.affine.workspace.cloud.account.settings']()}
|
||||
</MenuItem>
|
||||
{isAdmin ? (
|
||||
<MenuItem
|
||||
prefixIcon={<AdminIcon />}
|
||||
data-testid="workspace-modal-account-admin-option"
|
||||
onClick={onOpenAdminPanel}
|
||||
>
|
||||
{t['com.affine.workspace.cloud.account.admin']()}
|
||||
</MenuItem>
|
||||
) : null}
|
||||
<MenuItem
|
||||
prefixIcon={<SignOutIcon />}
|
||||
data-testid="workspace-modal-sign-out-option"
|
||||
|
||||
Reference in New Issue
Block a user