refactor(plugin-workflow): adjust ui and client api (#2817)
* refactor(plugin-workflow): adjust ui and client api * fix(plugin-workflow): fix test cases * fix(plugin-workflow): fix test case
This commit is contained in:
parent
62d9200657
commit
9044434930
@ -1,16 +1,20 @@
|
||||
import { cx } from '@nocobase/client';
|
||||
import { Tag } from 'antd';
|
||||
import { Alert } from 'antd';
|
||||
import React from 'react';
|
||||
import { Branch } from './Branch';
|
||||
import { lang } from './locale';
|
||||
import useStyles from './style';
|
||||
import { TriggerConfig } from './triggers';
|
||||
import { useFlowContext } from './FlowContext';
|
||||
|
||||
export function CanvasContent({ entry }) {
|
||||
const { styles } = useStyles();
|
||||
const { workflow } = useFlowContext();
|
||||
|
||||
return (
|
||||
<div className="workflow-canvas">
|
||||
{workflow?.executed ? (
|
||||
<Alert type="warning" message={lang('Executed workflow cannot be modified')} showIcon />
|
||||
) : null}
|
||||
<TriggerConfig />
|
||||
<div className={styles.branchBlockClass}>
|
||||
<Branch entry={entry} />
|
||||
|
@ -10,7 +10,7 @@ export const WorkflowLink = () => {
|
||||
const { setVisible } = useActionContext();
|
||||
return (
|
||||
<Link to={`/admin/settings/workflow/workflows/${id}`} onClick={() => setVisible(false)}>
|
||||
{t('View')}
|
||||
{t('Configure')}
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ test.describe('workflow manage', () => {
|
||||
await page.getByTestId('filter-action').click();
|
||||
await page.getByRole('textbox').fill(workFlowName);
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
await page.getByRole('cell', { name: 'View Edit Duplicate Delete' }).getByTestId('delete-action').click();
|
||||
await page.getByRole('cell', { name: 'Configure Edit Duplicate Delete' }).getByTestId('delete-action').click();
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
await expect(page.getByText(workFlowName)).toBeHidden();
|
||||
});
|
||||
|
@ -36,7 +36,7 @@ test.describe('workflow manage', () => {
|
||||
await page.getByTestId('filter-action').click();
|
||||
await page.getByRole('textbox').fill(workFlowName);
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
await page.getByRole('cell', { name: 'View Edit Duplicate Delete' }).getByTestId('delete-action').click();
|
||||
await page.getByRole('cell', { name: 'Configure Edit Duplicate Delete' }).getByTestId('delete-action').click();
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
await expect(page.getByText(workFlowName)).toBeHidden();
|
||||
});
|
||||
|
@ -37,7 +37,7 @@ test.describe('trigger collection events', () => {
|
||||
|
||||
//配置工作流触发器
|
||||
await page
|
||||
.getByRole('row', { name: '1 ' + workFlowName + ' Collection event Off 0 View Edit Duplicate Delete' })
|
||||
.getByRole('row', { name: '1 ' + workFlowName + ' Collection event Off 0 Configure Edit Duplicate Delete' })
|
||||
.getByRole('link')
|
||||
.click();
|
||||
await page.getByRole('button', { name: 'Configure' }).click();
|
||||
@ -48,7 +48,7 @@ test.describe('trigger collection events', () => {
|
||||
await page.getByTestId('submit-action').click();
|
||||
await page.getByRole('link', { name: 'Workflow' }).click();
|
||||
await page
|
||||
.getByRole('row', { name: '1 ' + workFlowName + ' Collection event Off 0 View Edit Duplicate Delete' })
|
||||
.getByRole('row', { name: '1 ' + workFlowName + ' Collection event Off 0 Configure Edit Duplicate Delete' })
|
||||
.getByTestId('update-action')
|
||||
.click();
|
||||
await page.getByTestId('enabled-item').getByLabel('On').check();
|
||||
@ -99,7 +99,7 @@ test.describe('trigger collection events', () => {
|
||||
await page.getByTestId('filter-action').click();
|
||||
await page.getByRole('textbox').fill(workFlowName);
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
await page.getByRole('cell', { name: 'View Edit Duplicate Delete' }).getByTestId('delete-action').click();
|
||||
await page.getByRole('cell', { name: 'Configure Edit Duplicate Delete' }).getByTestId('delete-action').click();
|
||||
await page.getByRole('button', { name: 'OK' }).click();
|
||||
await expect(page.getByText(workFlowName)).toBeHidden();
|
||||
});
|
||||
|
@ -2,7 +2,7 @@ export * from './constants';
|
||||
export * from './Branch';
|
||||
export * from './FlowContext';
|
||||
export * from './nodes';
|
||||
export { triggers, getTriggersOptions } from './triggers';
|
||||
export { triggers, useTrigger, getTriggersOptions } from './triggers';
|
||||
export { useWorkflowVariableOptions } from './variable';
|
||||
|
||||
import { Plugin } from '@nocobase/client';
|
||||
|
@ -383,24 +383,7 @@ export function NodeDefaultView(props) {
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
...(workflow.executed
|
||||
? {
|
||||
alert: {
|
||||
type: 'void',
|
||||
'x-component': Alert,
|
||||
'x-component-props': {
|
||||
type: 'warning',
|
||||
showIcon: true,
|
||||
message: `{{t("Node in executed workflow cannot be modified", { ns: "${NAMESPACE}" })}}`,
|
||||
className: css`
|
||||
width: 100%;
|
||||
font-size: 85%;
|
||||
margin-bottom: 2em;
|
||||
`,
|
||||
},
|
||||
},
|
||||
}
|
||||
: instruction.description
|
||||
...(instruction.description
|
||||
? {
|
||||
description: {
|
||||
type: 'void',
|
||||
|
@ -311,7 +311,7 @@ export const workflowSchema: ISchema = {
|
||||
split: '|',
|
||||
},
|
||||
properties: {
|
||||
view: {
|
||||
configure: {
|
||||
type: 'void',
|
||||
'x-component': 'WorkflowLink',
|
||||
},
|
||||
|
@ -44,6 +44,11 @@ const useStyles = createStyles(({ css, token }) => {
|
||||
align-items: center;
|
||||
padding: 2em;
|
||||
|
||||
> .ant-alert {
|
||||
margin-bottom: 2em;
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
.end {
|
||||
cursor: default;
|
||||
|
||||
|
@ -242,23 +242,7 @@ export const TriggerConfig = () => {
|
||||
form,
|
||||
},
|
||||
properties: {
|
||||
...(executed
|
||||
? {
|
||||
alert: {
|
||||
'x-component': Alert,
|
||||
'x-component-props': {
|
||||
type: 'warning',
|
||||
showIcon: true,
|
||||
message: `{{t("Trigger in executed workflow cannot be modified", { ns: "${NAMESPACE}" })}}`,
|
||||
className: css`
|
||||
width: 100%;
|
||||
font-size: 85%;
|
||||
margin-bottom: 2em;
|
||||
`,
|
||||
},
|
||||
},
|
||||
}
|
||||
: trigger.description
|
||||
...(trigger.description
|
||||
? {
|
||||
description: {
|
||||
type: 'void',
|
||||
|
@ -248,8 +248,7 @@ export default {
|
||||
Distinct: '去重',
|
||||
'Query result': '查询结果',
|
||||
|
||||
'Trigger in executed workflow cannot be modified': '已经执行过工作流的触发器不能被修改',
|
||||
'Node in executed workflow cannot be modified': '已经执行过工作流中的节点不能被修改',
|
||||
'Executed workflow cannot be modified': '已经执行过的工作流不能被修改',
|
||||
'Can not delete': '无法删除',
|
||||
'The result of this node has been referenced by other nodes ({{nodes}}), please remove the usage before deleting.':
|
||||
'该节点的执行结果已被其他节点({{nodes}})引用,删除前请先移除引用。',
|
||||
|
Loading…
Reference in New Issue
Block a user