mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-12-05 21:00:15 +08:00
feat: 在安全设置中增加资源添加与分享策略选项
This commit is contained in:
1 parent
7b03aa5354
commit
3e600e688b
12 files changed
+492
-4
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState, type FormEvent } from "react"
|
||||
import { useEffect, useState, type FormEvent, type ReactNode } from "react"
|
||||
import { Trans, useTranslation } from "react-i18next"
|
||||
import { HugeiconsIcon } from "@hugeicons/react"
|
||||
import { Add01Icon, Delete02Icon } from "@hugeicons/core-free-icons"
|
||||
@@ -33,8 +33,10 @@ type Setting = { value: { blocked_cidrs: string[] } }
|
||||
|
||||
export function NetworkSettingsCard({
|
||||
settingKey,
|
||||
children,
|
||||
}: {
|
||||
settingKey: "mcp" | "model_network"
|
||||
children?: ReactNode
|
||||
}) {
|
||||
const labels =
|
||||
settingKey === "mcp" ? "pages.security.mcpNetwork" : "pages.security.model"
|
||||
@@ -111,6 +113,7 @@ export function NetworkSettingsCard({
|
||||
<CardTitle>{t(`${labels}.title`)}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{children}
|
||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||
<Item variant="outline">
|
||||
<ItemContent className="min-w-0">
|
||||
|
||||
@@ -2850,6 +2850,40 @@ export const ar = {
|
||||
security: {
|
||||
title: "الأمان",
|
||||
description: "إدارة إعدادات أمان النظام.",
|
||||
userCreation: {
|
||||
models: "إضافة النماذج بواسطة الأعضاء العاديين",
|
||||
knowledgeBases: "إضافة قواعد المعرفة بواسطة الأعضاء العاديين",
|
||||
skills: "إضافة المهارات بواسطة الأعضاء العاديين",
|
||||
experts: "إضافة الخبراء بواسطة الأعضاء العاديين",
|
||||
mcp: "إضافة الموصلات بواسطة الأعضاء العاديين",
|
||||
rules: "إضافة القواعد بواسطة الأعضاء العاديين",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "السماح بالإضافة",
|
||||
approval: "تتطلب الموافقة",
|
||||
deny: "منع الإضافة",
|
||||
confirmTitle: "تأكيد تغيير صلاحية الإضافة؟",
|
||||
confirmDescription: "هل تريد تغيير «{{setting}}» من «{{from}}» إلى «{{to}}»؟",
|
||||
cancel: "إلغاء",
|
||||
confirm: "تأكيد",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "السماح بالمشاركة",
|
||||
approval: "تتطلب الموافقة",
|
||||
deny: "منع المشاركة",
|
||||
confirmTitle: "تأكيد تغيير صلاحية المشاركة؟",
|
||||
confirmDescription: "هل تريد تغيير «{{setting}}» من «{{from}}» إلى «{{to}}»؟",
|
||||
cancel: "إلغاء",
|
||||
confirm: "تأكيد",
|
||||
},
|
||||
userSharing: {
|
||||
models: "مشاركة النماذج بواسطة الأعضاء العاديين",
|
||||
knowledgeBases: "مشاركة قواعد المعرفة بواسطة الأعضاء العاديين",
|
||||
skills: "مشاركة المهارات بواسطة الأعضاء العاديين",
|
||||
experts: "مشاركة الخبراء بواسطة الأعضاء العاديين",
|
||||
mcp: "مشاركة الموصلات بواسطة الأعضاء العاديين",
|
||||
rules: "مشاركة القواعد بواسطة الأعضاء العاديين",
|
||||
},
|
||||
model: {
|
||||
title: "النماذج",
|
||||
blocklist: "قائمة حظر الشبكة",
|
||||
|
||||
@@ -2912,6 +2912,40 @@ export const deDE = {
|
||||
security: {
|
||||
title: "Sicherheit",
|
||||
description: "Sicherheitseinstellungen des Systems verwalten.",
|
||||
userCreation: {
|
||||
models: "Hinzufügen von Modellen durch reguläre Mitglieder",
|
||||
knowledgeBases: "Hinzufügen von Wissensbasen durch reguläre Mitglieder",
|
||||
skills: "Hinzufügen von Skills durch reguläre Mitglieder",
|
||||
experts: "Hinzufügen von Experten durch reguläre Mitglieder",
|
||||
mcp: "Hinzufügen von Konnektoren durch reguläre Mitglieder",
|
||||
rules: "Hinzufügen von Regeln durch reguläre Mitglieder",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "Hinzufügen erlauben",
|
||||
approval: "Genehmigung erforderlich",
|
||||
deny: "Hinzufügen verbieten",
|
||||
confirmTitle: "Berechtigung zum Hinzufügen ändern?",
|
||||
confirmDescription: "„{{setting}}“ von „{{from}}“ auf „{{to}}“ ändern?",
|
||||
cancel: "Abbrechen",
|
||||
confirm: "Bestätigen",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "Teilen erlauben",
|
||||
approval: "Genehmigung erforderlich",
|
||||
deny: "Teilen verbieten",
|
||||
confirmTitle: "Berechtigung zum Teilen ändern?",
|
||||
confirmDescription: "„{{setting}}“ von „{{from}}“ auf „{{to}}“ ändern?",
|
||||
cancel: "Abbrechen",
|
||||
confirm: "Bestätigen",
|
||||
},
|
||||
userSharing: {
|
||||
models: "Teilen von Modellen durch reguläre Mitglieder",
|
||||
knowledgeBases: "Teilen von Wissensbasen durch reguläre Mitglieder",
|
||||
skills: "Teilen von Skills durch reguläre Mitglieder",
|
||||
experts: "Teilen von Experten durch reguläre Mitglieder",
|
||||
mcp: "Teilen von Konnektoren durch reguläre Mitglieder",
|
||||
rules: "Teilen von Regeln durch reguläre Mitglieder",
|
||||
},
|
||||
model: {
|
||||
title: "Modelle",
|
||||
blocklist: "Netzwerksperrliste",
|
||||
|
||||
@@ -3010,6 +3010,40 @@ export const enUS = {
|
||||
security: {
|
||||
title: "Security",
|
||||
description: "Manage system security settings.",
|
||||
userCreation: {
|
||||
models: "Model additions by regular members",
|
||||
knowledgeBases: "Knowledge base additions by regular members",
|
||||
skills: "Skill additions by regular members",
|
||||
experts: "Expert additions by regular members",
|
||||
mcp: "Connector additions by regular members",
|
||||
rules: "Rule additions by regular members",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "Allow additions",
|
||||
approval: "Require approval",
|
||||
deny: "Disallow additions",
|
||||
confirmTitle: "Change addition permissions?",
|
||||
confirmDescription: "Change “{{setting}}” from “{{from}}” to “{{to}}”?",
|
||||
cancel: "Cancel",
|
||||
confirm: "Confirm",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "Allow sharing",
|
||||
approval: "Require approval",
|
||||
deny: "Disallow sharing",
|
||||
confirmTitle: "Change sharing permissions?",
|
||||
confirmDescription: "Change “{{setting}}” from “{{from}}” to “{{to}}”?",
|
||||
cancel: "Cancel",
|
||||
confirm: "Confirm",
|
||||
},
|
||||
userSharing: {
|
||||
models: "Model sharing by regular members",
|
||||
knowledgeBases: "Knowledge base sharing by regular members",
|
||||
skills: "Skill sharing by regular members",
|
||||
experts: "Expert sharing by regular members",
|
||||
mcp: "Connector sharing by regular members",
|
||||
rules: "Rule sharing by regular members",
|
||||
},
|
||||
model: {
|
||||
title: "Models",
|
||||
blocklist: "Network blocklist",
|
||||
|
||||
@@ -2895,6 +2895,40 @@ export const es419 = {
|
||||
security: {
|
||||
title: "Seguridad",
|
||||
description: "Administra la configuración de seguridad del sistema.",
|
||||
userCreation: {
|
||||
models: "Miembros regulares: agregar modelos",
|
||||
knowledgeBases: "Miembros regulares: agregar bases de conocimiento",
|
||||
skills: "Miembros regulares: agregar habilidades",
|
||||
experts: "Miembros regulares: agregar expertos",
|
||||
mcp: "Miembros regulares: agregar conectores",
|
||||
rules: "Miembros regulares: agregar reglas",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "Permitir agregar",
|
||||
approval: "Requiere aprobación",
|
||||
deny: "Prohibir agregar",
|
||||
confirmTitle: "¿Cambiar los permisos para agregar?",
|
||||
confirmDescription: "¿Cambiar «{{setting}}» de «{{from}}» a «{{to}}»?",
|
||||
cancel: "Cancelar",
|
||||
confirm: "Confirmar",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "Permitir compartir",
|
||||
approval: "Requiere aprobación",
|
||||
deny: "Prohibir compartir",
|
||||
confirmTitle: "¿Cambiar los permisos para compartir?",
|
||||
confirmDescription: "¿Cambiar «{{setting}}» de «{{from}}» a «{{to}}»?",
|
||||
cancel: "Cancelar",
|
||||
confirm: "Confirmar",
|
||||
},
|
||||
userSharing: {
|
||||
models: "Miembros regulares: compartir modelos",
|
||||
knowledgeBases: "Miembros regulares: compartir bases de conocimiento",
|
||||
skills: "Miembros regulares: compartir habilidades",
|
||||
experts: "Miembros regulares: compartir expertos",
|
||||
mcp: "Miembros regulares: compartir conectores",
|
||||
rules: "Miembros regulares: compartir reglas",
|
||||
},
|
||||
model: {
|
||||
title: "Modelos",
|
||||
blocklist: "Lista de bloqueo de red",
|
||||
|
||||
@@ -2910,6 +2910,40 @@ export const frFR = {
|
||||
security: {
|
||||
title: "Sécurité",
|
||||
description: "Gérez les paramètres de sécurité du système.",
|
||||
userCreation: {
|
||||
models: "Ajout de modèles par les membres ordinaires",
|
||||
knowledgeBases: "Ajout de bases de connaissances par les membres ordinaires",
|
||||
skills: "Ajout de compétences par les membres ordinaires",
|
||||
experts: "Ajout d’experts par les membres ordinaires",
|
||||
mcp: "Ajout de connecteurs par les membres ordinaires",
|
||||
rules: "Ajout de règles par les membres ordinaires",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "Autoriser l’ajout",
|
||||
approval: "Approbation requise",
|
||||
deny: "Interdire l’ajout",
|
||||
confirmTitle: "Modifier les droits d’ajout ?",
|
||||
confirmDescription: "Passer « {{setting}} » de « {{from}} » à « {{to}} » ?",
|
||||
cancel: "Annuler",
|
||||
confirm: "Confirmer",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "Autoriser le partage",
|
||||
approval: "Approbation requise",
|
||||
deny: "Interdire le partage",
|
||||
confirmTitle: "Modifier les droits de partage ?",
|
||||
confirmDescription: "Passer « {{setting}} » de « {{from}} » à « {{to}} » ?",
|
||||
cancel: "Annuler",
|
||||
confirm: "Confirmer",
|
||||
},
|
||||
userSharing: {
|
||||
models: "Partage de modèles par les membres ordinaires",
|
||||
knowledgeBases: "Partage de bases de connaissances par les membres ordinaires",
|
||||
skills: "Partage de compétences par les membres ordinaires",
|
||||
experts: "Partage d’experts par les membres ordinaires",
|
||||
mcp: "Partage de connecteurs par les membres ordinaires",
|
||||
rules: "Partage de règles par les membres ordinaires",
|
||||
},
|
||||
model: {
|
||||
title: "Modèles",
|
||||
blocklist: "Liste de blocage réseau",
|
||||
|
||||
@@ -2870,6 +2870,40 @@ export const jaJP = {
|
||||
security: {
|
||||
title: "セキュリティ",
|
||||
description: "システムのセキュリティ設定を管理します。",
|
||||
userCreation: {
|
||||
models: "一般メンバーによるモデル追加",
|
||||
knowledgeBases: "一般メンバーによるナレッジベース追加",
|
||||
skills: "一般メンバーによるスキル追加",
|
||||
experts: "一般メンバーによるエキスパート追加",
|
||||
mcp: "一般メンバーによるコネクタ追加",
|
||||
rules: "一般メンバーによるルール追加",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "追加を許可",
|
||||
approval: "承認が必要",
|
||||
deny: "追加を禁止",
|
||||
confirmTitle: "追加権限を変更しますか?",
|
||||
confirmDescription: "「{{setting}}」を「{{from}}」から「{{to}}」に変更しますか?",
|
||||
cancel: "キャンセル",
|
||||
confirm: "確認",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "共有を許可",
|
||||
approval: "承認が必要",
|
||||
deny: "共有を禁止",
|
||||
confirmTitle: "共有権限を変更しますか?",
|
||||
confirmDescription: "「{{setting}}」を「{{from}}」から「{{to}}」に変更しますか?",
|
||||
cancel: "キャンセル",
|
||||
confirm: "確認",
|
||||
},
|
||||
userSharing: {
|
||||
models: "一般メンバーによるモデル共有",
|
||||
knowledgeBases: "一般メンバーによるナレッジベース共有",
|
||||
skills: "一般メンバーによるスキル共有",
|
||||
experts: "一般メンバーによるエキスパート共有",
|
||||
mcp: "一般メンバーによるコネクタ共有",
|
||||
rules: "一般メンバーによるルール共有",
|
||||
},
|
||||
model: {
|
||||
title: "モデル",
|
||||
blocklist: "ネットワークブロックリスト",
|
||||
|
||||
@@ -2853,6 +2853,40 @@ export const koKR = {
|
||||
security: {
|
||||
title: "보안",
|
||||
description: "시스템 보안 설정을 관리합니다.",
|
||||
userCreation: {
|
||||
models: "일반 멤버의 모델 추가",
|
||||
knowledgeBases: "일반 멤버의 지식 베이스 추가",
|
||||
skills: "일반 멤버의 스킬 추가",
|
||||
experts: "일반 멤버의 전문가 추가",
|
||||
mcp: "일반 멤버의 커넥터 추가",
|
||||
rules: "일반 멤버의 규칙 추가",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "추가 허용",
|
||||
approval: "승인 필요",
|
||||
deny: "추가 금지",
|
||||
confirmTitle: "추가 권한을 변경할까요?",
|
||||
confirmDescription: "‘{{setting}}’ 설정을 ‘{{from}}’에서 ‘{{to}}’로 변경할까요?",
|
||||
cancel: "취소",
|
||||
confirm: "확인",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "공유 허용",
|
||||
approval: "승인 필요",
|
||||
deny: "공유 금지",
|
||||
confirmTitle: "공유 권한을 변경할까요?",
|
||||
confirmDescription: "‘{{setting}}’ 설정을 ‘{{from}}’에서 ‘{{to}}’로 변경할까요?",
|
||||
cancel: "취소",
|
||||
confirm: "확인",
|
||||
},
|
||||
userSharing: {
|
||||
models: "일반 멤버의 모델 공유",
|
||||
knowledgeBases: "일반 멤버의 지식 베이스 공유",
|
||||
skills: "일반 멤버의 스킬 공유",
|
||||
experts: "일반 멤버의 전문가 공유",
|
||||
mcp: "일반 멤버의 커넥터 공유",
|
||||
rules: "일반 멤버의 규칙 공유",
|
||||
},
|
||||
model: {
|
||||
title: "모델",
|
||||
blocklist: "네트워크 차단 목록",
|
||||
|
||||
@@ -2898,6 +2898,40 @@ export const ruRU = {
|
||||
security: {
|
||||
title: "Безопасность",
|
||||
description: "Управление настройками безопасности системы.",
|
||||
userCreation: {
|
||||
models: "Добавление моделей обычными участниками",
|
||||
knowledgeBases: "Добавление баз знаний обычными участниками",
|
||||
skills: "Добавление навыков обычными участниками",
|
||||
experts: "Добавление экспертов обычными участниками",
|
||||
mcp: "Добавление коннекторов обычными участниками",
|
||||
rules: "Добавление правил обычными участниками",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "Разрешить добавление",
|
||||
approval: "Требуется одобрение",
|
||||
deny: "Запретить добавление",
|
||||
confirmTitle: "Изменить права на добавление?",
|
||||
confirmDescription: "Изменить «{{setting}}» с «{{from}}» на «{{to}}»?",
|
||||
cancel: "Отмена",
|
||||
confirm: "Подтвердить",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "Разрешить делиться",
|
||||
approval: "Требуется одобрение",
|
||||
deny: "Запретить делиться",
|
||||
confirmTitle: "Изменить права на обмен?",
|
||||
confirmDescription: "Изменить «{{setting}}» с «{{from}}» на «{{to}}»?",
|
||||
cancel: "Отмена",
|
||||
confirm: "Подтвердить",
|
||||
},
|
||||
userSharing: {
|
||||
models: "Обмен моделями обычными участниками",
|
||||
knowledgeBases: "Обмен базами знаний обычными участниками",
|
||||
skills: "Обмен навыками обычными участниками",
|
||||
experts: "Обмен экспертами обычными участниками",
|
||||
mcp: "Обмен коннекторами обычными участниками",
|
||||
rules: "Обмен правилами обычными участниками",
|
||||
},
|
||||
model: {
|
||||
title: "Модели",
|
||||
blocklist: "Список блокировки сети",
|
||||
|
||||
@@ -2869,6 +2869,40 @@ export const zhCN = {
|
||||
security: {
|
||||
title: "安全",
|
||||
description: "管理系统安全设置。",
|
||||
userCreation: {
|
||||
models: "普通成员添加大模型",
|
||||
knowledgeBases: "普通成员添加知识库",
|
||||
skills: "普通成员添加技能",
|
||||
experts: "普通成员添加专家",
|
||||
mcp: "普通成员添加连接器",
|
||||
rules: "普通成员添加规则",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "允许添加",
|
||||
approval: "需要审核",
|
||||
deny: "禁止添加",
|
||||
confirmTitle: "确认修改添加权限?",
|
||||
confirmDescription: "确定将“{{setting}}”从“{{from}}”改为“{{to}}”吗?",
|
||||
cancel: "取消",
|
||||
confirm: "确认",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "允许分享",
|
||||
approval: "需要审核",
|
||||
deny: "禁止分享",
|
||||
confirmTitle: "确认修改分享权限?",
|
||||
confirmDescription: "确定将“{{setting}}”从“{{from}}”改为“{{to}}”吗?",
|
||||
cancel: "取消",
|
||||
confirm: "确认",
|
||||
},
|
||||
userSharing: {
|
||||
models: "普通成员分享大模型",
|
||||
knowledgeBases: "普通成员分享知识库",
|
||||
skills: "普通成员分享技能",
|
||||
experts: "普通成员分享专家",
|
||||
mcp: "普通成员分享连接器",
|
||||
rules: "普通成员分享规则",
|
||||
},
|
||||
model: {
|
||||
title: "大模型",
|
||||
blocklist: "网络黑名单",
|
||||
|
||||
@@ -2809,6 +2809,40 @@ export const zhTW = {
|
||||
security: {
|
||||
title: "安全",
|
||||
description: "管理系統安全設定。",
|
||||
userCreation: {
|
||||
models: "一般成員新增大模型",
|
||||
knowledgeBases: "一般成員新增知識庫",
|
||||
skills: "一般成員新增技能",
|
||||
experts: "一般成員新增專家",
|
||||
mcp: "一般成員新增連接器",
|
||||
rules: "一般成員新增規則",
|
||||
},
|
||||
additionPolicy: {
|
||||
allow: "允許新增",
|
||||
approval: "需要審核",
|
||||
deny: "禁止新增",
|
||||
confirmTitle: "確認修改新增權限?",
|
||||
confirmDescription: "確定將「{{setting}}」從「{{from}}」改為「{{to}}」嗎?",
|
||||
cancel: "取消",
|
||||
confirm: "確認",
|
||||
},
|
||||
sharingPolicy: {
|
||||
allow: "允許分享",
|
||||
approval: "需要審核",
|
||||
deny: "禁止分享",
|
||||
confirmTitle: "確認修改分享權限?",
|
||||
confirmDescription: "確定將「{{setting}}」從「{{from}}」改為「{{to}}」嗎?",
|
||||
cancel: "取消",
|
||||
confirm: "確認",
|
||||
},
|
||||
userSharing: {
|
||||
models: "一般成員分享大模型",
|
||||
knowledgeBases: "一般成員分享知識庫",
|
||||
skills: "一般成員分享技能",
|
||||
experts: "一般成員分享專家",
|
||||
mcp: "一般成員分享連接器",
|
||||
rules: "一般成員分享規則",
|
||||
},
|
||||
model: {
|
||||
title: "模型",
|
||||
blocklist: "網路黑名單",
|
||||
|
||||
@@ -1,17 +1,162 @@
|
||||
import { useRef, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Navigate } from "react-router-dom"
|
||||
|
||||
import { NetworkSettingsCard } from "@/components/network-settings-card"
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog"
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Item, ItemActions, ItemContent, ItemTitle } from "@/components/ui/item"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select"
|
||||
import { useAuth } from "@/hooks/use-auth"
|
||||
import { DEFAULT_CONSOLE_PATH } from "@/lib/routes"
|
||||
|
||||
type MemberPolicy = "allow" | "approval" | "deny"
|
||||
type MemberResource =
|
||||
"models" | "knowledgeBases" | "skills" | "experts" | "mcp" | "rules"
|
||||
|
||||
// 仅用于界面预览;选项状态不持久化,也不影响实际权限。
|
||||
function MemberPolicyOption({
|
||||
resource,
|
||||
action,
|
||||
}: {
|
||||
resource: MemberResource
|
||||
action: "addition" | "sharing"
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const [policy, setPolicy] = useState<MemberPolicy>("allow")
|
||||
const [pendingPolicy, setPendingPolicy] = useState<MemberPolicy | null>(null)
|
||||
const triggerRef = useRef<HTMLButtonElement>(null)
|
||||
const label = t(
|
||||
`pages.security.${action === "addition" ? "userCreation" : "userSharing"}.${resource}`
|
||||
)
|
||||
const policyLabels =
|
||||
action === "addition"
|
||||
? "pages.security.additionPolicy"
|
||||
: "pages.security.sharingPolicy"
|
||||
const items = (["allow", "approval", "deny"] as const).map((value) => ({
|
||||
value,
|
||||
label: t(`${policyLabels}.${value}`),
|
||||
}))
|
||||
|
||||
return (
|
||||
<AlertDialog
|
||||
open={pendingPolicy !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setPendingPolicy(null)
|
||||
}}
|
||||
>
|
||||
<Item variant="outline">
|
||||
<ItemContent className="min-w-0 basis-40">
|
||||
<ItemTitle className="line-clamp-none break-words">{label}</ItemTitle>
|
||||
</ItemContent>
|
||||
<ItemActions className="ms-auto max-w-full">
|
||||
<Select<MemberPolicy>
|
||||
items={items}
|
||||
value={policy}
|
||||
onValueChange={(value) => {
|
||||
if (value !== null && value !== policy) setPendingPolicy(value)
|
||||
}}
|
||||
>
|
||||
<SelectTrigger
|
||||
ref={triggerRef}
|
||||
className="min-w-28"
|
||||
aria-label={label}
|
||||
>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent
|
||||
align="end"
|
||||
alignItemWithTrigger={false}
|
||||
className="w-max min-w-[var(--anchor-width)]"
|
||||
>
|
||||
<SelectGroup>
|
||||
{items.map((item) => (
|
||||
<SelectItem key={item.value} value={item.value}>
|
||||
{item.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</ItemActions>
|
||||
</Item>
|
||||
<AlertDialogContent finalFocus={triggerRef}>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
{t(`${policyLabels}.confirmTitle`)}
|
||||
</AlertDialogTitle>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogDescription>
|
||||
{t(`${policyLabels}.confirmDescription`, {
|
||||
setting: label,
|
||||
from: t(`${policyLabels}.${policy}`),
|
||||
to: t(`${policyLabels}.${pendingPolicy ?? policy}`),
|
||||
})}
|
||||
</AlertDialogDescription>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t(`${policyLabels}.cancel`)}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={() => {
|
||||
if (pendingPolicy === null) return
|
||||
setPolicy(pendingPolicy)
|
||||
setPendingPolicy(null)
|
||||
}}
|
||||
>
|
||||
{t(`${policyLabels}.confirm`)}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
)
|
||||
}
|
||||
|
||||
export function SecurityPage() {
|
||||
const { t } = useTranslation()
|
||||
const { user } = useAuth()
|
||||
if (user?.role !== "admin") return <Navigate to={DEFAULT_CONSOLE_PATH} replace />
|
||||
if (user?.role !== "admin")
|
||||
return <Navigate to={DEFAULT_CONSOLE_PATH} replace />
|
||||
|
||||
return (
|
||||
<section className="flex flex-1 flex-col gap-4 p-4 pt-0">
|
||||
<NetworkSettingsCard settingKey="model_network" />
|
||||
<NetworkSettingsCard settingKey="mcp" />
|
||||
<NetworkSettingsCard settingKey="model_network">
|
||||
<MemberPolicyOption resource="models" action="addition" />
|
||||
<MemberPolicyOption resource="models" action="sharing" />
|
||||
</NetworkSettingsCard>
|
||||
{(["knowledgeBases", "skills", "experts", "mcp", "rules"] as const).map(
|
||||
(resource) =>
|
||||
resource === "mcp" ? (
|
||||
<NetworkSettingsCard key={resource} settingKey="mcp">
|
||||
<MemberPolicyOption resource="mcp" action="addition" />
|
||||
<MemberPolicyOption resource="mcp" action="sharing" />
|
||||
</NetworkSettingsCard>
|
||||
) : (
|
||||
<Card key={resource}>
|
||||
<CardHeader>
|
||||
<CardTitle>{t(`pages.${resource}.title`)}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<MemberPolicyOption resource={resource} action="addition" />
|
||||
<MemberPolicyOption resource={resource} action="sharing" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user