Update Local Permission Assignments
This commit is contained in:
@@ -29,6 +29,7 @@ const userFormSchema = z.object({
|
||||
password: z.string().optional(),
|
||||
is_active: z.boolean(),
|
||||
is_superuser: z.boolean(),
|
||||
can_use_local_model: z.boolean(),
|
||||
})
|
||||
|
||||
type UserFormValues = z.infer<typeof userFormSchema>
|
||||
@@ -58,6 +59,7 @@ export function UserDialog({
|
||||
password: '',
|
||||
is_active: true,
|
||||
is_superuser: false,
|
||||
can_use_local_model: false,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -69,6 +71,7 @@ export function UserDialog({
|
||||
password: '',
|
||||
is_active: user.is_active,
|
||||
is_superuser: user.is_superuser,
|
||||
can_use_local_model: user.can_use_local_model,
|
||||
})
|
||||
} else {
|
||||
form.reset({
|
||||
@@ -77,6 +80,7 @@ export function UserDialog({
|
||||
password: '',
|
||||
is_active: true,
|
||||
is_superuser: false,
|
||||
can_use_local_model: false,
|
||||
})
|
||||
}
|
||||
}, [user, form])
|
||||
@@ -178,6 +182,27 @@ export function UserDialog({
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="can_use_local_model"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex flex-row items-start space-x-3 space-y-0">
|
||||
<FormControl>
|
||||
<Checkbox
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
<div className="space-y-1 leading-none">
|
||||
<FormLabel>本地模型权限</FormLabel>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
允许用户使用本地 TTS 模型
|
||||
</p>
|
||||
</div>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<DialogFooter className="flex-col sm:flex-row gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
|
||||
@@ -38,6 +38,7 @@ export function UserTable({ users, isLoading, onEdit, onDelete }: UserTableProps
|
||||
<th className="px-4 py-3 font-medium">邮箱</th>
|
||||
<th className="px-4 py-3 font-medium">状态</th>
|
||||
<th className="px-4 py-3 font-medium">角色</th>
|
||||
<th className="px-4 py-3 font-medium">权限</th>
|
||||
<th className="px-4 py-3 font-medium">创建时间</th>
|
||||
<th className="px-4 py-3 font-medium text-right">操作</th>
|
||||
</tr>
|
||||
@@ -58,6 +59,11 @@ export function UserTable({ users, isLoading, onEdit, onDelete }: UserTableProps
|
||||
{user.is_superuser ? '超级管理员' : '普通用户'}
|
||||
</Badge>
|
||||
</td>
|
||||
<td className="px-4 py-3">
|
||||
{(user.is_superuser || user.can_use_local_model) && (
|
||||
<Badge variant="secondary">本地模型</Badge>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-4 py-3">
|
||||
{new Date(user.created_at).toLocaleString('zh-CN')}
|
||||
</td>
|
||||
@@ -129,6 +135,14 @@ export function UserTable({ users, isLoading, onEdit, onDelete }: UserTableProps
|
||||
{user.is_superuser ? '超级管理员' : '普通用户'}
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="flex justify-between items-center">
|
||||
<span className="text-muted-foreground">权限:</span>
|
||||
{(user.is_superuser || user.can_use_local_model) ? (
|
||||
<Badge variant="secondary">本地模型</Badge>
|
||||
) : (
|
||||
<span className="text-xs text-muted-foreground">无</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-muted-foreground">创建时间:</span>
|
||||
<span className="text-xs">{new Date(user.created_at).toLocaleString('zh-CN')}</span>
|
||||
|
||||
Reference in New Issue
Block a user