/** * @file ArtifactsHubSettings — Settings → AI tools → Artifacts Hub: the * admin's server-wide switch that allows or blocks installing a shared skill * or plugin from the Hub into a user's own account (`GET/PUT * /api/artifacts/settings`). Renders nothing in local mode (there is no Hub) * or for anyone the server does not let manage it (`canManage`). * @author Nguyễn Ngọc Trí Vĩ */ import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { api, type ArtifactSettings } from "../../lib/api"; import { toast } from "../../lib/toast"; import { SettingsSection, SettingsSwitchRow } from "./SettingsRow"; export function ArtifactsHubSettings() { const { t } = useTranslation("artifacts"); const [settings, setSettings] = useState(null); useEffect(() => { api.artifacts .settings() .then(setSettings) .catch(() => setSettings(null)); }, []); if (!settings?.serverMode || !settings.canManage) return null; return ( { try { const r = await api.artifacts.setInstallsEnabled(v); setSettings({ ...settings, installsEnabled: r.installsEnabled }); } catch (err) { toast.error(err); } }} /> ); }