feat(web): start/chat variable name cannot be duplicated
This commit is contained in:
@@ -2453,7 +2453,8 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
|
||||
value: 'Value',
|
||||
addCase: 'Add Condition',
|
||||
addVariable: 'Add Variables',
|
||||
output: 'Output Variable'
|
||||
output: 'Output Variable',
|
||||
duplicateName: 'Variable name cannot be duplicated',
|
||||
},
|
||||
|
||||
clear: 'Clear',
|
||||
@@ -2480,7 +2481,7 @@ Memory Bear: After the rebellion, regional warlordism intensified for several re
|
||||
input_cycle_vars: 'Initial Loop Variables',
|
||||
output_cycle_vars: 'Final Loop Variables',
|
||||
},
|
||||
sureReplace: '确认替换',
|
||||
sureReplace: 'Confirm Replace',
|
||||
checkList: 'Check List',
|
||||
checkListDesc: 'Ensure all issues are resolved before publishing',
|
||||
checkListEmpty: 'No issues found',
|
||||
|
||||
@@ -2417,7 +2417,8 @@ export const zh = {
|
||||
value: '值',
|
||||
addCase: '添加条件',
|
||||
addVariable: '添加变量',
|
||||
output: '输出变量'
|
||||
output: '输出变量',
|
||||
duplicateName: '变量名不能重复',
|
||||
},
|
||||
|
||||
clear: '清空',
|
||||
|
||||
@@ -45,6 +45,7 @@ const array_object_placeholder = `# example
|
||||
|
||||
interface ChatVariableModalProps {
|
||||
refresh: (value: ChatVariable, editIndex?: number) => void;
|
||||
variables?: ChatVariable[];
|
||||
}
|
||||
|
||||
const types = [
|
||||
@@ -61,7 +62,8 @@ const types = [
|
||||
]
|
||||
|
||||
const ChatVariableModal = forwardRef<ChatVariableModalRef, ChatVariableModalProps>(({
|
||||
refresh
|
||||
refresh,
|
||||
variables
|
||||
}, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const uploadFileListModalRef = useRef<UploadFileListModalRef>(null);
|
||||
@@ -244,6 +246,12 @@ const ChatVariableModal = forwardRef<ChatVariableModalRef, ChatVariableModalProp
|
||||
rules={[
|
||||
{ required: true, message: t('common.pleaseEnter') },
|
||||
{ pattern: /^[a-zA-Z_][a-zA-Z0-9_]*$/, message: t('workflow.config.parameter-extractor.invalidParamName') },
|
||||
{
|
||||
validator: (_, value) => {
|
||||
const duplicate = variables?.some((v, i) => v.name === value && i !== editIndex);
|
||||
return duplicate ? Promise.reject(t('workflow.config.duplicateName')) : Promise.resolve();
|
||||
}
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input placeholder={t('common.enter')} />
|
||||
|
||||
@@ -104,6 +104,7 @@ const AddChatVariable = forwardRef<AddChatVariableRef, AddChatVariableProps>(({
|
||||
<ChatVariableModal
|
||||
ref={chatVariableRef}
|
||||
refresh={handleSave}
|
||||
variables={variables}
|
||||
/>
|
||||
</RbDrawer>
|
||||
);
|
||||
|
||||
@@ -10,6 +10,7 @@ const FormItem = Form.Item;
|
||||
|
||||
interface VariableEditModalProps {
|
||||
refresh: (values: Variable) => void;
|
||||
variables?: Variable[];
|
||||
}
|
||||
|
||||
const types = [
|
||||
@@ -32,7 +33,8 @@ const initialValues = {
|
||||
}
|
||||
|
||||
const VariableEditModal = forwardRef<VariableEditModalRef, VariableEditModalProps>(({
|
||||
refresh
|
||||
refresh,
|
||||
variables
|
||||
}, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const [visible, setVisible] = useState(false);
|
||||
@@ -123,6 +125,12 @@ const VariableEditModal = forwardRef<VariableEditModalRef, VariableEditModalProp
|
||||
rules={[
|
||||
{ required: true, message: t('common.pleaseEnter') },
|
||||
{ pattern: /^[a-zA-Z_][a-zA-Z0-9_]*$/, message: t('workflow.config.start.invalidVariableName') },
|
||||
{
|
||||
validator: (_, value) => {
|
||||
const duplicate = variables?.some(v => v.name === value && v.name !== editVo?.name);
|
||||
return duplicate ? Promise.reject(t('workflow.config.duplicateName')) : Promise.resolve();
|
||||
}
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input placeholder={t('common.enter')} onBlur={nameChange} />
|
||||
|
||||
@@ -104,6 +104,7 @@ const VariableList: FC<VariableListProps> = ({
|
||||
<VariableEditModal
|
||||
ref={variableModalRef}
|
||||
refresh={handleRefreshVariable}
|
||||
variables={value}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user