diff --git a/packages/core/client/src/workflow/nodes/index.tsx b/packages/core/client/src/workflow/nodes/index.tsx index 257a70952..c5ab2a534 100644 --- a/packages/core/client/src/workflow/nodes/index.tsx +++ b/packages/core/client/src/workflow/nodes/index.tsx @@ -165,13 +165,14 @@ export function NodeDefaultView(props) { const { data, children } = props; const instruction = instructions.get(data.type); const detailText = workflow.executed ? '{{t("View")}}' : '{{t("Configure")}}'; + const typeText = compile(instruction.title); return (
- {compile(instruction.title)} + {typeText}

{data.title} @@ -196,7 +197,7 @@ export function NodeDefaultView(props) { properties: { drawer: { type: 'void', - title: detailText, + title: typeText, 'x-component': 'Action.Drawer', 'x-decorator': 'Form', 'x-decorator-props': { diff --git a/packages/core/client/src/workflow/triggers/index.tsx b/packages/core/client/src/workflow/triggers/index.tsx index 66c7db30f..c722a9e68 100644 --- a/packages/core/client/src/workflow/triggers/index.tsx +++ b/packages/core/client/src/workflow/triggers/index.tsx @@ -61,6 +61,7 @@ export const TriggerConfig = () => { const { type, config, executed } = data.data; const { title, fieldset, scope, components } = triggers.get(type); const detailText = executed ? '{{t("View")}}' : '{{t("Configure")}}'; + const titleText = `${t('Trigger')}: ${compile(title)}`; return (
@@ -77,7 +78,7 @@ export const TriggerConfig = () => { properties: { drawer: { type: 'void', - title: detailText, + title: titleText, 'x-component': 'Action.Drawer', 'x-decorator': 'Form', 'x-decorator-props': { diff --git a/packages/plugins/workflow/src/__tests__/instructions/update.test.ts b/packages/plugins/workflow/src/__tests__/instructions/update.test.ts index d70cb06a9..b66a357c4 100644 --- a/packages/plugins/workflow/src/__tests__/instructions/update.test.ts +++ b/packages/plugins/workflow/src/__tests__/instructions/update.test.ts @@ -33,7 +33,7 @@ describe('workflow > instructions > update', () => { describe('update one', () => { it('params: from context', async () => { - const n2 = await workflow.createNode({ + const n1 = await workflow.createNode({ type: 'update', config: { collection: 'posts', @@ -59,4 +59,42 @@ describe('workflow > instructions > update', () => { expect(updatedPost.published).toBe(true); }); }); + + it('params: from job of node', async () => { + const n1 = await workflow.createNode({ + type: 'query', + config: { + collection: 'posts', + params: { + filter: { + title: 'test' + } + } + } + }); + + const n2 = await workflow.createNode({ + type: 'update', + config: { + collection: 'posts', + params: { + filter: { + id: `{{$jobsMapByNodeId.${n1.id}.id}}` + }, + values: { + title: 'changed' + } + } + }, + upstreamId: n1.id + }); + + await n1.setDownstream(n2); + + // NOTE: the result of post immediately created will not be changed by workflow + const { id } = await PostModel.create({ title: 'test' }); + // should get from db + const post = await PostModel.findByPk(id); + expect(post.title).toBe('changed'); + }); }); diff --git a/packages/plugins/workflow/src/collections/flow_nodes.ts b/packages/plugins/workflow/src/collections/flow_nodes.ts index 77422a215..75c7151a6 100644 --- a/packages/plugins/workflow/src/collections/flow_nodes.ts +++ b/packages/plugins/workflow/src/collections/flow_nodes.ts @@ -40,7 +40,7 @@ export default { type: 'integer', title: 'branch index' }, - // for reasons: + // Note: for reasons: // 1. redirect type node to solve cycle flow. // 2. recognize as real next node after branches. { @@ -53,14 +53,7 @@ export default { interface: 'select', type: 'string', name: 'type', - title: '类型', - // TODO: data for test only now - dataSource: [ - { label: '数据处理', value: 'data' }, - { label: '数据查询', value: 'query' }, - { label: '等待人工输入', value: 'prompt' }, - { label: '条件判断', value: 'condition' }, - ] + title: '类型' }, { interface: 'json', diff --git a/packages/plugins/workflow/src/instructions/create.ts b/packages/plugins/workflow/src/instructions/create.ts index 8757ba774..93eb77754 100644 --- a/packages/plugins/workflow/src/instructions/create.ts +++ b/packages/plugins/workflow/src/instructions/create.ts @@ -16,7 +16,8 @@ export default { }); return { - result, + // NOTE: get() for non-proxied instance (#380) + result: result.get(), status: JOB_STATUS.RESOLVED }; } diff --git a/packages/plugins/workflow/src/instructions/query.ts b/packages/plugins/workflow/src/instructions/query.ts index 717422a64..d0a633925 100644 --- a/packages/plugins/workflow/src/instructions/query.ts +++ b/packages/plugins/workflow/src/instructions/query.ts @@ -13,6 +13,10 @@ export default { const options = execution.getParsedValue(params); const result = await (multiple ? repo.find : repo.findOne).call(repo, { ...options, + // NOTE: `raw` to avoid getting undefined value from Proxied model instance (#380) + // e.g. Object.prototype.hasOwnProperty.call(result, 'id') // false + // so the properties can not be get by json-templates(object-path) + raw: true, transaction: execution.tx }); diff --git a/packages/plugins/workflow/src/instructions/update.ts b/packages/plugins/workflow/src/instructions/update.ts index ccc6438c8..d49faa7c4 100644 --- a/packages/plugins/workflow/src/instructions/update.ts +++ b/packages/plugins/workflow/src/instructions/update.ts @@ -1,8 +1,9 @@ import { JOB_STATUS } from "../constants"; +import ExecutionModel from "../models/Execution"; import FlowNodeModel from "../models/FlowNode"; export default { - async run(this: FlowNodeModel, input, execution) { + async run(this: FlowNodeModel, input, execution: ExecutionModel) { const { collection, multiple = false,