mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 10:01:26 +00:00
Fix(plugin workflow): fix cannot get job result properties (#382)
* fix(plugin-workflow): card drawer title * fix(plugin-workflow): fix job result to use raw object than proxied model (#380)
This commit is contained in:
parent
9e3995ab4a
commit
2df0e46318
@ -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 (
|
||||
<div className={cx(nodeClass, `workflow-node-type-${data.type}`)}>
|
||||
<div className={cx(nodeCardClass)}>
|
||||
<div className={cx(nodeHeaderClass)}>
|
||||
<div className={cx(nodeMetaClass)}>
|
||||
<Tag>{compile(instruction.title)}</Tag>
|
||||
<Tag>{typeText}</Tag>
|
||||
</div>
|
||||
<h4 className={cx(nodeTitleClass)}>
|
||||
<strong>{data.title}</strong>
|
||||
@ -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': {
|
||||
|
@ -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 (
|
||||
<div className={cx(nodeCardClass)}>
|
||||
@ -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': {
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
@ -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',
|
||||
|
@ -16,7 +16,8 @@ export default {
|
||||
});
|
||||
|
||||
return {
|
||||
result,
|
||||
// NOTE: get() for non-proxied instance (#380)
|
||||
result: result.get(),
|
||||
status: JOB_STATUS.RESOLVED
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
});
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user