2aa9d73325
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
753 lines
24 KiB
React
753 lines
24 KiB
React
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||
import {
|
||
RefreshCw as ActionRefreshCw,
|
||
Plus as ActionPlus,
|
||
KeyRound as ActionKeyRound,
|
||
ShieldCheck as ActionShieldCheck,
|
||
} from '@/components/common/icons/ActionIcons';
|
||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||
import {
|
||
Button,
|
||
Input,
|
||
InputNumber,
|
||
Modal,
|
||
Select,
|
||
SideSheet,
|
||
Switch,
|
||
TabPane,
|
||
Tabs,
|
||
Tag,
|
||
TextArea,
|
||
Toast,
|
||
} from '@/components/ui';
|
||
import { Cable } from 'lucide-react';
|
||
import { useTranslation } from 'react-i18next';
|
||
import { API } from '../../helpers/api';
|
||
import {
|
||
usePageGuide,
|
||
PageGuideDrawer,
|
||
PageGuidePill,
|
||
PageGuideTrigger,
|
||
} from '../../components/common/PageGuide';
|
||
import './org-connectors.css';
|
||
import OrgBreadcrumb from './components/OrgBreadcrumb';
|
||
|
||
const headersFor = (orgId) => ({ 'X-Org-Id': String(orgId) });
|
||
const blankConnector = {
|
||
definition_id: undefined,
|
||
instance_key: '',
|
||
display_name: '',
|
||
base_url: '',
|
||
config: '{}',
|
||
allowed_hosts: '',
|
||
allowed_cidrs: '',
|
||
egress_policy: 'public_https',
|
||
};
|
||
|
||
const parseLines = (value) =>
|
||
value
|
||
.split(/[,\n]/)
|
||
.map((item) => item.trim())
|
||
.filter(Boolean);
|
||
|
||
const OrgConnectors = ({ orgId }) => {
|
||
const { t } = useTranslation();
|
||
const headers = useMemo(() => headersFor(orgId), [orgId]);
|
||
const [definitions, setDefinitions] = useState([]);
|
||
const [connectors, setConnectors] = useState([]);
|
||
const [grants, setGrants] = useState([]);
|
||
const [audit, setAudit] = useState([]);
|
||
const [loading, setLoading] = useState(true);
|
||
const [editorOpen, setEditorOpen] = useState(false);
|
||
const [credentialOpen, setCredentialOpen] = useState(false);
|
||
const [grantOpen, setGrantOpen] = useState(false);
|
||
const [saving, setSaving] = useState(false);
|
||
const [form, setForm] = useState(blankConnector);
|
||
const [selected, setSelected] = useState(null);
|
||
const [credential, setCredential] = useState(
|
||
'{\n "headers": {\n "Authorization": "Bearer ..."\n }\n}',
|
||
);
|
||
const [grant, setGrant] = useState({
|
||
grant_key: '',
|
||
connector_id: undefined,
|
||
expert_id: undefined,
|
||
scope_type: 'organization',
|
||
scope_id: 0,
|
||
method_keys: [],
|
||
access_level: 'read',
|
||
confirmation_policy: 'write',
|
||
external_allowed: false,
|
||
max_calls_per_run: 5,
|
||
max_result_bytes: 65536,
|
||
});
|
||
|
||
const load = useCallback(async () => {
|
||
setLoading(true);
|
||
try {
|
||
const [
|
||
definitionResponse,
|
||
connectorResponse,
|
||
grantResponse,
|
||
auditResponse,
|
||
] = await Promise.all([
|
||
API.get('/api/org/connectors/definitions', { headers }),
|
||
API.get('/api/org/connectors', { headers }),
|
||
API.get('/api/org/connectors/grants', { headers }),
|
||
API.get('/api/org/connectors/audit', { headers }),
|
||
]);
|
||
setDefinitions(definitionResponse.data?.data || []);
|
||
setConnectors(connectorResponse.data?.data || []);
|
||
setGrants(grantResponse.data?.data || []);
|
||
setAudit(auditResponse.data?.data || []);
|
||
} catch (error) {
|
||
Toast.error(error?.response?.data?.message || error.message);
|
||
} finally {
|
||
setLoading(false);
|
||
}
|
||
}, [headers]);
|
||
|
||
useEffect(() => {
|
||
void load();
|
||
}, [load]);
|
||
|
||
const definitionsById = useMemo(
|
||
() => new Map(definitions.map((item) => [item.definition.id, item])),
|
||
[definitions],
|
||
);
|
||
const connectorRows = useMemo(
|
||
() => connectors.map((item) => item.connector || item),
|
||
[connectors],
|
||
);
|
||
const connectorViewById = useMemo(
|
||
() =>
|
||
new Map(connectors.map((item) => [(item.connector || item).id, item])),
|
||
[connectors],
|
||
);
|
||
const selectedGrantConnector = connectorRows.find(
|
||
(item) => item.id === grant.connector_id,
|
||
);
|
||
const grantDefinition = selectedGrantConnector
|
||
? definitionsById.get(selectedGrantConnector.definition_id)
|
||
: null;
|
||
// Method options must come from the instance's PINNED definition version
|
||
// (the backend validates against it); the definition catalog only carries
|
||
// the latest version, whose new methods would be rejected on save.
|
||
const grantConnectorView = grant.connector_id
|
||
? connectorViewById.get(grant.connector_id)
|
||
: null;
|
||
const grantMethodOptions =
|
||
grantConnectorView?.methods || grantDefinition?.methods || [];
|
||
const grantConnectorType =
|
||
grantDefinition?.version?.connector_type ||
|
||
grantDefinition?.definition?.connector_type ||
|
||
'';
|
||
|
||
const openCreate = () => {
|
||
setSelected(null);
|
||
setForm(blankConnector);
|
||
setEditorOpen(true);
|
||
};
|
||
|
||
const openEdit = (row) => {
|
||
setSelected(row);
|
||
setForm({
|
||
id: row.id,
|
||
definition_id: row.definition_id,
|
||
definition_version_id: row.definition_version_id,
|
||
instance_key: row.instance_key,
|
||
display_name: row.display_name,
|
||
base_url: row.base_url || '',
|
||
config: row.config || row.ConfigJSON || row.config_json || '{}',
|
||
allowed_hosts: (() => {
|
||
try {
|
||
return JSON.parse(
|
||
row.allowed_hosts || row.allowed_hosts_json || '[]',
|
||
).join('\n');
|
||
} catch {
|
||
return '';
|
||
}
|
||
})(),
|
||
allowed_cidrs: (() => {
|
||
try {
|
||
return JSON.parse(
|
||
row.allowed_cidrs || row.allowed_cidrs_json || '[]',
|
||
).join('\n');
|
||
} catch {
|
||
return '';
|
||
}
|
||
})(),
|
||
egress_policy: row.egress_policy || 'public_https',
|
||
});
|
||
setEditorOpen(true);
|
||
};
|
||
|
||
const saveConnector = async () => {
|
||
let config;
|
||
try {
|
||
config = JSON.parse(form.config || '{}');
|
||
} catch {
|
||
Toast.warning(t('配置必须是有效 JSON'));
|
||
return;
|
||
}
|
||
setSaving(true);
|
||
try {
|
||
const payload = {
|
||
...form,
|
||
config,
|
||
allowed_hosts: parseLines(form.allowed_hosts),
|
||
allowed_cidrs: parseLines(form.allowed_cidrs),
|
||
};
|
||
const url = form.id
|
||
? `/api/org/connectors/${form.id}`
|
||
: '/api/org/connectors';
|
||
const response = form.id
|
||
? await API.put(url, payload, { headers })
|
||
: await API.post(url, payload, { headers });
|
||
if (!response.data?.success) throw new Error(response.data?.message);
|
||
setEditorOpen(false);
|
||
Toast.success(t('Connector 配置已保存'));
|
||
await load();
|
||
} catch (error) {
|
||
Toast.error(error?.response?.data?.message || error.message);
|
||
} finally {
|
||
setSaving(false);
|
||
}
|
||
};
|
||
|
||
const saveCredential = async () => {
|
||
let parsed;
|
||
try {
|
||
parsed = JSON.parse(credential);
|
||
} catch {
|
||
Toast.warning(t('凭据必须是有效 JSON'));
|
||
return;
|
||
}
|
||
setSaving(true);
|
||
try {
|
||
await API.put(
|
||
`/api/org/connectors/${selected.id}/credential`,
|
||
{ credential: parsed },
|
||
{ headers },
|
||
);
|
||
setCredentialOpen(false);
|
||
Toast.success(t('凭据已加密轮换,旧凭据已停用'));
|
||
await load();
|
||
} catch (error) {
|
||
Toast.error(error?.response?.data?.message || error.message);
|
||
} finally {
|
||
setSaving(false);
|
||
}
|
||
};
|
||
|
||
const saveGrant = async () => {
|
||
setSaving(true);
|
||
try {
|
||
await API.post('/api/org/connectors/grants', grant, { headers });
|
||
setGrantOpen(false);
|
||
Toast.success(t('授权版本已发布'));
|
||
await load();
|
||
} catch (error) {
|
||
Toast.error(error?.response?.data?.message || error.message);
|
||
} finally {
|
||
setSaving(false);
|
||
}
|
||
};
|
||
|
||
const revoke = (row) => {
|
||
Modal.confirm({
|
||
title: t('撤销 Connector'),
|
||
content: t('撤销后,排队和等待确认的调用都会在执行前重新校验并被阻断。'),
|
||
onOk: async () => {
|
||
await API.post(
|
||
`/api/org/connectors/${row.id}/revoke`,
|
||
{ reason: 'Revoked from organization connector console' },
|
||
{ headers },
|
||
);
|
||
await load();
|
||
},
|
||
});
|
||
};
|
||
|
||
// 使用指引:连接器从接入到可被专家调用的四步,完成态由真实数据驱动。
|
||
const guide = usePageGuide({
|
||
guideKey: 'org-connectors',
|
||
ready: !loading,
|
||
title: t('业务系统连接器 · 使用指引'),
|
||
intro: t(
|
||
'配置实例 → 加密凭据 → 发布授权 → 审计治理,让专家安全地调用业务系统',
|
||
),
|
||
steps: [
|
||
{
|
||
title: t('配置 Connector 实例'),
|
||
detail: t('选择连接器类型,设置地址与网络边界'),
|
||
done: connectorRows.length > 0,
|
||
cta: t('去配置实例'),
|
||
onAction: openCreate,
|
||
points: [
|
||
t('填写实例键、显示名与 Base URL;主机白名单精确到域名'),
|
||
t('出网策略二选一:公网 HTTPS,或已审批的内网 CIDR 段'),
|
||
t('能力边界用 JSON 描述,保存前会做合法性校验'),
|
||
],
|
||
},
|
||
{
|
||
title: t('轮换加密凭据'),
|
||
detail: t('凭据只进不出,界面永远只显示哈希后缀'),
|
||
done: connectors.some((item) => Boolean(item.credential)),
|
||
points: [
|
||
t('在实例卡片点「轮换凭据」,粘贴 JSON 形式的认证头'),
|
||
t('轮换后旧凭据立即停用;服务端不会回显明文'),
|
||
],
|
||
},
|
||
{
|
||
title: t('发布授权版本'),
|
||
detail: t('按「专家 × 范围」发布不可变授权,专家才可调用'),
|
||
done: grants.length > 0,
|
||
points: [
|
||
t('在「授权矩阵」页点「发布授权」,选择连接器、专家与范围'),
|
||
t(
|
||
'访问级别 read/write 与确认策略 never/write/always 决定哪些调用需成员确认',
|
||
),
|
||
t('每次任务的调用次数与返回字节都有上限,防止失控'),
|
||
],
|
||
},
|
||
{
|
||
title: t('审计与治理'),
|
||
detail: t('每次调用都有审计记录,出问题可随时撤销'),
|
||
done: grants.length > 0,
|
||
points: [
|
||
t('「审计」页记录每次调用的动作、状态与摘要'),
|
||
t('「撤销」实例后,排队和等待确认的调用都会在执行前被阻断'),
|
||
],
|
||
},
|
||
],
|
||
faq: [
|
||
{
|
||
q: t('成员没有确认操作的入口?'),
|
||
a: t(
|
||
'确认发生在云端大脑的任务详情里;成员可在「我的业务系统授权」查看自己的授权范围',
|
||
),
|
||
},
|
||
{
|
||
q: t('HTTP 类型连接器发布授权被拦?'),
|
||
a: t('需要先开启「允许向已审批外部系统发送必要参数」开关'),
|
||
},
|
||
],
|
||
});
|
||
const closeGuide = guide.close;
|
||
// 抽屉进度是组织私有的:切组织时关闭,避免带着旧组织的完成态短暂展示。
|
||
useEffect(() => {
|
||
closeGuide();
|
||
}, [orgId, closeGuide]);
|
||
return (
|
||
<main className='org-connector-page'>
|
||
<header className='org-connector-hero'>
|
||
<div>
|
||
<OrgBreadcrumb />
|
||
<h1>{t('业务系统连接器')}</h1>
|
||
<p>{t('凭据、授权范围、写操作确认和调用审计在同一控制面闭环。')}</p>
|
||
</div>
|
||
<div className='org-connector-actions'>
|
||
<PageGuideTrigger guide={guide} />
|
||
<Button
|
||
icon={<ActionRefreshCw size={16} />}
|
||
loading={loading}
|
||
onClick={load}
|
||
>
|
||
{t('刷新')}
|
||
</Button>
|
||
<Button
|
||
theme='solid'
|
||
icon={<ActionPlus size={16} />}
|
||
onClick={openCreate}
|
||
>
|
||
{t('配置 Connector')}
|
||
</Button>
|
||
</div>
|
||
</header>
|
||
|
||
<PageGuidePill guide={guide} />
|
||
<PageGuideDrawer guide={guide} />
|
||
|
||
<Tabs type='line'>
|
||
<TabPane
|
||
tab={`${t('实例')} · ${connectorRows.length}`}
|
||
itemKey='instances'
|
||
>
|
||
<section className='org-connector-grid'>
|
||
{connectorRows.map((row) => {
|
||
const definition = definitionsById.get(row.definition_id);
|
||
const credentialState = connectorViewById.get(row.id)?.credential;
|
||
return (
|
||
<article key={row.id} className='org-connector-card'>
|
||
<div className='org-connector-card-top'>
|
||
<span className='org-connector-icon'>
|
||
<Cable size={20} />
|
||
</span>
|
||
<Tag color={row.status === 'active' ? 'green' : 'red'}>
|
||
{row.status}
|
||
</Tag>
|
||
</div>
|
||
<h3>{row.display_name}</h3>
|
||
<p>
|
||
{definition?.version?.description_zh ||
|
||
definition?.version?.description_en}
|
||
</p>
|
||
<dl>
|
||
<div>
|
||
<dt>{t('实例键')}</dt>
|
||
<dd>{row.instance_key}</dd>
|
||
</div>
|
||
<div>
|
||
<dt>{t('网络策略')}</dt>
|
||
<dd>{row.egress_policy}</dd>
|
||
</div>
|
||
<div>
|
||
<dt>{t('凭据')}</dt>
|
||
<dd>
|
||
{credentialState
|
||
? `•••• ${credentialState.masked_suffix}`
|
||
: t('未配置')}
|
||
</dd>
|
||
</div>
|
||
</dl>
|
||
<div className='org-connector-card-actions'>
|
||
<Button size='small' onClick={() => openEdit(row)}>
|
||
{t('配置')}
|
||
</Button>
|
||
<Button
|
||
size='small'
|
||
icon={<ActionKeyRound size={14} />}
|
||
onClick={() => {
|
||
setSelected(row);
|
||
setCredentialOpen(true);
|
||
}}
|
||
>
|
||
{t('轮换凭据')}
|
||
</Button>
|
||
{row.status === 'active' && (
|
||
<Button
|
||
size='small'
|
||
type='danger'
|
||
onClick={() => revoke(row)}
|
||
>
|
||
{t('撤销')}
|
||
</Button>
|
||
)}
|
||
</div>
|
||
</article>
|
||
);
|
||
})}
|
||
</section>
|
||
</TabPane>
|
||
|
||
<TabPane tab={`${t('授权矩阵')} · ${grants.length}`} itemKey='grants'>
|
||
<div className='org-connector-section-head'>
|
||
<p>
|
||
{t('授权按专家与组织、部门、项目或成员范围发布为不可变版本。')}
|
||
</p>
|
||
<Button
|
||
theme='solid'
|
||
icon={<ActionShieldCheck size={16} />}
|
||
onClick={() => {
|
||
setGrant((current) => ({
|
||
...current,
|
||
connector_id: connectorRows[0]?.id,
|
||
}));
|
||
setGrantOpen(true);
|
||
}}
|
||
>
|
||
{t('发布授权')}
|
||
</Button>
|
||
</div>
|
||
<section className='org-connector-list'>
|
||
{grants.map((item) => (
|
||
<article key={item.id}>
|
||
<div>
|
||
<strong>
|
||
{item.scope_type} #{item.scope_id || 0}
|
||
</strong>
|
||
<Tag>v{item.version}</Tag>
|
||
</div>
|
||
<code>{item.method_keys}</code>
|
||
<span>
|
||
{item.access_level} · {item.confirmation_policy} ·{' '}
|
||
{item.max_calls_per_run}/run
|
||
</span>
|
||
</article>
|
||
))}
|
||
</section>
|
||
</TabPane>
|
||
|
||
<TabPane tab={`${t('审计')} · ${audit.length}`} itemKey='audit'>
|
||
<section className='org-connector-list org-connector-audit'>
|
||
{audit.map((item) => (
|
||
<article key={item.id}>
|
||
<div>
|
||
<strong>{item.action}</strong>
|
||
<Tag color={item.status === 'succeeded' ? 'green' : 'orange'}>
|
||
{item.status}
|
||
</Tag>
|
||
</div>
|
||
<code>{item.method_key || item.tool_call_id || '-'}</code>
|
||
<span>{item.summary}</span>
|
||
</article>
|
||
))}
|
||
</section>
|
||
</TabPane>
|
||
</Tabs>
|
||
|
||
<SideSheet
|
||
title={form.id ? t('编辑 Connector') : t('配置 Connector')}
|
||
visible={editorOpen}
|
||
onCancel={() => setEditorOpen(false)}
|
||
width={520}
|
||
footer={
|
||
<Button theme='solid' loading={saving} onClick={saveConnector}>
|
||
{t('保存配置')}
|
||
</Button>
|
||
}
|
||
>
|
||
<div className='org-connector-form'>
|
||
<label>
|
||
{t('Connector 类型')}
|
||
<Select
|
||
value={form.definition_id}
|
||
disabled={!!form.id}
|
||
onChange={(value) => setForm({ ...form, definition_id: value })}
|
||
optionList={definitions.map((item) => ({
|
||
value: item.definition.id,
|
||
label: item.version.name_zh || item.version.name_en,
|
||
}))}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('实例键')}
|
||
<Input
|
||
value={form.instance_key}
|
||
onChange={(value) => setForm({ ...form, instance_key: value })}
|
||
placeholder='gitlab_primary'
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('显示名称')}
|
||
<Input
|
||
value={form.display_name}
|
||
onChange={(value) => setForm({ ...form, display_name: value })}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('Base URL(HTTP 类型)')}
|
||
<Input
|
||
value={form.base_url}
|
||
onChange={(value) => setForm({ ...form, base_url: value })}
|
||
placeholder='https://api.example.com'
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('精确域名白名单')}
|
||
<TextArea
|
||
value={form.allowed_hosts}
|
||
onChange={(value) => setForm({ ...form, allowed_hosts: value })}
|
||
placeholder={I18N_TECHNICAL_TEXT.API_EXAMPLE_COM}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('出站策略')}
|
||
<Select
|
||
value={form.egress_policy}
|
||
onChange={(value) => setForm({ ...form, egress_policy: value })}
|
||
optionList={[
|
||
{ value: 'public_https', label: 'Public HTTPS' },
|
||
{ value: 'approved_private', label: 'Approved private CIDR' },
|
||
]}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('授权 CIDR(仅运维审批私网)')}
|
||
<TextArea
|
||
value={form.allowed_cidrs}
|
||
onChange={(value) => setForm({ ...form, allowed_cidrs: value })}
|
||
placeholder={I18N_TECHNICAL_TEXT.CONNECTOR_CIDR_EXAMPLE}
|
||
/>
|
||
<span className='org-connector-note'>
|
||
{t(
|
||
'仅接受具体的私网网段:IPv4 须为 RFC1918 且前缀 ≥ /16,IPv6 须为 fc00::/7 内且前缀 ≥ /48;每行一条。',
|
||
)}
|
||
</span>
|
||
</label>
|
||
<label>
|
||
{t('能力边界 JSON')}
|
||
<TextArea
|
||
autosize
|
||
value={form.config}
|
||
onChange={(value) => setForm({ ...form, config: value })}
|
||
placeholder={I18N_TECHNICAL_TEXT.CONNECTOR_SCOPE_EXAMPLE}
|
||
/>
|
||
</label>
|
||
</div>
|
||
</SideSheet>
|
||
|
||
<Modal
|
||
title={t('轮换加密凭据')}
|
||
visible={credentialOpen}
|
||
onCancel={() => setCredentialOpen(false)}
|
||
onOk={saveCredential}
|
||
confirmLoading={saving}
|
||
>
|
||
<p className='org-connector-note'>
|
||
{t('提交后只显示哈希尾号,服务端不会回显明文。')}
|
||
</p>
|
||
<TextArea autosize value={credential} onChange={setCredential} />
|
||
</Modal>
|
||
|
||
<SideSheet
|
||
title={t('发布授权版本')}
|
||
visible={grantOpen}
|
||
onCancel={() => setGrantOpen(false)}
|
||
width={520}
|
||
footer={
|
||
<Button theme='solid' loading={saving} onClick={saveGrant}>
|
||
{t('发布授权')}
|
||
</Button>
|
||
}
|
||
>
|
||
<div className='org-connector-form'>
|
||
<label>
|
||
{t('授权键')}
|
||
<Input
|
||
value={grant.grant_key}
|
||
onChange={(value) => setGrant({ ...grant, grant_key: value })}
|
||
placeholder='gitlab_read_engineering'
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('Connector 实例')}
|
||
<Select
|
||
value={grant.connector_id}
|
||
onChange={(value) =>
|
||
setGrant({ ...grant, connector_id: value, method_keys: [] })
|
||
}
|
||
optionList={connectorRows
|
||
.filter((item) => item.status === 'active')
|
||
.map((item) => ({ value: item.id, label: item.display_name }))}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('专家 ID')}
|
||
<InputNumber
|
||
min={1}
|
||
value={grant.expert_id}
|
||
onChange={(value) => setGrant({ ...grant, expert_id: value })}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('范围')}
|
||
<Select
|
||
value={grant.scope_type}
|
||
onChange={(value) =>
|
||
setGrant({
|
||
...grant,
|
||
scope_type: value,
|
||
scope_id: value === 'organization' ? 0 : undefined,
|
||
})
|
||
}
|
||
optionList={[
|
||
'organization',
|
||
'department',
|
||
'project',
|
||
'member',
|
||
].map((value) => ({ value, label: value }))}
|
||
/>
|
||
</label>
|
||
{grant.scope_type !== 'organization' && (
|
||
<label>
|
||
{t('范围 ID')}
|
||
<InputNumber
|
||
min={1}
|
||
value={grant.scope_id}
|
||
onChange={(value) => setGrant({ ...grant, scope_id: value })}
|
||
/>
|
||
</label>
|
||
)}
|
||
<label>
|
||
{t('允许的方法')}
|
||
<Select
|
||
multiple
|
||
value={grant.method_keys}
|
||
onChange={(value) => setGrant({ ...grant, method_keys: value })}
|
||
optionList={grantMethodOptions.map((item) => ({
|
||
value: item.method_key,
|
||
label: `${item.name_zh || item.name_en} · ${item.operation_type}`,
|
||
}))}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('访问级别')}
|
||
<Select
|
||
value={grant.access_level}
|
||
onChange={(value) => setGrant({ ...grant, access_level: value })}
|
||
optionList={[
|
||
{ value: 'read', label: 'read' },
|
||
{ value: 'write', label: 'write' },
|
||
]}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('确认策略')}
|
||
<Select
|
||
value={grant.confirmation_policy}
|
||
onChange={(value) =>
|
||
setGrant({ ...grant, confirmation_policy: value })
|
||
}
|
||
optionList={['never', 'write', 'always'].map((value) => ({
|
||
value,
|
||
label: value,
|
||
}))}
|
||
/>
|
||
</label>
|
||
<label className='org-connector-switch'>
|
||
<span>{t('允许向已审批外部系统发送必要参数')}</span>
|
||
<Switch
|
||
checked={grant.external_allowed}
|
||
onChange={(value) =>
|
||
setGrant({ ...grant, external_allowed: value })
|
||
}
|
||
/>
|
||
</label>
|
||
{grantConnectorType === 'http' && !grant.external_allowed && (
|
||
<p className='org-connector-note'>
|
||
{t(
|
||
'HTTP 类型 Connector 必须开启此开关才会在任务运行时生效,关闭状态下无法发布授权。',
|
||
)}
|
||
</p>
|
||
)}
|
||
<label>
|
||
{t('单任务调用上限')}
|
||
<InputNumber
|
||
min={1}
|
||
max={10}
|
||
value={grant.max_calls_per_run}
|
||
onChange={(value) =>
|
||
setGrant({ ...grant, max_calls_per_run: value })
|
||
}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('结果上限(字节)')}
|
||
<InputNumber
|
||
min={1024}
|
||
max={1048576}
|
||
value={grant.max_result_bytes}
|
||
onChange={(value) =>
|
||
setGrant({ ...grant, max_result_bytes: value })
|
||
}
|
||
/>
|
||
</label>
|
||
</div>
|
||
</SideSheet>
|
||
</main>
|
||
);
|
||
};
|
||
|
||
export default OrgConnectors;
|