@nocobase/plugin-workflow-manual 0.18.0-alpha.9 → 0.19.0-alpha.10
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/index.js +4 -4
- package/dist/client/instruction/SchemaConfig.d.ts +3 -3
- package/dist/client/instruction/forms/custom.d.ts +1 -1
- package/dist/client/instruction/index.d.ts +6 -0
- package/dist/externalVersion.js +10 -8
- package/dist/locale/ko_KR.json +32 -0
- package/dist/locale/zh-CN.json +2 -1
- package/dist/server/ManualInstruction.js +1 -0
- package/dist/server/Plugin.js +3 -7
- package/dist/server/collections/1-users_jobs.d.ts +2 -0
- package/dist/server/collections/{users_jobs.js → 1-users_jobs.js} +7 -4
- package/dist/server/collections/2-jobs.d.ts +6 -0
- package/dist/server/collections/{jobs.js → 2-jobs.js} +3 -2
- package/dist/server/collections/3-users.d.ts +6 -0
- package/dist/server/collections/{users.js → 3-users.js} +3 -2
- package/package.json +7 -2
- package/src/client/WorkflowTodo.tsx +73 -41
- package/src/client/__e2e__/assignees.test.ts +0 -0
- package/src/client/__e2e__/createRecordForm.test.ts +2231 -0
- package/src/client/__e2e__/customFormBlocks.test.ts +1868 -0
- package/src/client/__e2e__/datablocks.test.ts +1195 -0
- package/src/client/__e2e__/updateRecordForm.test.ts +2154 -0
- package/src/client/__e2e__/workflowTodo.test.ts +233 -0
- package/src/client/index.ts +1 -2
- package/src/client/instruction/FormBlockInitializer.tsx +6 -2
- package/src/client/instruction/SchemaConfig.tsx +6 -7
- package/src/client/instruction/forms/create.tsx +4 -1
- package/src/client/instruction/forms/custom.tsx +8 -5
- package/src/client/instruction/forms/update.tsx +4 -1
- package/src/client/instruction/index.tsx +5 -2
- package/src/locale/ko_KR.json +32 -0
- package/src/locale/zh-CN.json +2 -1
- package/src/server/ManualInstruction.ts +1 -0
- package/src/server/Plugin.ts +3 -7
- package/src/server/__tests__/instruction.test.ts +5 -7
- package/src/server/collections/{users_jobs.ts → 1-users_jobs.ts} +7 -5
- package/src/server/collections/{jobs.ts → 2-jobs.ts} +4 -2
- package/src/server/collections/{users.ts → 3-users.ts} +4 -2
- package/dist/server/collections/jobs.d.ts +0 -19
- package/dist/server/collections/users.d.ts +0 -15
- package/dist/server/collections/users_jobs.d.ts +0 -3
|
@@ -31,7 +31,7 @@ import WorkflowPlugin, {
|
|
|
31
31
|
import { DetailsBlockProvider } from './instruction/DetailsBlockProvider';
|
|
32
32
|
import { FormBlockProvider } from './instruction/FormBlockProvider';
|
|
33
33
|
import { ManualFormType, manualFormTypes } from './instruction/SchemaConfig';
|
|
34
|
-
import { NAMESPACE } from '../locale';
|
|
34
|
+
import { NAMESPACE, useLang } from '../locale';
|
|
35
35
|
|
|
36
36
|
const nodeCollection = {
|
|
37
37
|
title: `{{t("Task", { ns: "${NAMESPACE}" })}}`,
|
|
@@ -211,6 +211,15 @@ const UserColumn = observer(
|
|
|
211
211
|
{ displayName: 'UserColumn' },
|
|
212
212
|
);
|
|
213
213
|
|
|
214
|
+
function UserJobStatusColumn(props) {
|
|
215
|
+
const record = useRecord();
|
|
216
|
+
const labelUnprocessed = useLang('Unprocessed');
|
|
217
|
+
if (record.execution.status && !record.status) {
|
|
218
|
+
return <Tag>{labelUnprocessed}</Tag>;
|
|
219
|
+
}
|
|
220
|
+
return props.children;
|
|
221
|
+
}
|
|
222
|
+
|
|
214
223
|
export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC } = () => {
|
|
215
224
|
return (
|
|
216
225
|
<SchemaComponent
|
|
@@ -218,6 +227,7 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
218
227
|
NodeColumn,
|
|
219
228
|
WorkflowColumn,
|
|
220
229
|
UserColumn,
|
|
230
|
+
UserJobStatusColumn,
|
|
221
231
|
}}
|
|
222
232
|
schema={{
|
|
223
233
|
type: 'void',
|
|
@@ -265,11 +275,35 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
265
275
|
useProps: '{{ useTableBlockProps }}',
|
|
266
276
|
},
|
|
267
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
|
+
},
|
|
268
299
|
node: {
|
|
269
300
|
type: 'void',
|
|
270
301
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
271
302
|
'x-component': 'TableV2.Column',
|
|
272
|
-
|
|
303
|
+
'x-component-props': {
|
|
304
|
+
width: null,
|
|
305
|
+
},
|
|
306
|
+
title: `{{t("Task node", { ns: "${NAMESPACE}" })}}`,
|
|
273
307
|
properties: {
|
|
274
308
|
node: {
|
|
275
309
|
'x-component': 'NodeColumn',
|
|
@@ -281,7 +315,10 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
281
315
|
type: 'void',
|
|
282
316
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
283
317
|
'x-component': 'TableV2.Column',
|
|
284
|
-
|
|
318
|
+
'x-component-props': {
|
|
319
|
+
width: null,
|
|
320
|
+
},
|
|
321
|
+
title: `{{t("Workflow", { ns: "workflow" })}}`,
|
|
285
322
|
properties: {
|
|
286
323
|
workflow: {
|
|
287
324
|
'x-component': 'WorkflowColumn',
|
|
@@ -289,13 +326,18 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
289
326
|
},
|
|
290
327
|
},
|
|
291
328
|
},
|
|
292
|
-
|
|
329
|
+
status: {
|
|
293
330
|
type: 'void',
|
|
294
331
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
295
332
|
'x-component': 'TableV2.Column',
|
|
333
|
+
'x-component-props': {
|
|
334
|
+
width: 100,
|
|
335
|
+
},
|
|
336
|
+
title: `{{t("Status", { ns: "workflow" })}}`,
|
|
296
337
|
properties: {
|
|
297
|
-
|
|
298
|
-
type: '
|
|
338
|
+
status: {
|
|
339
|
+
type: 'number',
|
|
340
|
+
'x-decorator': 'UserJobStatusColumn',
|
|
299
341
|
'x-component': 'CollectionField',
|
|
300
342
|
'x-read-pretty': true,
|
|
301
343
|
},
|
|
@@ -305,6 +347,9 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
305
347
|
type: 'void',
|
|
306
348
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
307
349
|
'x-component': 'TableV2.Column',
|
|
350
|
+
'x-component-props': {
|
|
351
|
+
width: 140,
|
|
352
|
+
},
|
|
308
353
|
title: `{{t("Assignee", { ns: "${NAMESPACE}" })}}`,
|
|
309
354
|
properties: {
|
|
310
355
|
user: {
|
|
@@ -313,35 +358,21 @@ export const WorkflowTodo: React.FC & { Drawer: React.FC; Decorator: React.FC }
|
|
|
313
358
|
},
|
|
314
359
|
},
|
|
315
360
|
},
|
|
316
|
-
|
|
361
|
+
createdAt: {
|
|
317
362
|
type: 'void',
|
|
318
363
|
'x-decorator': 'TableV2.Column.Decorator',
|
|
319
364
|
'x-component': 'TableV2.Column',
|
|
365
|
+
'x-component-props': {
|
|
366
|
+
width: 160,
|
|
367
|
+
},
|
|
320
368
|
properties: {
|
|
321
|
-
|
|
369
|
+
createdAt: {
|
|
370
|
+
type: 'string',
|
|
322
371
|
'x-component': 'CollectionField',
|
|
323
372
|
'x-read-pretty': true,
|
|
324
373
|
},
|
|
325
374
|
},
|
|
326
375
|
},
|
|
327
|
-
actions: {
|
|
328
|
-
type: 'void',
|
|
329
|
-
'x-decorator': 'TableV2.Column.Decorator',
|
|
330
|
-
'x-component': 'TableV2.Column',
|
|
331
|
-
title: '{{t("Actions")}}',
|
|
332
|
-
properties: {
|
|
333
|
-
view: {
|
|
334
|
-
type: 'void',
|
|
335
|
-
'x-component': 'Action.Link',
|
|
336
|
-
title: '{{t("View")}}',
|
|
337
|
-
properties: {
|
|
338
|
-
drawer: {
|
|
339
|
-
'x-component': 'WorkflowTodo.Drawer',
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
376
|
},
|
|
346
377
|
},
|
|
347
378
|
},
|
|
@@ -381,16 +412,16 @@ function ActionBarProvider(props) {
|
|
|
381
412
|
const ManualActionStatusContext = createContext<number | null>(null);
|
|
382
413
|
|
|
383
414
|
function ManualActionStatusProvider({ value, children }) {
|
|
384
|
-
const { userJob } = useFlowContext();
|
|
415
|
+
const { userJob, execution } = useFlowContext();
|
|
385
416
|
const button = useField();
|
|
386
417
|
const buttonSchema = useFieldSchema();
|
|
387
418
|
|
|
388
419
|
useEffect(() => {
|
|
389
|
-
if (userJob.status) {
|
|
420
|
+
if (execution.status || userJob.status) {
|
|
390
421
|
button.disabled = true;
|
|
391
422
|
button.visible = userJob.status === value && userJob.result._ === buttonSchema.name;
|
|
392
423
|
}
|
|
393
|
-
}, [userJob, value, button, buttonSchema.name]);
|
|
424
|
+
}, [execution, userJob, value, button, buttonSchema.name]);
|
|
394
425
|
|
|
395
426
|
return <ManualActionStatusContext.Provider value={value}>{children}</ManualActionStatusContext.Provider>;
|
|
396
427
|
}
|
|
@@ -401,12 +432,12 @@ function useSubmit() {
|
|
|
401
432
|
const { values, submit } = useForm();
|
|
402
433
|
const buttonSchema = useFieldSchema();
|
|
403
434
|
const { service } = useTableBlockContext();
|
|
404
|
-
const { userJob } = useFlowContext();
|
|
435
|
+
const { userJob, execution } = useFlowContext();
|
|
405
436
|
const { name: actionKey } = buttonSchema;
|
|
406
437
|
const { name: formKey } = buttonSchema.parent.parent;
|
|
407
438
|
return {
|
|
408
439
|
async run() {
|
|
409
|
-
if (userJob.status) {
|
|
440
|
+
if (execution.status || userJob.status) {
|
|
410
441
|
return;
|
|
411
442
|
}
|
|
412
443
|
await submit();
|
|
@@ -437,7 +468,7 @@ function FlowContextProvider(props) {
|
|
|
437
468
|
.resource('users_jobs')
|
|
438
469
|
.get?.({
|
|
439
470
|
filterByTk: id,
|
|
440
|
-
appends: ['node', 'workflow', 'workflow.nodes', 'execution', 'execution.jobs'],
|
|
471
|
+
appends: ['node', 'job', 'workflow', 'workflow.nodes', 'execution', 'execution.jobs'],
|
|
441
472
|
})
|
|
442
473
|
.then(({ data }) => {
|
|
443
474
|
const { node, workflow: { nodes = [], ...workflow } = {}, execution, ...userJob } = data?.data ?? {};
|
|
@@ -498,18 +529,19 @@ function FlowContextProvider(props) {
|
|
|
498
529
|
}
|
|
499
530
|
|
|
500
531
|
function useFormBlockProps() {
|
|
501
|
-
const { userJob } = useFlowContext();
|
|
532
|
+
const { userJob, execution } = useFlowContext();
|
|
502
533
|
const record = useRecord();
|
|
503
534
|
const { data: user } = useCurrentUserContext();
|
|
504
535
|
const { form } = useFormBlockContext();
|
|
505
536
|
|
|
506
|
-
const pattern =
|
|
507
|
-
|
|
508
|
-
?
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
537
|
+
const pattern =
|
|
538
|
+
execution.status || userJob.status
|
|
539
|
+
? record
|
|
540
|
+
? 'readPretty'
|
|
541
|
+
: 'disabled'
|
|
542
|
+
: user?.data?.id !== userJob.userId
|
|
543
|
+
? 'disabled'
|
|
544
|
+
: 'editable';
|
|
513
545
|
|
|
514
546
|
useEffect(() => {
|
|
515
547
|
form?.setPattern(pattern);
|
|
@@ -594,7 +626,7 @@ function Decorator({ params = {}, children }) {
|
|
|
594
626
|
pageSize: 20,
|
|
595
627
|
sort: ['-createdAt'],
|
|
596
628
|
...params,
|
|
597
|
-
appends: ['user', 'node', 'workflow'],
|
|
629
|
+
appends: ['user', 'node', 'workflow', 'execution.status'],
|
|
598
630
|
except: ['node.config', 'workflow.config', 'workflow.options'],
|
|
599
631
|
},
|
|
600
632
|
rowKey: 'id',
|
|
File without changes
|