Skip to content

Commit cbdda44

Browse files
authored
[elsa] 并行节点特性添加 (#114)
* [elsa] 提交并行节点代码框架 * [elsa] 并行节点特性添加 * [elsa] 检视意见修改
1 parent 9db5b06 commit cbdda44

24 files changed

+815
-59
lines changed

framework/elsa/fit-elsa-react/src/common/Consts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export const RENDER_TYPE = {
191191
LABEL: 'Label',
192192
};
193193

194-
export const DEFAULT_LOOP_NODE_CONTEXT = {
194+
export const DEFAULT_ADD_TOOL_NODE_CONTEXT = {
195195
id: uuidv4(),
196196
name: 'context',
197197
type: DATA_TYPES.OBJECT,
Lines changed: 22 additions & 0 deletions
Loading

framework/elsa/fit-elsa-react/src/components/common/InvokeInput.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {JadeInputTree} from '@/components/common/JadeInputTree.jsx';
1313

1414
_InvokeInput.propTypes = {
1515
inputData: PropTypes.array,
16-
shapeStatus: PropTypes.object
16+
shapeStatus: PropTypes.object,
17+
parentId: PropTypes.string,
1718
}
1819

1920
/**
@@ -25,9 +26,10 @@ _InvokeInput.propTypes = {
2526
* @param radioValue Radio对应的值.
2627
* @param radioTitle Radio对应的展示信息.
2728
* @param radioRuleMessage Radio没填时的报错信息.
29+
* @param parentId 输入入参上层所属id,非必填.
2830
* @returns {JSX.Element}
2931
*/
30-
function _InvokeInput({inputData, shapeStatus, showRadio = false, radioValue, radioTitle, radioRuleMessage}) {
32+
function _InvokeInput({inputData, shapeStatus, showRadio = false, radioValue, radioTitle, radioRuleMessage, parentId}) {
3133
const dispatch = useDispatch();
3234

3335
/**
@@ -37,7 +39,7 @@ function _InvokeInput({inputData, shapeStatus, showRadio = false, radioValue, ra
3739
* @param changes 需要改变的属性.
3840
*/
3941
const updateItem = (id, changes) => {
40-
dispatch({type: 'update', id, changes});
42+
dispatch({type: 'update', id, changes, parentId});
4143
};
4244

4345
/**

framework/elsa/fit-elsa-react/src/components/common/JadeInputTreeCollapse.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ JadeInputTreeCollapse.propTypes = {
2222
*
2323
* @param data 数据.
2424
* @param children 子组件列表.
25+
* @param props 参数。
2526
* @return {JSX.Element}
2627
* @constructor
2728
*/
28-
export default function JadeInputTreeCollapse({data, children}) {
29+
export default function JadeInputTreeCollapse({data, children, ...props}) {
2930
const { t } = useTranslation();
3031

3132
const getContent = () => {
@@ -50,7 +51,7 @@ export default function JadeInputTreeCollapse({data, children}) {
5051
const content = getContent();
5152

5253
return (<>
53-
<JadeCollapse defaultActiveKey={['jadeInputTreePanel']}>
54+
<JadeCollapse defaultActiveKey={['jadeInputTreePanel']} {...props}>
5455
<Panel
5556
key={'jadeInputTreePanel'}
5657
header={

framework/elsa/fit-elsa-react/src/components/loopNode/LoopConsts.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the MIT License. See License.txt in the project root for license information.
55
*--------------------------------------------------------------------------------------------*/
66

7-
import {DATA_TYPES, FROM_TYPE} from '@/common/Consts.js';
7+
import {DATA_TYPES, DEFAULT_ADD_TOOL_NODE_CONTEXT, FROM_TYPE} from '@/common/Consts.js';
88
import {v4 as uuidv4} from 'uuid';
99

1010
export const DEFAULT_INPUT_PARAMS = [
@@ -29,4 +29,5 @@ export const DEFAULT_INPUT_PARAMS = [
2929
from: FROM_TYPE.INPUT,
3030
value: {},
3131
},
32+
DEFAULT_ADD_TOOL_NODE_CONTEXT
3233
];

framework/elsa/fit-elsa-react/src/components/loopNode/LoopWrapper.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {InvokeOutput} from '@/components/common/InvokeOutput.jsx';
99
import {SkillForm} from '@/components/loopNode/SkillForm.jsx';
1010
import {useDataContext, useDispatch} from '@/components/DefaultRoot.jsx';
1111
import {TOOL_TYPE} from '@/common/Consts.js';
12+
import PropTypes from 'prop-types';
1213

1314
/**
1415
* 循环节点Wrapper
@@ -28,12 +29,10 @@ const LoopWrapper = ({shapeStatus}) => {
2829
const filterArgs = isWaterFlow ? args.find(arg => arg.name === 'inputParams')?.value ?? args : args;
2930
const filterRadioValue = isWaterFlow && radioValue ? radioValue.replace(/^inputParams\./, '') : radioValue;
3031

31-
32-
const handlePluginChange = (entity, returnSchema, uniqueName, name, tags) => {
32+
const handlePluginChange = (entity, uniqueName, name, tags) => {
3333
dispatch({
3434
type: 'changePluginByMetaData',
3535
entity: entity,
36-
returnSchema: returnSchema,
3736
uniqueName: uniqueName,
3837
pluginName: name,
3938
tags: tags,
@@ -60,4 +59,8 @@ const LoopWrapper = ({shapeStatus}) => {
6059
</>);
6160
};
6261

62+
LoopWrapper.propTypes = {
63+
shapeStatus: PropTypes.object,
64+
};
65+
6366
export default LoopWrapper;

framework/elsa/fit-elsa-react/src/components/loopNode/SkillForm.jsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {convertParameter, convertReturnFormat} from '@/components/util/MethodMet
1212
import {useTranslation} from 'react-i18next';
1313
import {MinusCircleOutlined} from '@ant-design/icons';
1414
import PropTypes from 'prop-types';
15+
import {recursive} from '@/components/util/ReferenceUtil.js';
1516

1617
/**
1718
* 循环节点插件折叠区域组件
@@ -51,7 +52,7 @@ const _SkillForm = ({plugin, data = undefined, handlePluginChange, handlePluginD
5152
const outputParams = convertReturnFormat(selectedData.schema.return);
5253
outputParams.type = 'Array';
5354
entity.outputParams = [outputParams];
54-
handlePluginChange(entity, selectedData.schema.return, selectedData.uniqueName, selectedData.name, selectedData.tags);
55+
handlePluginChange(entity, selectedData.uniqueName, selectedData.name, selectedData.tags);
5556
};
5657

5758
const pluginSelectEvent = {
@@ -63,17 +64,6 @@ const _SkillForm = ({plugin, data = undefined, handlePluginChange, handlePluginD
6364
},
6465
};
6566

66-
const recursive = (params, parent, action) => {
67-
params.forEach(p => {
68-
if (p.type === 'Object') {
69-
recursive(p.value, p, action);
70-
action(p, parent);
71-
} else {
72-
action(p, parent);
73-
}
74-
});
75-
};
76-
7767
const deregisterObservables = () => {
7868
if (data) {
7969
recursive(data, null, (p) => {
@@ -150,9 +140,9 @@ const _SkillForm = ({plugin, data = undefined, handlePluginChange, handlePluginD
150140
>
151141
{plugin && plugin.id && <Row key={`pluginRow-${plugin.id}`}>
152142
<div className={`jade-custom-multi-select-with-slider-div item-hover ${pluginInValid ? 'jade-error-border' : ''}`}>
153-
<span className={'jade-custom-multi-select-item'}>
154-
{plugin?.name ?? ''}
155-
</span>
143+
<span className={'jade-custom-multi-select-item'}>
144+
{plugin?.name ?? ''}
145+
</span>
156146
{renderDeleteIcon(plugin.id)}
157147
</div>
158148
</Row>}

framework/elsa/fit-elsa-react/src/components/loopNode/loopComponent.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {ChangeFlowMetaReducer} from '@/components/common/reducers/commonReducers
99
import {ChangePluginByMetaDataReducer, DeletePluginReducer, UpdateInputReducer, UpdateRadioInfoReducer} from '@/components/loopNode/reducers/reducers.js';
1010
import {defaultComponent} from '@/components/defaultComponent.js';
1111
import {v4 as uuidv4} from 'uuid';
12-
import {DATA_TYPES, DEFAULT_LOOP_NODE_CONTEXT, FROM_TYPE} from '@/common/Consts.js';
12+
import {DATA_TYPES, DEFAULT_ADD_TOOL_NODE_CONTEXT, FROM_TYPE} from '@/common/Consts.js';
1313

1414
export const loopComponent = (jadeConfig, shape) => {
1515
const self = defaultComponent(jadeConfig);
@@ -50,7 +50,7 @@ export const loopComponent = (jadeConfig, shape) => {
5050
from: FROM_TYPE.INPUT,
5151
value: {},
5252
},
53-
DEFAULT_LOOP_NODE_CONTEXT,
53+
DEFAULT_ADD_TOOL_NODE_CONTEXT,
5454
],
5555
outputParams: [],
5656
};

framework/elsa/fit-elsa-react/src/components/loopNode/reducers/reducers.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {updateInput} from '@/components/util/JadeConfigUtils.js';
88
import {DEFAULT_INPUT_PARAMS} from '@/components/loopNode/LoopConsts.js';
99
import {TOOL_TYPE} from '@/common/Consts.js';
1010

11-
export const ChangePluginByMetaDataReducer = (shape) => {
11+
export const ChangePluginByMetaDataReducer = () => {
1212
const self = {};
1313
self.type = 'changePluginByMetaData';
1414

@@ -39,19 +39,18 @@ export const ChangePluginByMetaDataReducer = (shape) => {
3939
}
4040
});
4141

42+
const updateToolInfo = (toolInfo = {}) => {
43+
return {
44+
...toolInfo,
45+
params: newConfig.inputParams?.find(param => param.name === 'args')?.value?.map(({name}) => ({name})) || [],
46+
uniqueName: action.uniqueName,
47+
return: { type: 'array' },
48+
pluginName: action.pluginName,
49+
tags: action.tags
50+
};
51+
};
4252

43-
function updateToolInfo() {
44-
newToolInfo.params = newConfig.inputParams.find(param => param.name === 'args').value.map(property => {
45-
return {name: property.name};
46-
});
47-
newToolInfo.uniqueName = action.uniqueName;
48-
newToolInfo.return = {};
49-
newToolInfo.return.type = 'array';
50-
newToolInfo.pluginName = action.pluginName;
51-
newToolInfo.tags = action.tags;
52-
}
53-
let newToolInfo = {};
54-
updateToolInfo();
53+
const newToolInfo = updateToolInfo();
5554

5655
Object.entries(newConfig).forEach(([key, value]) => {
5756
if (key === 'inputParams') {
@@ -69,12 +68,9 @@ export const ChangePluginByMetaDataReducer = (shape) => {
6968
newConfig[key] = value;
7069
}
7170
});
72-
7371
return newConfig;
7472
};
7573

76-
77-
7874
return self;
7975
};
8076

@@ -134,7 +130,6 @@ export const UpdateInputReducer = () => {
134130
newConfig[key] = value;
135131
}
136132
});
137-
138133
return newConfig;
139134
};
140135

framework/elsa/fit-elsa-react/src/components/manualCheck/ManualCheckForm.jsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {convertParameter, convertReturnFormat} from '@/components/util/MethodMet
1313
import {useTranslation} from 'react-i18next';
1414
import {EyeOutlined, MinusCircleOutlined} from '@ant-design/icons';
1515
import PropTypes from 'prop-types';
16+
import {recursive} from '@/components/util/ReferenceUtil.js';
1617

1718
/**
1819
* 人工检查节点折叠区域组件
@@ -87,17 +88,6 @@ const _ManualCheckForm = ({form, data = undefined, handleFormChange, handleFormD
8788
},
8889
};
8990

90-
const recursive = (params, parent, action) => {
91-
params.forEach(p => {
92-
if (p.type === 'Object') {
93-
recursive(p.value, p, action);
94-
action(p, parent);
95-
} else {
96-
action(p, parent);
97-
}
98-
});
99-
};
100-
10191
const deregisterObservables = () => {
10292
if (data) {
10393
recursive(data, null, (p) => {

0 commit comments

Comments
 (0)