/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import { Trans } from 'react-i18next'; import React, { useEffect, useMemo, useState } from 'react'; import { Button, Card, Empty, Tag, Typography } from 'antd'; import { Cable, LockKeyhole } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { API } from '../../helpers/api'; import { usePageGuide, PageGuideDrawer, PageGuideTrigger, } from '../../components/common/PageGuide'; import OrgPageHeader from './components/OrgPageHeader'; import './org-my-capabilities.css'; const confirmationLabels = { never: '无需确认', write: '写操作前确认', always: '每次调用都确认', }; const OrgMyConnectors = ({ orgId }) => { const { t } = useTranslation(); const headers = useMemo(() => ({ 'X-Org-Id': String(orgId) }), [orgId]); const [items, setItems] = useState([]); const [loadError, setLoadError] = useState(''); useEffect(() => { let active = true; API.get('/api/org/connectors/mine', { headers, skipErrorHandler: true }) .then((response) => { if (!active) return; if (response.data?.success) { setItems(response.data.data || []); setLoadError(''); } else { // A failed load must not masquerade as "no authorizations". setLoadError(response.data?.message || t('授权列表加载失败')); } }) .catch((error) => { if (active) setLoadError( error?.response?.data?.message || error?.message || t('授权列表加载失败'), ); }); return () => { active = false; }; }, [headers, t]); // 使用指引:成员视角的阅读式说明(无上手流程,不出进度胶囊)。 const guide = usePageGuide({ guideKey: 'org-my-connectors', title: t('我的业务系统授权 · 使用指引'), intro: t('这里列出专家在任务中可以代表你调用的业务系统与边界'), steps: [ { title: t('看懂授权卡片'), detail: t('一张卡片对应一个已授权的业务系统连接器'), points: [ t('右上角标签是访问级别:read 只读,write 可执行写操作'), t('卡片中的标签列出专家可调用的具体方法'), ], }, { title: t('理解确认策略'), detail: t('确认策略决定哪些调用执行前需要你亲自确认'), points: [ t('never 无需确认;write 写操作前确认;always 每次调用都确认'), ], }, { title: t('任务中的确认操作'), detail: t('确认动作发生在云端大脑的任务详情页'), points: [ t('专家发起调用时任务会停在「等待操作确认」'), t('展开「查看冻结参数」核对操作内容,填写原因后确认或拒绝'), t('长时间不处理会确认超时,任务按已发生用量结算'), ], }, { title: t('需要调整授权'), detail: t('授权由企业管理员统一发布与撤销'), points: [t('缺少某个系统的授权或范围不足时,请联系企业管理员')], }, ], faq: [ { q: t('列表是空的?'), a: t('管理员发布授权并覆盖到你之后才会显示,请联系企业管理员'), }, { q: t('「企业服务账号由管理员管理」是什么意思?'), a: t('该连接器以企业级凭据运行,个人无法自行撤销'), }, ], }); return (
} /> {loadError ? ( {t('授权列表加载失败')} {loadError} } /> ) : items.length === 0 ? ( {t('当前没有 Connector 授权')} {t('管理员发布授权并覆盖到你后会显示在这里。')} } /> ) : (
{items.map((item) => (
{item.connector_name} {item.definition_name}
{item.grant.access_level}
{item.methods.map((method) => ( {method} ))}
))}
)}
); }; export default OrgMyConnectors;