diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json index ce1383a3..922c51a7 100644 --- a/web/src/i18n/locales/en.json +++ b/web/src/i18n/locales/en.json @@ -46,6 +46,9 @@ "myNamespaces": "My Namespaces", "stars": "Starred", "reviews": "Review Management", + "promotions": "Promotion Management", + "users": "User Management", + "auditLog": "Audit Log", "security": "Security Settings", "accounts": "Account Merge", "logout": "Logout" diff --git a/web/src/i18n/locales/zh.json b/web/src/i18n/locales/zh.json index 2a77aee3..98509331 100644 --- a/web/src/i18n/locales/zh.json +++ b/web/src/i18n/locales/zh.json @@ -46,6 +46,9 @@ "myNamespaces": "我的命名空间", "stars": "我的星标", "reviews": "审核管理", + "promotions": "推广管理", + "users": "用户管理", + "auditLog": "审计日志", "security": "安全设置", "accounts": "账号合并", "logout": "退出登录" diff --git a/web/src/shared/components/user-menu.tsx b/web/src/shared/components/user-menu.tsx index 1042fe97..05fbbb4c 100644 --- a/web/src/shared/components/user-menu.tsx +++ b/web/src/shared/components/user-menu.tsx @@ -11,6 +11,7 @@ import { interface User { displayName: string avatarUrl?: string + platformRoles?: string[] } interface UserMenuProps { @@ -21,6 +22,12 @@ export function UserMenu({ user }: UserMenuProps) { const { t } = useTranslation() const navigate = useNavigate() + const hasRole = (role: string) => user.platformRoles?.includes(role) ?? false + const isReviewer = hasRole('SKILL_ADMIN') || hasRole('NAMESPACE_ADMIN') || hasRole('SUPER_ADMIN') + const isSkillAdmin = hasRole('SKILL_ADMIN') || hasRole('SUPER_ADMIN') + const isUserAdmin = hasRole('USER_ADMIN') || hasRole('SUPER_ADMIN') + const isAuditor = hasRole('AUDITOR') || hasRole('SUPER_ADMIN') + const handleLogout = async () => { try { await fetch('/api/auth/logout', { method: 'POST' }) @@ -69,11 +76,35 @@ export function UserMenu({ user }: UserMenuProps) { {t('user.menu.stars')} - - - {t('user.menu.reviews')} - - + {isReviewer && ( + + + {t('user.menu.reviews')} + + + )} + {isSkillAdmin && ( + + + {t('user.menu.promotions')} + + + )} + {(isUserAdmin || isAuditor) && } + {isUserAdmin && ( + + + {t('user.menu.users')} + + + )} + {isAuditor && ( + + + {t('user.menu.auditLog')} + + + )}