Skip to content

Commit 1a1186b

Browse files
authored
[elsa] Add variable update node. (#238)
* [elsa] Add variable update node. * [elsa] VariableUpdateNode not allow reference systemEnv. Because systemEnv variable cannot be modified.
1 parent f76ae46 commit 1a1186b

File tree

16 files changed

+690
-19
lines changed

16 files changed

+690
-19
lines changed
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 15 additions & 0 deletions
Loading

framework/elsa/fit-elsa-react/src/components/base/jadeNode.jsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,17 @@ export const jadeNode = (id, x, y, width, height, parent, drawer) => {
193193

194194
// 从当前节点开始启动递归
195195
explorePreShapesRecursive(self.id);
196-
const systemEnv = self.page.getShapeById(VIRTUAL_CONTEXT_NODE.id);
197-
systemEnv.runnable = true;
198-
preNodeInfos.push({
199-
id: systemEnv.id,
200-
name: systemEnv.text,
201-
node: systemEnv,
202-
runnable: true,
203-
observableList: self.page.getObservableList(systemEnv.id),
204-
});
196+
if (self.isAllowReferenceSystemEnv()) {
197+
const systemEnv = self.page.getShapeById(VIRTUAL_CONTEXT_NODE.id);
198+
systemEnv.runnable = true;
199+
preNodeInfos.push({
200+
id: systemEnv.id,
201+
name: systemEnv.text,
202+
node: systemEnv,
203+
runnable: true,
204+
observableList: self.page.getObservableList(systemEnv.id),
205+
});
206+
}
205207
preNodeInfos.shift();
206208
return preNodeInfos;
207209
};
@@ -367,6 +369,13 @@ export const jadeNode = (id, x, y, width, height, parent, drawer) => {
367369
return self.page.getEvents().filter(l => l.fromShape === self.id && l.runnable);
368370
};
369371

372+
/**
373+
* 允许引用系统上下文节点.
374+
*/
375+
self.isAllowReferenceSystemEnv = () => {
376+
return true;
377+
};
378+
370379
/**
371380
* 校验节点状态是否正常.
372381
*

framework/elsa/fit-elsa-react/src/components/code/codeNodeState.jsx

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

7-
import {jadeNode} from "@/components/base/jadeNode.jsx";
8-
import "./style.css";
9-
import {codeComponent} from "@/components/code/codeComponent.jsx";
10-
import {SECTION_TYPE} from "@/common/Consts.js";
11-
import {codeNodeDrawer} from "@/components/code/CodeNodeDrawer.jsx";
7+
import {jadeNode} from '@/components/base/jadeNode.jsx';
8+
import './style.css';
9+
import {codeComponent} from '@/components/code/codeComponent.jsx';
10+
import {SECTION_TYPE} from '@/common/Consts.js';
11+
import {codeNodeDrawer} from '@/components/code/CodeNodeDrawer.jsx';
1212

1313
/**
1414
* 代码节点shape
@@ -18,7 +18,6 @@ import {codeNodeDrawer} from "@/components/code/CodeNodeDrawer.jsx";
1818
export const codeNodeState = (id, x, y, width, height, parent, drawer) => {
1919
const self = jadeNode(id, x, y, width, height, parent, drawer ? drawer : codeNodeDrawer);
2020
self.type = "codeNodeState";
21-
self.width = 360;
2221
self.componentName = "codeComponent";
2322
self.text = "代码节点"
2423
self.width = 368;

framework/elsa/fit-elsa-react/src/components/start/StartFormWrapper.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import {useState} from 'react';
88
import {Button, Collapse, Popover} from 'antd';
9-
import {DeleteOutlined, PlusOutlined, QuestionCircleOutlined} from '@ant-design/icons';
9+
import {PlusOutlined, QuestionCircleOutlined} from '@ant-design/icons';
1010
import {StartInputForm} from './StartInputForm.jsx';
1111
import './style.css';
1212
import {useConfigContext, useDispatch, useShapeContext} from '@/components/DefaultRoot.jsx';
@@ -16,6 +16,7 @@ import PropTypes from 'prop-types';
1616
import {Trans, useTranslation} from 'react-i18next';
1717
import {AppConfiguration} from '@/components/start/AppConfiguration.jsx';
1818
import {JadeCollapse} from '@/components/common/JadeCollapse.jsx';
19+
import IconTrashBin from '../asserts/icon-delete-trash-bin.svg?react'; // 导入背景图片
1920

2021
const {Panel} = Collapse;
2122

@@ -87,7 +88,7 @@ export default function StartFormWrapper({data, shapeStatus}) {
8788
type="text"
8889
className="icon-button start-node-delete-icon-button"
8990
onClick={() => handleDelete(item.id)}>
90-
<DeleteOutlined/>
91+
<IconTrashBin/>
9192
</Button>
9293
</>);
9394
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
import {v4 as uuidv4} from 'uuid';
8+
import {DATA_TYPES, FROM_TYPE} from '@/common/Consts.js';
9+
10+
export const createDefaultVariable = () => ({
11+
id: uuidv4(),
12+
type: DATA_TYPES.OBJECT,
13+
from: FROM_TYPE.EXPAND,
14+
value: [{
15+
id: uuidv4(),
16+
name: 'key',
17+
type: DATA_TYPES.ARRAY,
18+
dataType: '',
19+
from: FROM_TYPE.INPUT,
20+
value: [],
21+
referenceNode: '',
22+
referenceId: '',
23+
referenceKey: '',
24+
}, {
25+
id: uuidv4(),
26+
name: 'value',
27+
type: '',
28+
from: FROM_TYPE.REFERENCE,
29+
value: '',
30+
referenceNode: '',
31+
referenceId: '',
32+
referenceKey: '',
33+
}],
34+
});

0 commit comments

Comments
 (0)