@nocobase/plugin-workflow 0.10.1-alpha.1 → 0.11.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +2 -3
- package/client.js +1 -30
- package/lib/client/AddButton.js +13 -11
- package/lib/client/Branch.js +10 -8
- package/lib/client/CanvasContent.js +12 -10
- package/lib/client/ExecutionCanvas.js +37 -33
- package/lib/client/ExecutionPage.js +4 -9
- package/lib/client/WorkflowCanvas.js +18 -15
- package/lib/client/WorkflowPage.js +4 -9
- package/lib/client/WorkflowProvider.js +1 -40
- package/lib/client/components/CollectionBlockInitializer.js +3 -3
- package/lib/client/components/CollectionFieldset.d.ts +1 -1
- package/lib/client/components/CollectionFieldset.js +15 -16
- package/lib/client/components/Duration.js +5 -5
- package/lib/client/components/DynamicExpression.d.ts +3 -3
- package/lib/client/components/FieldsSelect.d.ts +1 -1
- package/lib/client/components/FieldsSelect.js +10 -7
- package/lib/client/components/NodeDescription.js +45 -31
- package/lib/client/components/RadioWithTooltip.js +13 -20
- package/lib/client/components/ValueBlock.js +14 -21
- package/lib/client/components/renderEngineReference.js +1 -8
- package/lib/client/index.d.ts +12 -4
- package/lib/client/index.js +78 -15
- package/lib/client/locale/zh-CN.d.ts +5 -1
- package/lib/client/locale/zh-CN.js +6 -2
- package/lib/client/nodes/aggregate.d.ts +8 -3
- package/lib/client/nodes/aggregate.js +5 -4
- package/lib/client/nodes/calculation.d.ts +6 -4
- package/lib/client/nodes/calculation.js +22 -28
- package/lib/client/nodes/condition.d.ts +2 -10
- package/lib/client/nodes/condition.js +19 -37
- package/lib/client/nodes/create.d.ts +5 -6
- package/lib/client/nodes/create.js +1 -3
- package/lib/client/nodes/destroy.d.ts +1 -1
- package/lib/client/nodes/index.d.ts +2 -3
- package/lib/client/nodes/index.js +95 -102
- package/lib/client/nodes/loop.d.ts +1 -1
- package/lib/client/nodes/loop.js +46 -54
- package/lib/client/nodes/manual/FormBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/ModeConfig.js +23 -30
- package/lib/client/nodes/manual/SchemaConfig.d.ts +4 -5
- package/lib/client/nodes/manual/SchemaConfig.js +180 -25
- package/lib/client/nodes/manual/WorkflowTodo.js +95 -110
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -5
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/forms/create.js +8 -1
- package/lib/client/nodes/manual/forms/custom.js +22 -22
- package/lib/client/nodes/manual/forms/update.js +8 -1
- package/lib/client/nodes/manual/index.d.ts +6 -1
- package/lib/client/nodes/manual/index.js +5 -4
- package/lib/client/nodes/parallel.js +23 -20
- package/lib/client/nodes/query.d.ts +3 -5
- package/lib/client/nodes/query.js +1 -3
- package/lib/client/nodes/request.d.ts +2 -2
- package/lib/client/nodes/request.js +7 -7
- package/lib/client/nodes/sql.d.ts +26 -0
- package/lib/client/{triggers/schedule/DateFieldsSelect.js → nodes/sql.js} +37 -46
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +1 -1
- package/lib/client/schemas/collection.d.ts +3 -4
- package/lib/client/schemas/collection.js +11 -17
- package/lib/client/style.d.ts +18 -13
- package/lib/client/style.js +315 -292
- package/lib/client/triggers/collection.d.ts +13 -13
- package/lib/client/triggers/collection.js +5 -1
- package/lib/client/triggers/index.d.ts +3 -4
- package/lib/client/triggers/index.js +51 -53
- package/lib/client/triggers/schedule/EndsByField.js +11 -11
- package/lib/client/triggers/schedule/OnField.js +45 -33
- package/lib/client/triggers/schedule/RepeatField.js +4 -4
- package/lib/client/triggers/schedule/ScheduleConfig.js +24 -31
- package/lib/client/triggers/schedule/index.d.ts +1 -1
- package/lib/client/triggers/schedule/index.js +32 -20
- package/lib/client/variable.d.ts +31 -13
- package/lib/client/variable.js +44 -29
- package/lib/server/Plugin.d.ts +3 -6
- package/lib/server/Plugin.js +15 -12
- package/lib/server/Processor.d.ts +3 -5
- package/lib/server/Processor.js +2 -2
- package/lib/server/actions/nodes.js +7 -7
- package/lib/server/fields/expression-field.d.ts +1 -2
- package/lib/server/fields/expression-field.js +1 -8
- package/lib/server/functions/index.d.ts +2 -3
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +12 -0
- package/lib/server/instructions/aggregate.d.ts +1 -1
- package/lib/server/instructions/aggregate.js +5 -5
- package/lib/server/instructions/condition.d.ts +2 -1
- package/lib/server/instructions/create.d.ts +2 -2
- package/lib/server/instructions/create.js +13 -13
- package/lib/server/instructions/delay.d.ts +3 -3
- package/lib/server/instructions/delay.js +66 -64
- package/lib/server/instructions/destroy.d.ts +1 -1
- package/lib/server/instructions/index.d.ts +5 -5
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/loop.d.ts +1 -2
- package/lib/server/instructions/manual/actions.js +19 -7
- package/lib/server/instructions/manual/forms/create.js +7 -1
- package/lib/server/instructions/manual/forms/index.d.ts +1 -1
- package/lib/server/instructions/manual/forms/update.js +7 -1
- package/lib/server/instructions/manual/index.d.ts +1 -1
- package/lib/server/instructions/parallel.d.ts +1 -2
- package/lib/server/instructions/query.d.ts +1 -1
- package/lib/server/instructions/query.js +8 -1
- package/lib/server/instructions/request.d.ts +3 -3
- package/lib/server/instructions/request.js +5 -2
- package/lib/server/instructions/sql.d.ts +12 -0
- package/lib/server/instructions/sql.js +34 -0
- package/lib/server/instructions/update.d.ts +1 -1
- package/lib/server/migrations/20230221071831-calculation-expression.js +1 -1
- package/lib/server/migrations/20230221121203-condition-calculation.js +1 -1
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +7 -7
- package/lib/server/migrations/20230411034722-manual-multi-form.js +1 -8
- package/lib/server/migrations/20230710115902-manual-action-values.d.ts +4 -0
- package/lib/server/migrations/20230710115902-manual-action-values.js +97 -0
- package/lib/server/triggers/collection.d.ts +1 -1
- package/lib/server/triggers/collection.js +15 -13
- package/lib/server/triggers/index.d.ts +1 -1
- package/lib/server/triggers/schedule.d.ts +1 -1
- package/lib/server/triggers/schedule.js +18 -18
- package/lib/server/{models → types}/Execution.d.ts +2 -3
- package/lib/server/{models → types}/FlowNode.d.ts +1 -2
- package/lib/server/{models → types}/Job.d.ts +1 -2
- package/lib/server/{models → types}/Workflow.d.ts +1 -2
- package/lib/server/types/index.d.ts +4 -0
- package/lib/server/types/index.js +5 -0
- package/lib/server/utils.d.ts +2 -0
- package/lib/server/utils.js +21 -0
- package/package.json +39 -18
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/src/client/AddButton.tsx +111 -0
- package/src/client/Branch.tsx +37 -0
- package/src/client/CanvasContent.tsx +25 -0
- package/src/client/ExecutionCanvas.tsx +166 -0
- package/src/client/ExecutionLink.tsx +16 -0
- package/src/client/ExecutionPage.tsx +45 -0
- package/src/client/ExecutionResourceProvider.tsx +21 -0
- package/src/client/FlowContext.ts +7 -0
- package/src/client/WorkflowCanvas.tsx +221 -0
- package/src/client/WorkflowLink.tsx +16 -0
- package/src/client/WorkflowPage.tsx +52 -0
- package/src/client/WorkflowProvider.tsx +84 -0
- package/src/client/components/CollectionBlockInitializer.tsx +71 -0
- package/src/client/components/CollectionFieldset.tsx +160 -0
- package/src/client/components/Duration.tsx +45 -0
- package/src/client/components/DynamicExpression.tsx +53 -0
- package/src/client/components/FieldsSelect.tsx +32 -0
- package/src/client/components/FilterDynamicComponent.tsx +15 -0
- package/src/client/components/NodeDescription.tsx +51 -0
- package/src/client/components/NullRender.tsx +3 -0
- package/src/client/components/OpenDrawer.tsx +24 -0
- package/src/client/components/RadioWithTooltip.tsx +38 -0
- package/src/client/components/ValueBlock.tsx +67 -0
- package/src/client/components/renderEngineReference.tsx +30 -0
- package/src/client/constants.tsx +91 -0
- package/src/client/index.tsx +51 -0
- package/src/client/interfaces/expression.tsx +25 -0
- package/src/client/locale/en-US.ts +136 -0
- package/src/client/locale/es-ES.ts +129 -0
- package/src/client/locale/index.ts +18 -0
- package/src/client/locale/ja-JP.ts +90 -0
- package/src/client/locale/pt-BR.ts +136 -0
- package/src/client/locale/ru-RU.ts +90 -0
- package/src/client/locale/tr-TR.ts +90 -0
- package/src/client/locale/zh-CN.ts +248 -0
- package/src/client/nodes/aggregate.tsx +327 -0
- package/src/client/nodes/calculation.tsx +216 -0
- package/src/client/nodes/condition.tsx +463 -0
- package/src/client/nodes/create.tsx +85 -0
- package/src/client/nodes/delay.tsx +37 -0
- package/src/client/nodes/destroy.tsx +34 -0
- package/src/client/nodes/index.tsx +485 -0
- package/src/client/nodes/loop.tsx +144 -0
- package/src/client/nodes/manual/AssigneesSelect.tsx +33 -0
- package/src/client/nodes/manual/DetailsBlockProvider.tsx +80 -0
- package/src/client/nodes/manual/FormBlockInitializer.tsx +69 -0
- package/src/client/nodes/manual/FormBlockProvider.tsx +75 -0
- package/src/client/nodes/manual/ModeConfig.tsx +84 -0
- package/src/client/nodes/manual/SchemaConfig.tsx +509 -0
- package/src/client/nodes/manual/WorkflowTodo.tsx +607 -0
- package/src/client/nodes/manual/WorkflowTodoBlockInitializer.tsx +28 -0
- package/src/client/nodes/manual/forms/create.tsx +92 -0
- package/src/client/nodes/manual/forms/custom.tsx +392 -0
- package/src/client/nodes/manual/forms/update.tsx +134 -0
- package/src/client/nodes/manual/index.tsx +162 -0
- package/src/client/nodes/manual/utils.ts +28 -0
- package/src/client/nodes/parallel.tsx +138 -0
- package/src/client/nodes/query.tsx +88 -0
- package/src/client/nodes/request.tsx +185 -0
- package/src/client/nodes/sql.tsx +37 -0
- package/src/client/nodes/update.tsx +99 -0
- package/src/client/schemas/collection.ts +75 -0
- package/src/client/schemas/executions.tsx +169 -0
- package/src/client/schemas/workflows.ts +364 -0
- package/src/client/style.tsx +347 -0
- package/src/client/triggers/collection.tsx +190 -0
- package/src/client/triggers/index.tsx +311 -0
- package/src/client/triggers/schedule/EndsByField.tsx +40 -0
- package/src/client/triggers/schedule/OnField.tsx +64 -0
- package/src/client/triggers/schedule/RepeatField.tsx +116 -0
- package/src/client/triggers/schedule/ScheduleConfig.tsx +227 -0
- package/src/client/triggers/schedule/constants.ts +4 -0
- package/src/client/triggers/schedule/index.tsx +78 -0
- package/src/client/triggers/schedule/locale/Cron.zh-CN.ts +79 -0
- package/src/client/utils.ts +36 -0
- package/src/client/variable.tsx +318 -0
- package/src/index.ts +1 -0
- package/src/server/Plugin.ts +355 -0
- package/src/server/Processor.ts +354 -0
- package/src/server/__tests__/Plugin.test.ts +398 -0
- package/src/server/__tests__/Processor.test.ts +474 -0
- package/src/server/__tests__/actions/workflows.test.ts +419 -0
- package/src/server/__tests__/collections/categories.ts +27 -0
- package/src/server/__tests__/collections/comments.ts +24 -0
- package/src/server/__tests__/collections/posts.ts +42 -0
- package/src/server/__tests__/collections/replies.ts +9 -0
- package/src/server/__tests__/collections/tags.ts +15 -0
- package/src/server/__tests__/index.ts +89 -0
- package/src/server/__tests__/instructions/aggregate.test.ts +294 -0
- package/src/server/__tests__/instructions/calculation.test.ts +265 -0
- package/src/server/__tests__/instructions/condition.test.ts +335 -0
- package/src/server/__tests__/instructions/create.test.ts +129 -0
- package/src/server/__tests__/instructions/delay.test.ts +182 -0
- package/src/server/__tests__/instructions/destroy.test.ts +58 -0
- package/src/server/__tests__/instructions/loop.test.ts +331 -0
- package/src/server/__tests__/instructions/manual.test.ts +1173 -0
- package/src/server/__tests__/instructions/parallel.test.ts +445 -0
- package/src/server/__tests__/instructions/query.test.ts +359 -0
- package/src/server/__tests__/instructions/request.test.ts +247 -0
- package/src/server/__tests__/instructions/sql.test.ts +162 -0
- package/src/server/__tests__/instructions/update.test.ts +189 -0
- package/src/server/__tests__/triggers/collection.test.ts +333 -0
- package/src/server/__tests__/triggers/schedule.test.ts +369 -0
- package/src/server/actions/index.ts +25 -0
- package/src/server/actions/nodes.ts +214 -0
- package/src/server/actions/workflows.ts +178 -0
- package/src/server/collections/executions.ts +35 -0
- package/src/server/collections/flow_nodes.ts +54 -0
- package/src/server/collections/jobs.ts +31 -0
- package/src/server/collections/workflows.ts +88 -0
- package/src/server/constants.ts +26 -0
- package/src/server/fields/expression-field.ts +11 -0
- package/src/server/fields/index.ts +7 -0
- package/src/server/functions/index.ts +16 -0
- package/src/server/index.ts +6 -0
- package/src/server/instructions/aggregate.ts +42 -0
- package/src/server/instructions/calculation.ts +41 -0
- package/src/server/instructions/condition.ts +172 -0
- package/src/server/instructions/create.ts +39 -0
- package/src/server/instructions/delay.ts +105 -0
- package/src/server/instructions/destroy.ts +23 -0
- package/src/server/instructions/index.ts +64 -0
- package/src/server/instructions/loop.ts +99 -0
- package/src/server/instructions/manual/actions.ts +91 -0
- package/src/server/instructions/manual/collecions/jobs.ts +17 -0
- package/src/server/instructions/manual/collecions/users.ts +15 -0
- package/src/server/instructions/manual/collecions/users_jobs.ts +50 -0
- package/src/server/instructions/manual/forms/create.ts +23 -0
- package/src/server/instructions/manual/forms/index.ts +12 -0
- package/src/server/instructions/manual/forms/update.ts +23 -0
- package/src/server/instructions/manual/index.ts +184 -0
- package/src/server/instructions/parallel.ts +121 -0
- package/src/server/instructions/query.ts +42 -0
- package/src/server/instructions/request.ts +88 -0
- package/src/server/instructions/sql.ts +25 -0
- package/src/server/instructions/update.ts +24 -0
- package/src/server/migrations/20221129153547-calculation-variables.ts +64 -0
- package/src/server/migrations/20230221032941-change-request-body-type.ts +76 -0
- package/src/server/migrations/20230221071831-calculation-expression.ts +102 -0
- package/src/server/migrations/20230221121203-condition-calculation.ts +82 -0
- package/src/server/migrations/20230221162902-jsonb-to-json.ts +51 -0
- package/src/server/migrations/20230411034722-manual-multi-form.ts +282 -0
- package/src/server/migrations/20230612021134-manual-collection-block.ts +138 -0
- package/src/server/migrations/20230710115902-manual-action-values.ts +78 -0
- package/src/server/triggers/collection.ts +146 -0
- package/src/server/triggers/index.ts +22 -0
- package/src/server/triggers/schedule.ts +567 -0
- package/src/server/types/Execution.ts +26 -0
- package/src/server/types/FlowNode.ts +21 -0
- package/src/server/types/Job.ts +18 -0
- package/src/server/types/Workflow.ts +36 -0
- package/src/server/types/index.ts +4 -0
- package/src/server/utils.ts +17 -0
- package/lib/client/triggers/schedule/DateFieldsSelect.d.ts +0 -2
- /package/lib/server/{models → types}/Execution.js +0 -0
- /package/lib/server/{models → types}/FlowNode.js +0 -0
- /package/lib/server/{models → types}/Job.js +0 -0
- /package/lib/server/{models → types}/Workflow.js +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CollectionProvider,
|
|
5
|
+
SchemaInitializer,
|
|
6
|
+
SchemaInitializerItemOptions,
|
|
7
|
+
useCollectionManager,
|
|
8
|
+
useRecordCollectionDataSourceItems,
|
|
9
|
+
useSchemaTemplateManager,
|
|
10
|
+
} from '@nocobase/client';
|
|
11
|
+
import { traverseSchema } from '../nodes/manual/utils';
|
|
12
|
+
|
|
13
|
+
function InnerCollectionBlockInitializer({ insert, collection, dataSource, ...props }) {
|
|
14
|
+
const { getTemplateSchemaByMode } = useSchemaTemplateManager();
|
|
15
|
+
const { getCollection } = useCollectionManager();
|
|
16
|
+
const items = useRecordCollectionDataSourceItems('FormItem') as SchemaInitializerItemOptions[];
|
|
17
|
+
const resolvedCollection = getCollection(collection);
|
|
18
|
+
|
|
19
|
+
async function onConfirm({ item }) {
|
|
20
|
+
const template = item.template ? await getTemplateSchemaByMode(item) : null;
|
|
21
|
+
const result = {
|
|
22
|
+
type: 'void',
|
|
23
|
+
name: resolvedCollection.name,
|
|
24
|
+
title: resolvedCollection.title,
|
|
25
|
+
'x-decorator': 'DetailsBlockProvider',
|
|
26
|
+
'x-decorator-props': {
|
|
27
|
+
collection,
|
|
28
|
+
dataSource,
|
|
29
|
+
},
|
|
30
|
+
'x-component': 'CardItem',
|
|
31
|
+
'x-component-props': {
|
|
32
|
+
title: props.title,
|
|
33
|
+
},
|
|
34
|
+
'x-designer': 'SimpleDesigner',
|
|
35
|
+
properties: {
|
|
36
|
+
grid: {
|
|
37
|
+
type: 'void',
|
|
38
|
+
'x-component': 'FormV2',
|
|
39
|
+
'x-component-props': {
|
|
40
|
+
useProps: '{{useDetailsBlockProps}}',
|
|
41
|
+
},
|
|
42
|
+
'x-read-pretty': true,
|
|
43
|
+
properties: {
|
|
44
|
+
grid: template || {
|
|
45
|
+
type: 'void',
|
|
46
|
+
'x-component': 'Grid',
|
|
47
|
+
'x-initializer': 'ReadPrettyFormItemInitializers',
|
|
48
|
+
properties: {},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
traverseSchema(result, (node) => {
|
|
55
|
+
if (node['x-uid']) {
|
|
56
|
+
delete node['x-uid'];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
insert(result);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return <SchemaInitializer.Item {...props} onClick={onConfirm} items={items} />;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function CollectionBlockInitializer(props) {
|
|
66
|
+
return (
|
|
67
|
+
<CollectionProvider collection={props.collection}>
|
|
68
|
+
<InnerCollectionBlockInitializer {...props} />
|
|
69
|
+
</CollectionProvider>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { CloseCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
|
2
|
+
import { observer, useField, useForm } from '@formily/react';
|
|
3
|
+
import {
|
|
4
|
+
CollectionField,
|
|
5
|
+
CollectionProvider,
|
|
6
|
+
SchemaComponent,
|
|
7
|
+
Variable,
|
|
8
|
+
css,
|
|
9
|
+
useCollectionManager,
|
|
10
|
+
useCompile,
|
|
11
|
+
useToken,
|
|
12
|
+
} from '@nocobase/client';
|
|
13
|
+
import { Button, Dropdown, Form, Input, MenuProps } from 'antd';
|
|
14
|
+
import React, { useMemo } from 'react';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { lang } from '../locale';
|
|
17
|
+
import { useWorkflowVariableOptions } from '../variable';
|
|
18
|
+
|
|
19
|
+
function AssociationInput(props) {
|
|
20
|
+
const { getCollectionFields } = useCollectionManager();
|
|
21
|
+
const { path } = useField();
|
|
22
|
+
const fieldName = path.segments[path.segments.length - 1] as string;
|
|
23
|
+
const { values: config } = useForm();
|
|
24
|
+
const fields = getCollectionFields(config?.collection);
|
|
25
|
+
const { type } = fields.find((item) => item.name === fieldName);
|
|
26
|
+
|
|
27
|
+
const value = Array.isArray(props.value) ? props.value.join(',') : props.value;
|
|
28
|
+
function onChange(ev) {
|
|
29
|
+
const trimed = ev.target.value.trim();
|
|
30
|
+
props.onChange(['belongsTo', 'hasOne'].includes(type) ? trimed : trimed.split(/[,\s]+/));
|
|
31
|
+
}
|
|
32
|
+
return <Input {...props} value={value} onChange={onChange} />;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function useCollectionUIFields(collection) {
|
|
36
|
+
const { getCollectionFields } = useCollectionManager();
|
|
37
|
+
|
|
38
|
+
return getCollectionFields(collection).filter(
|
|
39
|
+
(field) => !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// NOTE: observer for watching useProps
|
|
44
|
+
const CollectionFieldSet = observer(
|
|
45
|
+
({ value, disabled, onChange, filter }: any) => {
|
|
46
|
+
const { token } = useToken();
|
|
47
|
+
const { t } = useTranslation();
|
|
48
|
+
const compile = useCompile();
|
|
49
|
+
const form = useForm();
|
|
50
|
+
const { getCollection } = useCollectionManager();
|
|
51
|
+
const scope = useWorkflowVariableOptions();
|
|
52
|
+
const { values: config } = form;
|
|
53
|
+
const collectionName = config?.collection;
|
|
54
|
+
const collectionFields = useCollectionUIFields(collectionName);
|
|
55
|
+
const fields = filter ? collectionFields.filter(filter.bind(config)) : collectionFields;
|
|
56
|
+
|
|
57
|
+
const unassignedFields = useMemo(() => fields.filter((field) => !value || !(field.name in value)), [fields, value]);
|
|
58
|
+
const mergedDisabled = disabled || form.disabled;
|
|
59
|
+
const menu = useMemo<MenuProps>(() => {
|
|
60
|
+
return {
|
|
61
|
+
onClick: ({ key }) => {
|
|
62
|
+
onChange({ ...value, [key]: null });
|
|
63
|
+
},
|
|
64
|
+
style: {
|
|
65
|
+
maxHeight: 300,
|
|
66
|
+
overflowY: 'auto',
|
|
67
|
+
},
|
|
68
|
+
items: unassignedFields.map((field) => ({
|
|
69
|
+
key: field.name,
|
|
70
|
+
label: compile(field.uiSchema?.title ?? field.name),
|
|
71
|
+
})),
|
|
72
|
+
};
|
|
73
|
+
}, [onChange, unassignedFields, value]);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<fieldset
|
|
77
|
+
className={css`
|
|
78
|
+
margin-top: 0.5em;
|
|
79
|
+
|
|
80
|
+
> .ant-formily-item {
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
|
|
83
|
+
> .ant-formily-item-label {
|
|
84
|
+
line-height: 32px;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
`}
|
|
88
|
+
>
|
|
89
|
+
{fields.length ? (
|
|
90
|
+
<CollectionProvider collection={getCollection(collectionName)}>
|
|
91
|
+
{fields
|
|
92
|
+
.filter((field) => value && field.name in value)
|
|
93
|
+
.map((field) => {
|
|
94
|
+
// constant for associations to use Input, others to use CollectionField
|
|
95
|
+
// dynamic values only support belongsTo/hasOne association, other association type should disable
|
|
96
|
+
const ConstantCompoent = ['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type)
|
|
97
|
+
? AssociationInput
|
|
98
|
+
: CollectionField;
|
|
99
|
+
// TODO: try to use <ObjectField> to replace this map
|
|
100
|
+
return (
|
|
101
|
+
<Form.Item
|
|
102
|
+
key={field.name}
|
|
103
|
+
label={compile(field.uiSchema?.title ?? field.name)}
|
|
104
|
+
labelAlign="left"
|
|
105
|
+
className={css`
|
|
106
|
+
.ant-form-item-control-input-content {
|
|
107
|
+
display: flex;
|
|
108
|
+
}
|
|
109
|
+
`}
|
|
110
|
+
>
|
|
111
|
+
<Variable.Input
|
|
112
|
+
scope={scope}
|
|
113
|
+
value={value[field.name]}
|
|
114
|
+
onChange={(next) => {
|
|
115
|
+
onChange({ ...value, [field.name]: next });
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
<SchemaComponent
|
|
119
|
+
schema={{
|
|
120
|
+
type: 'void',
|
|
121
|
+
properties: {
|
|
122
|
+
[field.name]: {
|
|
123
|
+
'x-component': ConstantCompoent,
|
|
124
|
+
['x-validator']() {
|
|
125
|
+
return '';
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
}}
|
|
130
|
+
/>
|
|
131
|
+
</Variable.Input>
|
|
132
|
+
{!mergedDisabled ? (
|
|
133
|
+
<Button
|
|
134
|
+
type="link"
|
|
135
|
+
icon={<CloseCircleOutlined />}
|
|
136
|
+
onClick={() => {
|
|
137
|
+
const { [field.name]: _, ...rest } = value;
|
|
138
|
+
onChange(rest);
|
|
139
|
+
}}
|
|
140
|
+
/>
|
|
141
|
+
) : null}
|
|
142
|
+
</Form.Item>
|
|
143
|
+
);
|
|
144
|
+
})}
|
|
145
|
+
{unassignedFields.length ? (
|
|
146
|
+
<Dropdown menu={menu}>
|
|
147
|
+
<Button icon={<PlusOutlined />}>{t('Add field')}</Button>
|
|
148
|
+
</Dropdown>
|
|
149
|
+
) : null}
|
|
150
|
+
</CollectionProvider>
|
|
151
|
+
) : (
|
|
152
|
+
<p style={{ color: token.colorText }}>{lang('Please select collection first')}</p>
|
|
153
|
+
)}
|
|
154
|
+
</fieldset>
|
|
155
|
+
);
|
|
156
|
+
},
|
|
157
|
+
{ displayName: 'CollectionFieldSet' },
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
export default CollectionFieldSet;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { css } from '@nocobase/client';
|
|
2
|
+
import { InputNumber, Select } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { lang } from '../locale';
|
|
5
|
+
|
|
6
|
+
const UnitOptions = [
|
|
7
|
+
{ value: 1_000, label: 'Seconds' },
|
|
8
|
+
{ value: 60_000, label: 'Minutes' },
|
|
9
|
+
{ value: 3600_000, label: 'Hours' },
|
|
10
|
+
{ value: 86400_000, label: 'Days' },
|
|
11
|
+
{ value: 604800_000, label: 'Weeks' },
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
function getNumberOption(v) {
|
|
15
|
+
return UnitOptions.slice()
|
|
16
|
+
.reverse()
|
|
17
|
+
.find((item) => !(v % item.value));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function ({ value = 60000, onChange }) {
|
|
21
|
+
const option = getNumberOption(value);
|
|
22
|
+
const quantity = Math.round(value / option.value);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<fieldset
|
|
26
|
+
className={css`
|
|
27
|
+
display: flex;
|
|
28
|
+
gap: 0.5em;
|
|
29
|
+
`}
|
|
30
|
+
>
|
|
31
|
+
<InputNumber min={1} value={quantity} onChange={(v) => onChange(Math.round(v * option.value))} />
|
|
32
|
+
<Select
|
|
33
|
+
popupMatchSelectWidth={false}
|
|
34
|
+
value={option.value}
|
|
35
|
+
onChange={(unit) => onChange(Math.round(quantity * unit))}
|
|
36
|
+
>
|
|
37
|
+
{UnitOptions.map((item) => (
|
|
38
|
+
<Select.Option key={item.value} value={item.value}>
|
|
39
|
+
{lang(item.label)}
|
|
40
|
+
</Select.Option>
|
|
41
|
+
))}
|
|
42
|
+
</Select>
|
|
43
|
+
</fieldset>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { onFieldInputValueChange, onFormInitialValuesChange } from '@formily/core';
|
|
2
|
+
import { connect, mapReadPretty, observer, useForm, useFormEffects } from '@formily/react';
|
|
3
|
+
import { Tag } from 'antd';
|
|
4
|
+
import React, { useMemo, useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import { useCollectionManager, useCompile, useRecord, Variable } from '@nocobase/client';
|
|
8
|
+
|
|
9
|
+
import { NAMESPACE } from '../locale';
|
|
10
|
+
import { getCollectionFieldOptions } from '../variable';
|
|
11
|
+
|
|
12
|
+
const InternalExpression = observer(
|
|
13
|
+
(props: any) => {
|
|
14
|
+
const { onChange } = props;
|
|
15
|
+
const { values } = useForm();
|
|
16
|
+
const [collection, setCollection] = useState(values?.sourceCollection);
|
|
17
|
+
const compile = useCompile();
|
|
18
|
+
const { getCollectionFields } = useCollectionManager();
|
|
19
|
+
|
|
20
|
+
useFormEffects(() => {
|
|
21
|
+
onFormInitialValuesChange((form) => {
|
|
22
|
+
setCollection(form.values.sourceCollection);
|
|
23
|
+
});
|
|
24
|
+
onFieldInputValueChange('sourceCollection', (f) => {
|
|
25
|
+
setCollection(f.value);
|
|
26
|
+
onChange(null);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const options = getCollectionFieldOptions({ collection, compile, getCollectionFields });
|
|
31
|
+
|
|
32
|
+
return <Variable.TextArea {...props} scope={options} />;
|
|
33
|
+
},
|
|
34
|
+
{ displayName: 'InternalExpression' },
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
function Result(props) {
|
|
38
|
+
const { t } = useTranslation();
|
|
39
|
+
const values = useRecord();
|
|
40
|
+
const compile = useCompile();
|
|
41
|
+
const { getCollectionFields } = useCollectionManager();
|
|
42
|
+
const options = useMemo(
|
|
43
|
+
() => getCollectionFieldOptions({ collection: values.sourceCollection, compile, getCollectionFields }),
|
|
44
|
+
[values.sourceCollection, values.sourceCollection],
|
|
45
|
+
);
|
|
46
|
+
return props.value ? (
|
|
47
|
+
<Variable.TextArea {...props} scope={options} />
|
|
48
|
+
) : (
|
|
49
|
+
<Tag>{t('Unconfigured', { ns: NAMESPACE })}</Tag>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const DynamicExpression = connect(InternalExpression, mapReadPretty(Result));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { observer, useForm } from '@formily/react';
|
|
2
|
+
import { Select } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { useCollectionManager, useCompile } from '@nocobase/client';
|
|
6
|
+
|
|
7
|
+
function defaultFilter() {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const FieldsSelect = observer(
|
|
12
|
+
(props: any) => {
|
|
13
|
+
const { filter = defaultFilter, ...others } = props;
|
|
14
|
+
const compile = useCompile();
|
|
15
|
+
const { getCollectionFields } = useCollectionManager();
|
|
16
|
+
const { values } = useForm();
|
|
17
|
+
const fields = getCollectionFields(values?.collection);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Select
|
|
21
|
+
className="full-width"
|
|
22
|
+
popupMatchSelectWidth={false}
|
|
23
|
+
{...others}
|
|
24
|
+
options={fields.filter(filter).map((field) => ({
|
|
25
|
+
label: compile(field.uiSchema?.title),
|
|
26
|
+
value: field.name,
|
|
27
|
+
}))}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
{ displayName: 'FieldsSelect' },
|
|
32
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Variable } from '@nocobase/client';
|
|
4
|
+
|
|
5
|
+
import { useWorkflowVariableOptions } from '../variable';
|
|
6
|
+
|
|
7
|
+
export function FilterDynamicComponent({ value, onChange, renderSchemaComponent }) {
|
|
8
|
+
const scope = useWorkflowVariableOptions();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<Variable.Input value={value} onChange={onChange} scope={scope}>
|
|
12
|
+
{renderSchemaComponent()}
|
|
13
|
+
</Variable.Input>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createStyles, cx } from '@nocobase/client';
|
|
2
|
+
import { Tag } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { lang } from '../locale';
|
|
5
|
+
|
|
6
|
+
const useStyles = createStyles(({ css, token }) => {
|
|
7
|
+
return {
|
|
8
|
+
container: css`
|
|
9
|
+
margin-bottom: 1.5em;
|
|
10
|
+
padding: 1em;
|
|
11
|
+
background-color: ${token.colorFillAlter};
|
|
12
|
+
|
|
13
|
+
> *:last-child {
|
|
14
|
+
margin-bottom: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
dl {
|
|
18
|
+
display: flex;
|
|
19
|
+
|
|
20
|
+
dt {
|
|
21
|
+
color: ${token.colorText};
|
|
22
|
+
&:after {
|
|
23
|
+
content: ':';
|
|
24
|
+
margin-right: 0.5em;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
p {
|
|
30
|
+
color: ${token.colorTextDescription};
|
|
31
|
+
}
|
|
32
|
+
`,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export function NodeDescription(props) {
|
|
37
|
+
const { instruction } = props;
|
|
38
|
+
const { styles } = useStyles();
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className={cx(styles.container, props.className)}>
|
|
42
|
+
<dl>
|
|
43
|
+
<dt>{lang('Node type')}</dt>
|
|
44
|
+
<dd>
|
|
45
|
+
<Tag style={{ background: 'none' }}>{instruction.title}</Tag>
|
|
46
|
+
</dd>
|
|
47
|
+
</dl>
|
|
48
|
+
{instruction.description ? <p>{instruction.description}</p> : null}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useFieldSchema } from '@formily/react';
|
|
3
|
+
|
|
4
|
+
import { ActionContextProvider, SchemaComponent } from '@nocobase/client';
|
|
5
|
+
|
|
6
|
+
export default function ({ component = 'div', children, ...props }) {
|
|
7
|
+
const [visible, setVisible] = useState(false);
|
|
8
|
+
const fieldSchema = useFieldSchema();
|
|
9
|
+
return (
|
|
10
|
+
<ActionContextProvider value={{ visible, setVisible, fieldSchema }}>
|
|
11
|
+
{React.createElement(
|
|
12
|
+
component,
|
|
13
|
+
{
|
|
14
|
+
...props,
|
|
15
|
+
onClick() {
|
|
16
|
+
setVisible(true);
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
children,
|
|
20
|
+
)}
|
|
21
|
+
<SchemaComponent schema={fieldSchema} onlyRenderProperties />
|
|
22
|
+
</ActionContextProvider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { QuestionCircleOutlined } from '@ant-design/icons';
|
|
2
|
+
import { css, useCompile } from '@nocobase/client';
|
|
3
|
+
import { Radio, Tooltip } from 'antd';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
export interface RadioWithTooltipOption {
|
|
7
|
+
value: any;
|
|
8
|
+
label: string;
|
|
9
|
+
tooltip?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function RadioWithTooltip(props) {
|
|
13
|
+
const { options = [], ...other } = props;
|
|
14
|
+
const compile = useCompile();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Radio.Group {...other}>
|
|
18
|
+
{options.map((option) => (
|
|
19
|
+
<Radio key={option.value} value={option.value}>
|
|
20
|
+
<span
|
|
21
|
+
className={css`
|
|
22
|
+
& + .anticon {
|
|
23
|
+
margin-left: 0.25em;
|
|
24
|
+
}
|
|
25
|
+
`}
|
|
26
|
+
>
|
|
27
|
+
{compile(option.label)}
|
|
28
|
+
</span>
|
|
29
|
+
{option.tooltip && (
|
|
30
|
+
<Tooltip title={compile(option.tooltip)}>
|
|
31
|
+
<QuestionCircleOutlined style={{ color: '#666' }} />
|
|
32
|
+
</Tooltip>
|
|
33
|
+
)}
|
|
34
|
+
</Radio>
|
|
35
|
+
))}
|
|
36
|
+
</Radio.Group>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useFieldSchema } from '@formily/react';
|
|
2
|
+
import { css, SchemaInitializer } from '@nocobase/client';
|
|
3
|
+
import { parse } from '@nocobase/utils/client';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useFlowContext } from '../FlowContext';
|
|
6
|
+
|
|
7
|
+
export const ValueBlock: (() => JSX.Element) & {
|
|
8
|
+
Initializer: (props) => JSX.Element;
|
|
9
|
+
Result: (props) => JSX.Element;
|
|
10
|
+
} = () => {
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function Initializer({ node, resultTitle, insert, ...props }) {
|
|
15
|
+
return (
|
|
16
|
+
<SchemaInitializer.Item
|
|
17
|
+
{...props}
|
|
18
|
+
onClick={() => {
|
|
19
|
+
insert({
|
|
20
|
+
type: 'void',
|
|
21
|
+
name: node.id,
|
|
22
|
+
title: node.title,
|
|
23
|
+
'x-component': 'CardItem',
|
|
24
|
+
'x-component-props': {
|
|
25
|
+
title: node.title ?? `#${node.id}`,
|
|
26
|
+
},
|
|
27
|
+
'x-designer': 'SimpleDesigner',
|
|
28
|
+
properties: {
|
|
29
|
+
result: {
|
|
30
|
+
type: 'void',
|
|
31
|
+
title: resultTitle,
|
|
32
|
+
'x-component': 'ValueBlock.Result',
|
|
33
|
+
'x-component-props': {
|
|
34
|
+
// NOTE: as same format as other reference for migration of revision
|
|
35
|
+
dataSource: `{{$jobsMapByNodeId.${node.id}}}`,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function Result({ dataSource }) {
|
|
46
|
+
const field = useFieldSchema();
|
|
47
|
+
const { execution } = useFlowContext();
|
|
48
|
+
if (!execution) {
|
|
49
|
+
return field.title;
|
|
50
|
+
}
|
|
51
|
+
const result = parse(dataSource)({
|
|
52
|
+
$jobsMapByNodeId: (execution.jobs ?? []).reduce((map, job) => Object.assign(map, { [job.nodeId]: job.result }), {}),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<pre
|
|
57
|
+
className={css`
|
|
58
|
+
margin: 0;
|
|
59
|
+
`}
|
|
60
|
+
>
|
|
61
|
+
{JSON.stringify(result, null, 2)}
|
|
62
|
+
</pre>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
ValueBlock.Initializer = Initializer;
|
|
67
|
+
ValueBlock.Result = Result;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { css, i18n } from '@nocobase/client';
|
|
2
|
+
import { evaluators } from '@nocobase/evaluators/client';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
export const renderEngineReference = (key: string) => {
|
|
6
|
+
const engine = evaluators.get(key);
|
|
7
|
+
if (!engine) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return engine.link ? (
|
|
12
|
+
<>
|
|
13
|
+
<span
|
|
14
|
+
className={css`
|
|
15
|
+
&:after {
|
|
16
|
+
content: ':';
|
|
17
|
+
}
|
|
18
|
+
& + a {
|
|
19
|
+
margin-left: 0.25em;
|
|
20
|
+
}
|
|
21
|
+
`}
|
|
22
|
+
>
|
|
23
|
+
{i18n.t('Syntax references')}
|
|
24
|
+
</span>
|
|
25
|
+
<a href={engine.link} target="_blank" rel="noreferrer">
|
|
26
|
+
{engine.label}
|
|
27
|
+
</a>
|
|
28
|
+
</>
|
|
29
|
+
) : null;
|
|
30
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
CloseOutlined,
|
|
4
|
+
ClockCircleOutlined,
|
|
5
|
+
CheckOutlined,
|
|
6
|
+
MinusOutlined,
|
|
7
|
+
ExclamationOutlined,
|
|
8
|
+
} from '@ant-design/icons';
|
|
9
|
+
import { NAMESPACE } from './locale';
|
|
10
|
+
|
|
11
|
+
export const EXECUTION_STATUS = {
|
|
12
|
+
QUEUEING: null,
|
|
13
|
+
STARTED: 0,
|
|
14
|
+
RESOLVED: 1,
|
|
15
|
+
FAILED: -1,
|
|
16
|
+
ERROR: -2,
|
|
17
|
+
ABORTED: -3,
|
|
18
|
+
CANCELED: -4,
|
|
19
|
+
REJECTED: -5,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const ExecutionStatusOptions = [
|
|
23
|
+
{ value: EXECUTION_STATUS.QUEUEING, label: `{{t("Queueing", { ns: "${NAMESPACE}" })}}`, color: 'blue' },
|
|
24
|
+
{ value: EXECUTION_STATUS.STARTED, label: `{{t("On going", { ns: "${NAMESPACE}" })}}`, color: 'gold' },
|
|
25
|
+
{ value: EXECUTION_STATUS.RESOLVED, label: `{{t("Resolved", { ns: "${NAMESPACE}" })}}`, color: 'green' },
|
|
26
|
+
{ value: EXECUTION_STATUS.FAILED, label: `{{t("Failed", { ns: "${NAMESPACE}" })}}`, color: 'red' },
|
|
27
|
+
{ value: EXECUTION_STATUS.ERROR, label: `{{t("Error", { ns: "${NAMESPACE}" })}}`, color: 'red' },
|
|
28
|
+
{ value: EXECUTION_STATUS.ABORTED, label: `{{t("Aborted", { ns: "${NAMESPACE}" })}}`, color: 'red' },
|
|
29
|
+
{ value: EXECUTION_STATUS.CANCELED, label: `{{t("Canceled", { ns: "${NAMESPACE}" })}}`, color: 'volcano' },
|
|
30
|
+
{ value: EXECUTION_STATUS.REJECTED, label: `{{t("Rejected", { ns: "${NAMESPACE}" })}}`, color: 'volcano' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const ExecutionStatusOptionsMap = ExecutionStatusOptions.reduce(
|
|
34
|
+
(map, option) => Object.assign(map, { [option.value as number]: option }),
|
|
35
|
+
{},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export const JOB_STATUS = {
|
|
39
|
+
PENDING: 0,
|
|
40
|
+
RESOLVED: 1,
|
|
41
|
+
FAILED: -1,
|
|
42
|
+
ERROR: -2,
|
|
43
|
+
ABORTED: -3,
|
|
44
|
+
CANCELED: -4,
|
|
45
|
+
REJECTED: -5,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const JobStatusOptions = [
|
|
49
|
+
{
|
|
50
|
+
value: JOB_STATUS.PENDING,
|
|
51
|
+
label: `{{t("Pending", { ns: "${NAMESPACE}" })}}`,
|
|
52
|
+
color: 'gold',
|
|
53
|
+
icon: <ClockCircleOutlined />,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
value: JOB_STATUS.RESOLVED,
|
|
57
|
+
label: `{{t("Resolved", { ns: "${NAMESPACE}" })}}`,
|
|
58
|
+
color: 'green',
|
|
59
|
+
icon: <CheckOutlined />,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: JOB_STATUS.FAILED,
|
|
63
|
+
label: `{{t("Failed", { ns: "${NAMESPACE}" })}}`,
|
|
64
|
+
color: 'red',
|
|
65
|
+
icon: <ExclamationOutlined />,
|
|
66
|
+
},
|
|
67
|
+
{ value: JOB_STATUS.ERROR, label: `{{t("Error", { ns: "${NAMESPACE}" })}}`, color: 'red', icon: <CloseOutlined /> },
|
|
68
|
+
{
|
|
69
|
+
value: JOB_STATUS.ABORTED,
|
|
70
|
+
label: `{{t("Aborted", { ns: "${NAMESPACE}" })}}`,
|
|
71
|
+
color: 'red',
|
|
72
|
+
icon: <MinusOutlined rotate={90} />,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
value: JOB_STATUS.CANCELED,
|
|
76
|
+
label: `{{t("Canceled", { ns: "${NAMESPACE}" })}}`,
|
|
77
|
+
color: 'volcano',
|
|
78
|
+
icon: <MinusOutlined rotate={45} />,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: JOB_STATUS.REJECTED,
|
|
82
|
+
label: `{{t("Rejected", { ns: "${NAMESPACE}" })}}`,
|
|
83
|
+
color: 'volcano',
|
|
84
|
+
icon: <MinusOutlined />,
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
export const JobStatusOptionsMap = JobStatusOptions.reduce(
|
|
89
|
+
(map, option) => Object.assign(map, { [option.value]: option }),
|
|
90
|
+
{},
|
|
91
|
+
);
|