fix(ui): 修复登录和并发请求并统一页面展示
调整登录流程和请求处理,统一各中心的表格交互、主题样式和页面展示。
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
OctagonX as ActionOctagonX,
|
||||
Code2 as ActionCode2,
|
||||
} from '@/components/common/icons/ActionIcons';
|
||||
import { TableRowActions } from '@/components/common/table/TableToolbar';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
@@ -217,118 +218,115 @@ const OrgPrivateSkills = ({ orgId }) => {
|
||||
currentUserId > 0 && Number(row.version?.created_by) === currentUserId;
|
||||
const isReviewer =
|
||||
currentUserId > 0 && Number(row.review?.reviewer_id) === currentUserId;
|
||||
return (
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
<Button
|
||||
size='small'
|
||||
disabled={row.definition.emergency_stopped}
|
||||
onClick={() => {
|
||||
setEditingSkill(row.definition);
|
||||
setForm({
|
||||
...blankSkill,
|
||||
canonical_id: row.definition.canonical_id,
|
||||
});
|
||||
setEditorVisible(true);
|
||||
}}
|
||||
>
|
||||
{t('新版本')}
|
||||
</Button>
|
||||
<Button size='small' onClick={() => openHistory(row.definition)}>
|
||||
{t('历史版本')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
disabled={!versionId}
|
||||
onClick={() => {
|
||||
// Clear residue from a previous version's test before reopening.
|
||||
setEvidence({ model: '', input: '' });
|
||||
setEvidenceVersion(versionId);
|
||||
}}
|
||||
>
|
||||
{t('执行模型实测')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
disabled={!versionId || row.review?.status !== 'pending' || isAuthor}
|
||||
onClick={() =>
|
||||
action(`/api/org/skills/private/versions/${versionId}/review/start`)
|
||||
}
|
||||
>
|
||||
{isAuthor && row.review?.status === 'pending'
|
||||
const [primaryAction, ...moreActions] = [
|
||||
{
|
||||
key: 'new-version',
|
||||
label: t('新版本'),
|
||||
onClick: () => {
|
||||
setEditingSkill(row.definition);
|
||||
setForm({
|
||||
...blankSkill,
|
||||
canonical_id: row.definition.canonical_id,
|
||||
});
|
||||
setEditorVisible(true);
|
||||
},
|
||||
disabled: row.definition.emergency_stopped,
|
||||
},
|
||||
{
|
||||
key: 'history',
|
||||
label: t('历史版本'),
|
||||
onClick: () => openHistory(row.definition),
|
||||
},
|
||||
{
|
||||
key: 'runtime',
|
||||
label: t('执行模型实测'),
|
||||
onClick: () => {
|
||||
// Clear residue from a previous version's test before reopening.
|
||||
setEvidence({ model: '', input: '' });
|
||||
setEvidenceVersion(versionId);
|
||||
},
|
||||
disabled: !versionId,
|
||||
},
|
||||
{
|
||||
key: 'claim',
|
||||
label:
|
||||
isAuthor && row.review?.status === 'pending'
|
||||
? t('待他人审核')
|
||||
: t('领取审核')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
icon={<ActionFileCheck2 size={14} />}
|
||||
disabled={
|
||||
!versionId || row.review?.status !== 'reviewing' || !isReviewer
|
||||
}
|
||||
onClick={() =>
|
||||
: t('领取审核'),
|
||||
onClick: () =>
|
||||
action(`/api/org/skills/private/versions/${versionId}/review/start`),
|
||||
disabled: !versionId || row.review?.status !== 'pending' || isAuthor,
|
||||
},
|
||||
{
|
||||
key: 'approve',
|
||||
label: t('通过'),
|
||||
onClick: () =>
|
||||
action(
|
||||
`/api/org/skills/private/versions/${versionId}/review/decision`,
|
||||
{ approved: true, conclusion: { decision: 'approved' } },
|
||||
),
|
||||
disabled:
|
||||
!versionId || row.review?.status !== 'reviewing' || !isReviewer,
|
||||
icon: <ActionFileCheck2 size={14} />,
|
||||
},
|
||||
{
|
||||
key: 'reject',
|
||||
label: t('驳回'),
|
||||
onClick: () =>
|
||||
action(
|
||||
`/api/org/skills/private/versions/${versionId}/review/decision`,
|
||||
{ approved: false, conclusion: { decision: 'rejected' } },
|
||||
),
|
||||
disabled:
|
||||
!versionId || row.review?.status !== 'reviewing' || !isReviewer,
|
||||
danger: true,
|
||||
},
|
||||
{
|
||||
key: 'publish',
|
||||
label: t('发布'),
|
||||
onClick: () =>
|
||||
action(`/api/org/skills/private/versions/${versionId}/publish`),
|
||||
disabled: !versionId || row.review?.status !== 'approved',
|
||||
},
|
||||
{
|
||||
key: 'rollback',
|
||||
label: t('回滚'),
|
||||
onClick: () =>
|
||||
askReason(t('回滚到当前列表版本'), (reason) =>
|
||||
action(
|
||||
`/api/org/skills/private/versions/${versionId}/review/decision`,
|
||||
{ approved: true, conclusion: { decision: 'approved' } },
|
||||
)
|
||||
}
|
||||
>
|
||||
{t('通过')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
type='danger'
|
||||
disabled={
|
||||
!versionId || row.review?.status !== 'reviewing' || !isReviewer
|
||||
}
|
||||
onClick={() =>
|
||||
`/api/org/skills/private/${row.definition.id}/versions/${versionId}/rollback`,
|
||||
{ reason },
|
||||
),
|
||||
),
|
||||
disabled: !versionId,
|
||||
icon: <ActionRotateCcw size={14} />,
|
||||
},
|
||||
{
|
||||
key: 'stop',
|
||||
label: t('紧急停用'),
|
||||
onClick: () =>
|
||||
askReason(t('紧急停用 Skill'), (reason) =>
|
||||
action(
|
||||
`/api/org/skills/private/versions/${versionId}/review/decision`,
|
||||
{ approved: false, conclusion: { decision: 'rejected' } },
|
||||
)
|
||||
}
|
||||
>
|
||||
{t('驳回')}
|
||||
</Button>
|
||||
`/api/org/skills/private/${row.definition.id}/emergency-stop`,
|
||||
{ reason },
|
||||
),
|
||||
),
|
||||
disabled: row.definition.emergency_stopped,
|
||||
icon: <ActionOctagonX size={14} />,
|
||||
danger: true,
|
||||
},
|
||||
];
|
||||
return (
|
||||
<TableRowActions items={moreActions}>
|
||||
<Button
|
||||
size='small'
|
||||
disabled={!versionId || row.review?.status !== 'approved'}
|
||||
onClick={() =>
|
||||
action(`/api/org/skills/private/versions/${versionId}/publish`)
|
||||
}
|
||||
type='link'
|
||||
disabled={primaryAction.disabled}
|
||||
onClick={primaryAction.onClick}
|
||||
>
|
||||
{t('发布')}
|
||||
{primaryAction.label}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
icon={<ActionRotateCcw size={14} />}
|
||||
disabled={!versionId}
|
||||
onClick={() =>
|
||||
askReason(t('回滚到当前列表版本'), (reason) =>
|
||||
action(
|
||||
`/api/org/skills/private/${row.definition.id}/versions/${versionId}/rollback`,
|
||||
{ reason },
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
{t('回滚')}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
type='danger'
|
||||
icon={<ActionOctagonX size={14} />}
|
||||
disabled={row.definition.emergency_stopped}
|
||||
onClick={() =>
|
||||
askReason(t('紧急停用 Skill'), (reason) =>
|
||||
action(
|
||||
`/api/org/skills/private/${row.definition.id}/emergency-stop`,
|
||||
{ reason },
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
{t('紧急停用')}
|
||||
</Button>
|
||||
</div>
|
||||
</TableRowActions>
|
||||
);
|
||||
};
|
||||
const openCreateEditor = () => {
|
||||
@@ -500,7 +498,7 @@ const OrgPrivateSkills = ({ orgId }) => {
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 430,
|
||||
width: 170,
|
||||
render: (_, row) => renderSkillActions(row),
|
||||
},
|
||||
]}
|
||||
|
||||
Reference in New Issue
Block a user