|
|
@@ -3,11 +3,12 @@ import type { ColumnsType } from 'antd/es/table';
|
|
|
|
|
|
import { PageHeader } from '../components/common/PageHeader';
|
|
|
import { SectionCard } from '../components/common/SectionCard';
|
|
|
-import { StatusPill } from '../components/common/StatusPill';
|
|
|
+import { StatusPill, type StatusTone } from '../components/common/StatusPill';
|
|
|
import { StatusTag } from '../components/common/StatusTag';
|
|
|
import { getDnsCurrentValues } from '../frontend/domain-model.js';
|
|
|
import { useI18n } from '../frontend/i18n/react';
|
|
|
import type { DnsRecord, RuntimeConfig, User } from '../frontend/types';
|
|
|
+import { adminUserStatusMeta } from './Admin/admin-model.js';
|
|
|
|
|
|
interface SettingsProps {
|
|
|
me: User | null;
|
|
|
@@ -36,14 +37,19 @@ export default function Settings({ me, settings, users, loading, onSave }: Setti
|
|
|
{
|
|
|
title: 'Role',
|
|
|
dataIndex: 'role',
|
|
|
- render: (value) => <StatusPill tone="neutral">{value}</StatusPill>
|
|
|
+ render: (value: string) => (
|
|
|
+ <StatusPill tone={value === 'admin' ? 'info' : 'neutral'}>
|
|
|
+ {roleLabel(value)}
|
|
|
+ </StatusPill>
|
|
|
+ )
|
|
|
},
|
|
|
{
|
|
|
title: 'Status',
|
|
|
dataIndex: 'status',
|
|
|
- render: (value) => (
|
|
|
- <StatusPill tone={value === 'active' ? 'success' : 'neutral'}>{value}</StatusPill>
|
|
|
- )
|
|
|
+ render: (value: string) => {
|
|
|
+ const meta = adminUserStatusMeta(value);
|
|
|
+ return <StatusPill tone={userStatusTone(meta.color)}>{meta.label}</StatusPill>;
|
|
|
+ }
|
|
|
}
|
|
|
];
|
|
|
const checkColumns: ColumnsType<DnsRecord> = [
|
|
|
@@ -131,3 +137,17 @@ export default function Settings({ me, settings, users, loading, onSave }: Setti
|
|
|
</Space>
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+function roleLabel(role: string) {
|
|
|
+ if (role === 'admin') return '管理员';
|
|
|
+ if (role === 'user') return '用户';
|
|
|
+ return role || '-';
|
|
|
+}
|
|
|
+
|
|
|
+function userStatusTone(color: string): StatusTone {
|
|
|
+ if (color === 'green' || color === 'success') return 'success';
|
|
|
+ if (color === 'gold' || color === 'orange' || color === 'warning') return 'warning';
|
|
|
+ if (color === 'red' || color === 'error') return 'error';
|
|
|
+ if (color === 'blue' || color === 'processing') return 'info';
|
|
|
+ return 'neutral';
|
|
|
+}
|