@nocobase/plugin-workflow-manual 1.0.0-alpha.2 → 1.0.0-alpha.4
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/dist/client/WorkflowTodo.d.ts +8 -0
- package/dist/client/WorkflowTodoBlockInitializer.d.ts +8 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +9 -0
- package/dist/client/instruction/AssigneesSelect.d.ts +8 -0
- package/dist/client/instruction/FormBlockInitializer.d.ts +8 -0
- package/dist/client/instruction/FormBlockProvider.d.ts +8 -0
- package/dist/client/instruction/ModeConfig.d.ts +8 -0
- package/dist/client/instruction/SchemaConfig.d.ts +8 -0
- package/dist/client/instruction/createManualFormBlockUISchema.d.ts +8 -0
- package/dist/client/instruction/forms/create.d.ts +8 -0
- package/dist/client/instruction/forms/custom.d.ts +8 -0
- package/dist/client/instruction/forms/update.d.ts +8 -0
- package/dist/client/instruction/index.d.ts +8 -0
- package/dist/client/instruction/utils.d.ts +8 -0
- package/dist/externalVersion.js +18 -9
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/locale/index.d.ts +8 -0
- package/dist/locale/index.js +9 -0
- package/dist/server/ManualInstruction.d.ts +8 -0
- package/dist/server/ManualInstruction.js +9 -0
- package/dist/server/Plugin.d.ts +8 -0
- package/dist/server/Plugin.js +9 -0
- package/dist/server/actions.d.ts +8 -0
- package/dist/server/actions.js +9 -0
- package/dist/server/collections/1-users_jobs.d.ts +8 -0
- package/dist/server/collections/1-users_jobs.js +9 -0
- package/dist/server/collections/2-jobs.d.ts +8 -0
- package/dist/server/collections/2-jobs.js +9 -0
- package/dist/server/collections/3-users.d.ts +8 -0
- package/dist/server/collections/3-users.js +9 -0
- package/dist/server/forms/create.d.ts +8 -0
- package/dist/server/forms/create.js +9 -0
- package/dist/server/forms/index.d.ts +8 -0
- package/dist/server/forms/index.js +9 -0
- package/dist/server/forms/update.d.ts +8 -0
- package/dist/server/forms/update.js +9 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +9 -0
- package/dist/server/migrations/20240325213145-fix-schema.d.ts +8 -0
- package/dist/server/migrations/20240325213145-fix-schema.js +9 -0
- package/package.json +2 -2
- package/src/client/WorkflowTodo.tsx +0 -647
- package/src/client/WorkflowTodoBlockInitializer.tsx +0 -32
- package/src/client/__e2e__/assignees.test.ts +0 -0
- package/src/client/__e2e__/createRecordForm.test.ts +0 -2287
- package/src/client/__e2e__/customFormBlocks.test.ts +0 -1933
- package/src/client/__e2e__/datablocks.test.ts +0 -1208
- package/src/client/__e2e__/updateRecordForm.test.ts +0 -2338
- package/src/client/__e2e__/workflowTodo.test.ts +0 -242
- package/src/client/index.ts +0 -51
- package/src/client/instruction/AssigneesSelect.tsx +0 -39
- package/src/client/instruction/FormBlockInitializer.tsx +0 -79
- package/src/client/instruction/FormBlockProvider.tsx +0 -92
- package/src/client/instruction/ModeConfig.tsx +0 -85
- package/src/client/instruction/SchemaConfig.tsx +0 -659
- package/src/client/instruction/createManualFormBlockUISchema.ts +0 -5
- package/src/client/instruction/forms/create.tsx +0 -123
- package/src/client/instruction/forms/custom.tsx +0 -439
- package/src/client/instruction/forms/update.tsx +0 -167
- package/src/client/instruction/index.tsx +0 -160
- package/src/client/instruction/utils.ts +0 -19
- package/src/index.ts +0 -2
- package/src/locale/en-US.json +0 -30
- package/src/locale/index.ts +0 -14
- package/src/locale/ko_KR.json +0 -32
- package/src/locale/zh-CN.json +0 -32
- package/src/server/ManualInstruction.ts +0 -157
- package/src/server/Plugin.ts +0 -43
- package/src/server/__tests__/assignees.test.ts +0 -153
- package/src/server/__tests__/collections/categories.ts +0 -15
- package/src/server/__tests__/collections/comments.ts +0 -24
- package/src/server/__tests__/collections/posts.ts +0 -40
- package/src/server/__tests__/collections/replies.ts +0 -9
- package/src/server/__tests__/collections/tags.ts +0 -15
- package/src/server/__tests__/data-source.test.ts +0 -223
- package/src/server/__tests__/form.test.ts +0 -637
- package/src/server/__tests__/mode.test.ts +0 -561
- package/src/server/actions.ts +0 -103
- package/src/server/collections/1-users_jobs.ts +0 -52
- package/src/server/collections/2-jobs.ts +0 -19
- package/src/server/collections/3-users.ts +0 -17
- package/src/server/forms/create.ts +0 -30
- package/src/server/forms/index.ts +0 -13
- package/src/server/forms/update.ts +0 -30
- package/src/server/index.ts +0 -1
- package/src/server/migrations/20240325213145-fix-schema.ts +0 -82
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流:人工处理节点",
|
|
5
5
|
"description": "Could be used for workflows which some of decisions are made by users.",
|
|
6
6
|
"description.zh-CN": "用于人工控制部分决策的流程。",
|
|
7
|
-
"version": "1.0.0-alpha.
|
|
7
|
+
"version": "1.0.0-alpha.4",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow-manual",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@nocobase/test": "1.x",
|
|
31
31
|
"@nocobase/utils": "1.x"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "7a7005ce3bddf33498580a6486c45b5d9ea64ffb",
|
|
34
34
|
"keywords": [
|
|
35
35
|
"Workflow"
|
|
36
36
|
]
|
|
@@ -1,647 +0,0 @@
|
|
|
1
|
-
import { observer, useField, useFieldSchema, useForm } from '@formily/react';
|
|
2
|
-
import { Space, Spin, Tag } from 'antd';
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
|
-
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
5
|
-
|
|
6
|
-
import { css, useCompile, usePlugin } from '@nocobase/client';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
SchemaComponent,
|
|
10
|
-
SchemaComponentContext,
|
|
11
|
-
TableBlockProvider,
|
|
12
|
-
useAPIClient,
|
|
13
|
-
useActionContext,
|
|
14
|
-
useCurrentUserContext,
|
|
15
|
-
useFormBlockContext,
|
|
16
|
-
useRecord,
|
|
17
|
-
useTableBlockContext,
|
|
18
|
-
ExtendCollectionsProvider,
|
|
19
|
-
} from '@nocobase/client';
|
|
20
|
-
import WorkflowPlugin, {
|
|
21
|
-
FlowContext,
|
|
22
|
-
JobStatusOptions,
|
|
23
|
-
JobStatusOptionsMap,
|
|
24
|
-
linkNodes,
|
|
25
|
-
useAvailableUpstreams,
|
|
26
|
-
useFlowContext,
|
|
27
|
-
DetailsBlockProvider,
|
|
28
|
-
} from '@nocobase/plugin-workflow/client';
|
|
29
|
-
|
|
30
|
-
import { NAMESPACE, useLang } from '../locale';
|
|
31
|
-
import { FormBlockProvider } from './instruction/FormBlockProvider';
|
|
32
|
-
import { ManualFormType, manualFormTypes } from './instruction/SchemaConfig';
|
|
33
|
-
|
|
34
|
-
const nodeCollection = {
|
|
35
|
-
title: `{{t("Task", { ns: "${NAMESPACE}" })}}`,
|
|
36
|
-
name: 'flow_nodes',
|
|
37
|
-
fields: [
|
|
38
|
-
{
|
|
39
|
-
type: 'bigInt',
|
|
40
|
-
name: 'id',
|
|
41
|
-
interface: 'm2o',
|
|
42
|
-
uiSchema: {
|
|
43
|
-
type: 'number',
|
|
44
|
-
title: 'ID',
|
|
45
|
-
'x-component': 'RemoteSelect',
|
|
46
|
-
'x-component-props': {
|
|
47
|
-
fieldNames: {
|
|
48
|
-
label: 'title',
|
|
49
|
-
value: 'id',
|
|
50
|
-
},
|
|
51
|
-
service: {
|
|
52
|
-
resource: 'flow_nodes',
|
|
53
|
-
params: {
|
|
54
|
-
filter: {
|
|
55
|
-
type: 'manual',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
type: 'string',
|
|
64
|
-
name: 'title',
|
|
65
|
-
interface: 'input',
|
|
66
|
-
uiSchema: {
|
|
67
|
-
type: 'string',
|
|
68
|
-
title: '{{t("Title")}}',
|
|
69
|
-
'x-component': 'Input',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const workflowCollection = {
|
|
76
|
-
title: `{{t("Workflow", { ns: "${NAMESPACE}" })}}`,
|
|
77
|
-
name: 'workflows',
|
|
78
|
-
fields: [
|
|
79
|
-
{
|
|
80
|
-
type: 'string',
|
|
81
|
-
name: 'title',
|
|
82
|
-
interface: 'input',
|
|
83
|
-
uiSchema: {
|
|
84
|
-
title: '{{t("Name")}}',
|
|
85
|
-
type: 'string',
|
|
86
|
-
'x-component': 'Input',
|
|
87
|
-
required: true,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const todoCollection = {
|
|
94
|
-
title: `{{t("Workflow todos", { ns: "${NAMESPACE}" })}}`,
|
|
95
|
-
name: 'users_jobs',
|
|
96
|
-
fields: [
|
|
97
|
-
{
|
|
98
|
-
type: 'belongsTo',
|
|
99
|
-
name: 'user',
|
|
100
|
-
target: 'users',
|
|
101
|
-
foreignKey: 'userId',
|
|
102
|
-
interface: 'm2o',
|
|
103
|
-
uiSchema: {
|
|
104
|
-
type: 'number',
|
|
105
|
-
title: '{{t("User")}}',
|
|
106
|
-
'x-component': 'RemoteSelect',
|
|
107
|
-
'x-component-props': {
|
|
108
|
-
fieldNames: {
|
|
109
|
-
label: 'nickname',
|
|
110
|
-
value: 'id',
|
|
111
|
-
},
|
|
112
|
-
service: {
|
|
113
|
-
resource: 'users',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
type: 'belongsTo',
|
|
120
|
-
name: 'node',
|
|
121
|
-
target: 'flow_nodes',
|
|
122
|
-
foreignKey: 'nodeId',
|
|
123
|
-
interface: 'm2o',
|
|
124
|
-
isAssociation: true,
|
|
125
|
-
uiSchema: {
|
|
126
|
-
type: 'number',
|
|
127
|
-
title: `{{t("Task", { ns: "${NAMESPACE}" })}}`,
|
|
128
|
-
'x-component': 'RemoteSelect',
|
|
129
|
-
'x-component-props': {
|
|
130
|
-
fieldNames: {
|
|
131
|
-
label: 'title',
|
|
132
|
-
value: 'id',
|
|
133
|
-
},
|
|
134
|
-
service: {
|
|
135
|
-
resource: 'flow_nodes',
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
type: 'belongsTo',
|
|
142
|
-
name: 'workflow',
|
|
143
|
-
target: 'workflows',
|
|
144
|
-
foreignKey: 'workflowId',
|
|
145
|
-
interface: 'm2o',
|
|
146
|
-
uiSchema: {
|
|
147
|
-
type: 'number',
|
|
148
|
-
title: `{{t("Workflow", { ns: "${NAMESPACE}" })}}`,
|
|
149
|
-
'x-component': 'RemoteSelect',
|
|
150
|
-
'x-component-props': {
|
|
151
|
-
fieldNames: {
|
|
152
|
-
label: 'title',
|
|
153
|
-
value: 'id',
|
|
154
|
-
},
|
|
155
|
-
service: {
|
|
156
|
-
resource: 'workflows',
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
type: 'integer',
|
|
163
|
-
name: 'status',
|
|
164
|
-
interface: 'select',
|
|
165
|
-
uiSchema: {
|
|
166
|
-
type: 'number',
|
|
167
|
-
title: `{{t("Status", { ns: "${NAMESPACE}" })}}`,
|
|
168
|
-
'x-component': 'Select',
|
|
169
|
-
enum: JobStatusOptions,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: 'createdAt',
|
|
174
|
-
type: 'date',
|
|
175
|
-
interface: 'createdAt',
|
|
176
|
-
uiSchema: {
|
|
177
|
-
type: 'datetime',
|
|
178
|
-
title: '{{t("Created at")}}',
|
|
179
|
-
'x-component': 'DatePicker',
|
|
180
|
-
'x-component-props': {
|
|
181
|
-
showTime: true,
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const NodeColumn = observer(
|
|
189
|
-
() => {
|
|
190
|
-
const field = useField<any>();
|
|
191
|
-
return field?.value?.title ?? `#${field.value?.id}`;
|
|
192
|
-
},
|
|
193
|
-
{ displayName: 'NodeColumn' },
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
const WorkflowColumn = observer(
|
|
197
|
-
() => {
|
|
198
|
-
const field = useField<any>();
|
|
199
|
-
return field?.value?.title ?? `#${field.value?.id}`;
|
|
200
|
-
},
|
|
201
|
-
{ displayName: 'WorkflowColumn' },
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
const UserColumn = observer(
|
|
205
|
-
() => {
|
|
206
|
-
const field = useField<any>();
|
|
207
|
-
return field?.value?.nickname ?? field.value?.id;
|
|
208
|
-
},
|
|
209
|
-
{ displayName: 'UserColumn' },
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
function UserJobStatusColumn(props) {
|
|
213
|
-
const record = useRecord();
|
|
214
|
-
const labelUnprocessed = useLang('Unprocessed');
|
|
215
|
-
if (record.execution.status && !record.status) {
|
|
216
|
-
return <Tag>{labelUnprocessed}</Tag>;
|
|
217
|
-
}
|
|
218
|
-
return props.children;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC } = () => {
|
|
222
|
-
return (
|
|
223
|
-
<SchemaComponent
|
|
224
|
-
components={{
|
|
225
|
-
NodeColumn,
|
|
226
|
-
WorkflowColumn,
|
|
227
|
-
UserColumn,
|
|
228
|
-
UserJobStatusColumn,
|
|
229
|
-
}}
|
|
230
|
-
schema={{
|
|
231
|
-
type: 'void',
|
|
232
|
-
properties: {
|
|
233
|
-
actions: {
|
|
234
|
-
type: 'void',
|
|
235
|
-
'x-component': 'ActionBar',
|
|
236
|
-
'x-component-props': {
|
|
237
|
-
style: {
|
|
238
|
-
marginBottom: 16,
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
properties: {
|
|
242
|
-
filter: {
|
|
243
|
-
type: 'void',
|
|
244
|
-
title: '{{ t("Filter") }}',
|
|
245
|
-
'x-action': 'filter',
|
|
246
|
-
'x-designer': 'Filter.Action.Designer',
|
|
247
|
-
'x-component': 'Filter.Action',
|
|
248
|
-
'x-use-component-props': 'useFilterActionProps',
|
|
249
|
-
'x-component-props': {
|
|
250
|
-
icon: 'FilterOutlined',
|
|
251
|
-
},
|
|
252
|
-
'x-align': 'left',
|
|
253
|
-
},
|
|
254
|
-
refresher: {
|
|
255
|
-
type: 'void',
|
|
256
|
-
title: '{{ t("Refresh") }}',
|
|
257
|
-
'x-action': 'refresh',
|
|
258
|
-
'x-component': 'Action',
|
|
259
|
-
'x-use-component-props': 'useRefreshActionProps',
|
|
260
|
-
// 'x-designer': 'Action.Designer',
|
|
261
|
-
'x-toolbar': 'ActionSchemaToolbar',
|
|
262
|
-
'x-settings': 'actionSettings:refresh',
|
|
263
|
-
'x-component-props': {
|
|
264
|
-
icon: 'ReloadOutlined',
|
|
265
|
-
},
|
|
266
|
-
'x-align': 'right',
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
table: {
|
|
271
|
-
type: 'array',
|
|
272
|
-
'x-component': 'TableV2',
|
|
273
|
-
'x-use-component-props': 'useTableBlockProps',
|
|
274
|
-
'x-component-props': {
|
|
275
|
-
rowKey: 'id',
|
|
276
|
-
},
|
|
277
|
-
properties: {
|
|
278
|
-
actions: {
|
|
279
|
-
type: 'void',
|
|
280
|
-
'x-decorator': 'TableV2.Column.Decorator',
|
|
281
|
-
'x-component': 'TableV2.Column',
|
|
282
|
-
'x-component-props': {
|
|
283
|
-
width: 60,
|
|
284
|
-
},
|
|
285
|
-
title: '{{t("Actions")}}',
|
|
286
|
-
properties: {
|
|
287
|
-
view: {
|
|
288
|
-
type: 'void',
|
|
289
|
-
'x-component': 'Action.Link',
|
|
290
|
-
title: '{{t("View")}}',
|
|
291
|
-
properties: {
|
|
292
|
-
drawer: {
|
|
293
|
-
'x-component': 'WorkflowTodo.Drawer',
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
node: {
|
|
300
|
-
type: 'void',
|
|
301
|
-
'x-decorator': 'TableV2.Column.Decorator',
|
|
302
|
-
'x-component': 'TableV2.Column',
|
|
303
|
-
'x-component-props': {
|
|
304
|
-
width: null,
|
|
305
|
-
},
|
|
306
|
-
title: `{{t("Task node", { ns: "${NAMESPACE}" })}}`,
|
|
307
|
-
properties: {
|
|
308
|
-
node: {
|
|
309
|
-
'x-component': 'NodeColumn',
|
|
310
|
-
'x-read-pretty': true,
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
},
|
|
314
|
-
workflow: {
|
|
315
|
-
type: 'void',
|
|
316
|
-
'x-decorator': 'TableV2.Column.Decorator',
|
|
317
|
-
'x-component': 'TableV2.Column',
|
|
318
|
-
'x-component-props': {
|
|
319
|
-
width: null,
|
|
320
|
-
},
|
|
321
|
-
title: `{{t("Workflow", { ns: "workflow" })}}`,
|
|
322
|
-
properties: {
|
|
323
|
-
workflow: {
|
|
324
|
-
'x-component': 'WorkflowColumn',
|
|
325
|
-
'x-read-pretty': true,
|
|
326
|
-
},
|
|
327
|
-
},
|
|
328
|
-
},
|
|
329
|
-
status: {
|
|
330
|
-
type: 'void',
|
|
331
|
-
'x-decorator': 'TableV2.Column.Decorator',
|
|
332
|
-
'x-component': 'TableV2.Column',
|
|
333
|
-
'x-component-props': {
|
|
334
|
-
width: 100,
|
|
335
|
-
},
|
|
336
|
-
title: `{{t("Status", { ns: "workflow" })}}`,
|
|
337
|
-
properties: {
|
|
338
|
-
status: {
|
|
339
|
-
type: 'number',
|
|
340
|
-
'x-decorator': 'UserJobStatusColumn',
|
|
341
|
-
'x-component': 'CollectionField',
|
|
342
|
-
'x-read-pretty': true,
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
user: {
|
|
347
|
-
type: 'void',
|
|
348
|
-
'x-decorator': 'TableV2.Column.Decorator',
|
|
349
|
-
'x-component': 'TableV2.Column',
|
|
350
|
-
'x-component-props': {
|
|
351
|
-
width: 140,
|
|
352
|
-
},
|
|
353
|
-
title: `{{t("Assignee", { ns: "${NAMESPACE}" })}}`,
|
|
354
|
-
properties: {
|
|
355
|
-
user: {
|
|
356
|
-
'x-component': 'UserColumn',
|
|
357
|
-
'x-read-pretty': true,
|
|
358
|
-
},
|
|
359
|
-
},
|
|
360
|
-
},
|
|
361
|
-
createdAt: {
|
|
362
|
-
type: 'void',
|
|
363
|
-
'x-decorator': 'TableV2.Column.Decorator',
|
|
364
|
-
'x-component': 'TableV2.Column',
|
|
365
|
-
'x-component-props': {
|
|
366
|
-
width: 160,
|
|
367
|
-
},
|
|
368
|
-
properties: {
|
|
369
|
-
createdAt: {
|
|
370
|
-
type: 'string',
|
|
371
|
-
'x-component': 'CollectionField',
|
|
372
|
-
'x-read-pretty': true,
|
|
373
|
-
},
|
|
374
|
-
},
|
|
375
|
-
},
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
}}
|
|
380
|
-
/>
|
|
381
|
-
);
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
function ActionBarProvider(props) {
|
|
385
|
-
// * status is done:
|
|
386
|
-
// 1. form is this form: show action button, and emphasis used status button
|
|
387
|
-
// 2. form is not this form: hide action bar
|
|
388
|
-
// * status is not done:
|
|
389
|
-
// 1. current user: show action bar
|
|
390
|
-
// 2. not current user: disabled action bar
|
|
391
|
-
|
|
392
|
-
const { data: user } = useCurrentUserContext();
|
|
393
|
-
const { userJob } = useFlowContext();
|
|
394
|
-
const { status, result, userId } = userJob;
|
|
395
|
-
const buttonSchema = useFieldSchema();
|
|
396
|
-
const { name } = buttonSchema.parent.toJSON();
|
|
397
|
-
|
|
398
|
-
let { children: content } = props;
|
|
399
|
-
if (status) {
|
|
400
|
-
if (!result[name]) {
|
|
401
|
-
content = null;
|
|
402
|
-
}
|
|
403
|
-
} else {
|
|
404
|
-
if (user?.data?.id !== userId) {
|
|
405
|
-
content = null;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return content;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
const ManualActionStatusContext = createContext<number | null>(null);
|
|
413
|
-
ManualActionStatusContext.displayName = 'ManualActionStatusContext';
|
|
414
|
-
|
|
415
|
-
function ManualActionStatusProvider({ value, children }) {
|
|
416
|
-
const { userJob, execution } = useFlowContext();
|
|
417
|
-
const button = useField();
|
|
418
|
-
const buttonSchema = useFieldSchema();
|
|
419
|
-
|
|
420
|
-
useEffect(() => {
|
|
421
|
-
if (execution.status || userJob.status) {
|
|
422
|
-
button.disabled = true;
|
|
423
|
-
button.visible = userJob.status === value && userJob.result._ === buttonSchema.name;
|
|
424
|
-
}
|
|
425
|
-
}, [execution, userJob, value, button, buttonSchema.name]);
|
|
426
|
-
|
|
427
|
-
return <ManualActionStatusContext.Provider value={value}>{children}</ManualActionStatusContext.Provider>;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function useSubmit() {
|
|
431
|
-
const api = useAPIClient();
|
|
432
|
-
const { setVisible } = useActionContext();
|
|
433
|
-
const { values, submit } = useForm();
|
|
434
|
-
const buttonSchema = useFieldSchema();
|
|
435
|
-
const { service } = useTableBlockContext();
|
|
436
|
-
const { userJob, execution } = useFlowContext();
|
|
437
|
-
const { name: actionKey } = buttonSchema;
|
|
438
|
-
const { name: formKey } = buttonSchema.parent.parent;
|
|
439
|
-
return {
|
|
440
|
-
async run() {
|
|
441
|
-
if (execution.status || userJob.status) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
await submit();
|
|
445
|
-
await api.resource('users_jobs').submit({
|
|
446
|
-
filterByTk: userJob.id,
|
|
447
|
-
values: {
|
|
448
|
-
result: { [formKey]: values, _: actionKey },
|
|
449
|
-
},
|
|
450
|
-
});
|
|
451
|
-
setVisible(false);
|
|
452
|
-
service.refresh();
|
|
453
|
-
},
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
function FlowContextProvider(props) {
|
|
458
|
-
const workflowPlugin = usePlugin(WorkflowPlugin);
|
|
459
|
-
const api = useAPIClient();
|
|
460
|
-
const { id } = useRecord();
|
|
461
|
-
const [flowContext, setFlowContext] = useState<any>(null);
|
|
462
|
-
const [node, setNode] = useState<any>(null);
|
|
463
|
-
|
|
464
|
-
useEffect(() => {
|
|
465
|
-
if (!id) {
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
api
|
|
469
|
-
.resource('users_jobs')
|
|
470
|
-
.get?.({
|
|
471
|
-
filterByTk: id,
|
|
472
|
-
appends: ['node', 'job', 'workflow', 'workflow.nodes', 'execution', 'execution.jobs'],
|
|
473
|
-
})
|
|
474
|
-
.then(({ data }) => {
|
|
475
|
-
const { node, workflow: { nodes = [], ...workflow } = {}, execution, ...userJob } = data?.data ?? {};
|
|
476
|
-
linkNodes(nodes);
|
|
477
|
-
setNode(node);
|
|
478
|
-
setFlowContext({
|
|
479
|
-
userJob,
|
|
480
|
-
workflow,
|
|
481
|
-
nodes,
|
|
482
|
-
execution,
|
|
483
|
-
});
|
|
484
|
-
return;
|
|
485
|
-
});
|
|
486
|
-
}, [api, id]);
|
|
487
|
-
|
|
488
|
-
const upstreams = useAvailableUpstreams(flowContext?.nodes.find((item) => item.id === node.id));
|
|
489
|
-
const nodeComponents = upstreams.reduce(
|
|
490
|
-
(components, { type }) => Object.assign(components, workflowPlugin.instructions.get(type).components),
|
|
491
|
-
{},
|
|
492
|
-
);
|
|
493
|
-
|
|
494
|
-
return node && flowContext ? (
|
|
495
|
-
<FlowContext.Provider value={flowContext}>
|
|
496
|
-
<SchemaComponent
|
|
497
|
-
components={{
|
|
498
|
-
FormBlockProvider,
|
|
499
|
-
DetailsBlockProvider,
|
|
500
|
-
ActionBarProvider,
|
|
501
|
-
ManualActionStatusProvider,
|
|
502
|
-
// @ts-ignore
|
|
503
|
-
...Array.from(manualFormTypes.getValues()).reduce(
|
|
504
|
-
(result, item: ManualFormType) => Object.assign(result, item.block.components),
|
|
505
|
-
{},
|
|
506
|
-
),
|
|
507
|
-
...nodeComponents,
|
|
508
|
-
}}
|
|
509
|
-
scope={{
|
|
510
|
-
useSubmit,
|
|
511
|
-
useFormBlockProps,
|
|
512
|
-
useDetailsBlockProps,
|
|
513
|
-
// @ts-ignore
|
|
514
|
-
...Array.from(manualFormTypes.getValues()).reduce(
|
|
515
|
-
(result, item: ManualFormType) => Object.assign(result, item.block.scope),
|
|
516
|
-
{},
|
|
517
|
-
),
|
|
518
|
-
}}
|
|
519
|
-
schema={{
|
|
520
|
-
type: 'void',
|
|
521
|
-
name: 'tabs',
|
|
522
|
-
'x-component': 'Tabs',
|
|
523
|
-
properties: node.config?.schema,
|
|
524
|
-
}}
|
|
525
|
-
/>
|
|
526
|
-
</FlowContext.Provider>
|
|
527
|
-
) : (
|
|
528
|
-
<Spin />
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
function useFormBlockProps() {
|
|
533
|
-
const { userJob, execution } = useFlowContext();
|
|
534
|
-
const record = useRecord();
|
|
535
|
-
const { data: user } = useCurrentUserContext();
|
|
536
|
-
const { form } = useFormBlockContext();
|
|
537
|
-
|
|
538
|
-
const pattern =
|
|
539
|
-
execution.status || userJob.status
|
|
540
|
-
? record
|
|
541
|
-
? 'readPretty'
|
|
542
|
-
: 'disabled'
|
|
543
|
-
: user?.data?.id !== userJob.userId
|
|
544
|
-
? 'disabled'
|
|
545
|
-
: 'editable';
|
|
546
|
-
|
|
547
|
-
useEffect(() => {
|
|
548
|
-
form?.setPattern(pattern);
|
|
549
|
-
}, [pattern, form]);
|
|
550
|
-
|
|
551
|
-
return { form };
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
function useDetailsBlockProps() {
|
|
555
|
-
const { form } = useFormBlockContext();
|
|
556
|
-
return { form };
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
function FooterStatus() {
|
|
560
|
-
const compile = useCompile();
|
|
561
|
-
const { status, updatedAt } = useRecord();
|
|
562
|
-
const statusOption = JobStatusOptionsMap[status];
|
|
563
|
-
return status ? (
|
|
564
|
-
<Space>
|
|
565
|
-
<time
|
|
566
|
-
className={css`
|
|
567
|
-
margin-right: 0.5em;
|
|
568
|
-
`}
|
|
569
|
-
>
|
|
570
|
-
{dayjs(updatedAt).format('YYYY-MM-DD HH:mm:ss')}
|
|
571
|
-
</time>
|
|
572
|
-
<Tag icon={statusOption.icon} color={statusOption.color}>
|
|
573
|
-
{compile(statusOption.label)}
|
|
574
|
-
</Tag>
|
|
575
|
-
</Space>
|
|
576
|
-
) : null;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
function Drawer() {
|
|
580
|
-
const ctx = useContext(SchemaComponentContext);
|
|
581
|
-
const { id, node, workflow, status } = useRecord();
|
|
582
|
-
|
|
583
|
-
return (
|
|
584
|
-
<SchemaComponentContext.Provider value={{ ...ctx, reset() {}, designable: false }}>
|
|
585
|
-
<SchemaComponent
|
|
586
|
-
components={{
|
|
587
|
-
FooterStatus,
|
|
588
|
-
FlowContextProvider,
|
|
589
|
-
}}
|
|
590
|
-
schema={{
|
|
591
|
-
type: 'void',
|
|
592
|
-
name: `drawer-${id}-${status}`,
|
|
593
|
-
'x-component': 'Action.Drawer',
|
|
594
|
-
'x-component-props': {
|
|
595
|
-
className: 'nb-action-popup',
|
|
596
|
-
},
|
|
597
|
-
title: `${workflow.title} - ${node.title ?? `#${node.id}`}`,
|
|
598
|
-
properties: {
|
|
599
|
-
tabs: {
|
|
600
|
-
type: 'void',
|
|
601
|
-
'x-component': 'FlowContextProvider',
|
|
602
|
-
},
|
|
603
|
-
footer: {
|
|
604
|
-
type: 'void',
|
|
605
|
-
'x-component': 'Action.Drawer.Footer',
|
|
606
|
-
properties: {
|
|
607
|
-
content: {
|
|
608
|
-
type: 'void',
|
|
609
|
-
'x-component': 'FooterStatus',
|
|
610
|
-
},
|
|
611
|
-
},
|
|
612
|
-
},
|
|
613
|
-
},
|
|
614
|
-
}}
|
|
615
|
-
/>
|
|
616
|
-
</SchemaComponentContext.Provider>
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
function Decorator({ params = {}, children }) {
|
|
621
|
-
const blockProps = {
|
|
622
|
-
collection: 'users_jobs',
|
|
623
|
-
resource: 'users_jobs',
|
|
624
|
-
action: 'list',
|
|
625
|
-
params: {
|
|
626
|
-
pageSize: 20,
|
|
627
|
-
sort: ['-createdAt'],
|
|
628
|
-
...params,
|
|
629
|
-
appends: ['user', 'node', 'workflow', 'execution.status'],
|
|
630
|
-
except: ['node.config', 'workflow.config', 'workflow.options'],
|
|
631
|
-
},
|
|
632
|
-
rowKey: 'id',
|
|
633
|
-
showIndex: true,
|
|
634
|
-
dragSort: false,
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
return (
|
|
638
|
-
<ExtendCollectionsProvider collections={[nodeCollection, workflowCollection, todoCollection]}>
|
|
639
|
-
<TableBlockProvider name="workflow-todo" {...blockProps}>
|
|
640
|
-
{children}
|
|
641
|
-
</TableBlockProvider>
|
|
642
|
-
</ExtendCollectionsProvider>
|
|
643
|
-
);
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
WorkflowTodo.Drawer = Drawer;
|
|
647
|
-
WorkflowTodo.Decorator = Decorator;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { TableOutlined } from '@ant-design/icons';
|
|
2
|
-
import React, { FC } from 'react';
|
|
3
|
-
|
|
4
|
-
import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@nocobase/client';
|
|
5
|
-
|
|
6
|
-
export const WorkflowTodoBlockInitializer: FC<any> = () => {
|
|
7
|
-
const itemConfig = useSchemaInitializerItem();
|
|
8
|
-
const { insert } = useSchemaInitializer();
|
|
9
|
-
return (
|
|
10
|
-
<SchemaInitializerItem
|
|
11
|
-
icon={<TableOutlined />}
|
|
12
|
-
{...itemConfig}
|
|
13
|
-
onClick={() => {
|
|
14
|
-
insert({
|
|
15
|
-
type: 'void',
|
|
16
|
-
'x-decorator': 'WorkflowTodo.Decorator',
|
|
17
|
-
'x-decorator-props': {},
|
|
18
|
-
'x-component': 'CardItem',
|
|
19
|
-
// 'x-designer': 'TableBlockDesigner',
|
|
20
|
-
'x-toolbar': 'BlockSchemaToolbar',
|
|
21
|
-
'x-settings': 'blockSettings:table',
|
|
22
|
-
properties: {
|
|
23
|
-
todos: {
|
|
24
|
-
type: 'void',
|
|
25
|
-
'x-component': 'WorkflowTodo',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
File without changes
|