Skip to content

Commit ff1ba14

Browse files
committed
[frontend] feat: use modal to add/edit custom variables on start node
1 parent f59e398 commit ff1ba14

File tree

7 files changed

+856
-165
lines changed

7 files changed

+856
-165
lines changed

frontend/src/locale/en_US.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,5 +1682,23 @@
16821682
"guestTips": "Guest mode has no access authentication, there are potential threats such as data leakage, please use with caution.",
16831683
"wrongAddr": "Access address error",
16841684
"wrongAddrMsg": "Please visit the correct address"
1685-
}
1685+
},
1686+
"inputType": "Input",
1687+
"numberType": "Number",
1688+
"dropdownType": "Dropdown",
1689+
"switchType": "Switch",
1690+
"multiselectType": "Multi Select",
1691+
"maxLength": "Max Length",
1692+
"option": "option",
1693+
"plsEnterOption": "Please enter an option",
1694+
"optionShouldBeUnique": "Options should be unique",
1695+
"addOption": "Add option",
1696+
"maxValue": "Max Value",
1697+
"minValue": "Min Value",
1698+
"addParamField": "Add Param",
1699+
"editParamField": "Edit Param",
1700+
"varName": "Param Name",
1701+
"plsEnterVarName": "Please enter param name",
1702+
"attributeVarNameMustBeUnique": "Enter a unique param name.",
1703+
"noDefaultValue": "No default value"
16861704
}

frontend/src/locale/zh_CN.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@
694694
"access": "访问",
695695
"preview": "预览",
696696
"displayName": "展示名称",
697-
"paramDisplayNameCannotBeEmpty": "展示名称不能为空",
698-
"attributeDisplayNameMustBeUnique": "字段展示名称不能重复",
697+
"paramDisplayNameCannotBeEmpty": "请输入展示名称",
698+
"attributeDisplayNameMustBeUnique": "展示名称已存在,请重新命名",
699699
"pleaseInsertDisplayName": "请输入展示名称",
700700
"startNodeNamePopover": "用于表示入参字段的key,</p>\n<p>格式要求:只能输入英文、数字及下划线,且不能以数字开头",
701701
"startNodeDisplayNamePopover": "用于表示入参字段在对话配置窗口中的展示名称",
@@ -1682,5 +1682,23 @@
16821682
"guestMode": "游客模式",
16831683
"guestTips": "游客模式无访问鉴权,存在数据泄露等潜在威胁,请务必谨慎使用。",
16841684
"wrongAddr": "访问地址错误",
1685-
"wrongAddrMsg": "请访问正确的地址"
1685+
"wrongAddrMsg": "请访问正确的地址",
1686+
"inputType": "文本",
1687+
"numberType": "数字",
1688+
"dropdownType": "单选框",
1689+
"switchType": "开关",
1690+
"multiselectType": "多选框",
1691+
"maxLength": "最大长度",
1692+
"option": "选项",
1693+
"plsEnterOption": "请输入选项",
1694+
"optionShouldBeUnique": "选项不能重复",
1695+
"addOption": "添加选项",
1696+
"maxValue": "最大值",
1697+
"minValue": "最小值",
1698+
"addParamField": "添加变量",
1699+
"editParamField": "编辑变量",
1700+
"varName": "变量名称",
1701+
"plsEnterVarName": "请输入变量名称",
1702+
"attributeVarNameMustBeUnique": "名称已存在,请重新命名",
1703+
"noDefaultValue": "无默认值"
16861704
}

frontend/src/pages/addFlow/components/elsa-stage.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { configMap } from '../config';
2929
import { useTranslation } from 'react-i18next';
3030
import i18n from '../../../locale/i18n';
3131
import { cloneDeep } from 'lodash';
32+
import InputParamModal from '@/pages/configForm/configUi/components/add-input-param';
3233

3334
/**
3435
* elsa编排组件
@@ -56,6 +57,8 @@ const Stage = (props) => {
5657
} = props;
5758
const [showModal, setShowModal] = useState(false);
5859
const [showTools, setShowTools] = useState(false);
60+
const [showInputModal, setShowInputModal] = useState(false);
61+
const [inputModalMode, setInputModalMode] = useState('add');
5962
const [showDrawer, setShowDrawer] = useState(false);
6063
const [spinning, setSpinning] = useState(false);
6164
const [isDrawper, setIsDrawper] = useState(false);
@@ -79,6 +82,8 @@ const Stage = (props) => {
7982
const modelCallback = useRef<any>();
8083
const knowledgeCallback = useRef<any>();
8184
const pluginCallback = useRef<any>();
85+
const inputParamCallback = useRef<any>();
86+
const inputParamRef = useRef<any>({})
8287
const formCallback = useRef<any>();
8388
const currentApp = useRef<any>();
8489
const currentChange = useRef<any>(false);
@@ -251,6 +256,18 @@ const Stage = (props) => {
251256
setShowTools(true);
252257
setModalTypes('parallel');
253258
});
259+
agent.onAddInputParam(({onAdd, existParam}) => {
260+
inputParamCallback.current = onAdd;
261+
setInputModalMode('add')
262+
setShowInputModal(true);
263+
inputParamRef.current.existParam = existParam;
264+
})
265+
agent.onEditInputParam(({onEdit, id, selectedParam}) => {
266+
inputParamCallback.current = onEdit;
267+
setInputModalMode('edit')
268+
setShowInputModal(true);
269+
inputParamRef.current.selectedParam = selectedParam;
270+
})
254271
if (readOnly) {
255272
agent.readOnly();
256273
}
@@ -298,6 +315,10 @@ const Stage = (props) => {
298315
searchCallback.current(value);
299316
};
300317

318+
const addParam = (value) => {
319+
inputParamCallback.current(value);
320+
}
321+
301322
// 插件工具流选中
302323
const toolsConfirm = (item) => {
303324
let obj = {};
@@ -444,6 +465,14 @@ const Stage = (props) => {
444465
taskName={taskName}
445466
selectModal={selectModal}
446467
/>
468+
{/*input param添加弹窗*/}
469+
<InputParamModal
470+
mode={inputModalMode}
471+
modalRef={inputParamRef}
472+
showModal={showInputModal}
473+
setShowModal={setShowInputModal}
474+
onSubmit={addParam}
475+
/>
447476
{/* 添加知识库弹窗 */}
448477
<AddKnowledge
449478
modalRef={modalRef}

frontend/src/pages/addFlow/components/flow-test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ const Index = (props) => {
339339
name={debugType.name}
340340
label={debugType.displayName}
341341
key={index}
342-
isRequired={debugType.isRequired} />
342+
isRequired={debugType.isRequired}
343+
appearance={debugType.appearance}
344+
/>
343345
)
344346
})}
345347
{

0 commit comments

Comments
 (0)