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