Skip to content

Commit

Permalink
feat: Delete Answer and Relevant from RestrictedUpstreamMap of Switch i…
Browse files Browse the repository at this point in the history
…nfiniflow#1739 (infiniflow#2039)

### What problem does this PR solve?

feat: Delete Answer and Relevant from RestrictedUpstreamMap of Switch
infiniflow#1739

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
cike8899 authored Aug 21, 2024
1 parent 5d35418 commit 7b1f816
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion web/src/locales/zh-traditional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ export default {
yes: '是',
no: '否',
key: 'key',
componentId: '組件id',
componentId: '組件ID',
add: '新增',
operation: '操作',
run: '運行',
Expand Down
2 changes: 1 addition & 1 deletion web/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ export default {
yes: '是',
no: '否',
key: 'key',
componentId: '组件id',
componentId: '组件ID',
add: '新增',
operation: '操作',
run: '运行',
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/flow/constant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export const RestrictedUpstreamMap = {
[Operator.BaiduFanyi]: [Operator.Begin, Operator.Retrieval],
[Operator.QWeather]: [Operator.Begin, Operator.Retrieval],
[Operator.ExeSQL]: [Operator.Begin],
[Operator.Switch]: [Operator.Begin, Operator.Answer, Operator.Relevant],
[Operator.Switch]: [Operator.Begin],
};

export const NodeMap = {
Expand Down
31 changes: 16 additions & 15 deletions web/src/pages/flow/switch-form/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CloseOutlined } from '@ant-design/icons';
import { Button, Card, Form, Input, Select, Typography } from 'antd';
import { Button, Card, Divider, Form, Input, Select, Typography } from 'antd';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import {
Expand All @@ -14,11 +14,11 @@ import { IOperatorForm, ISwitchForm } from '../interface';
import { getOtherFieldValues } from '../utils';

const subLabelCol = {
span: 9,
span: 11,
};

const subWrapperCol = {
span: 15,
span: 13,
};

const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
Expand Down Expand Up @@ -53,27 +53,21 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {

return (
<Form
labelCol={{ span: 4 }}
wrapperCol={{ span: 20 }}
labelCol={{ span: 8 }}
wrapperCol={{ span: 16 }}
form={form}
name="dynamic_form_complex"
autoComplete="off"
initialValues={{ conditions: [{}] }}
onValuesChange={onValuesChange}
>
<Form.Item label={t('flow.to')} name={[SwitchElseTo]}>
<Select
allowClear
options={buildCategorizeToOptions(getSelectedConditionTos())}
/>
</Form.Item>
<Form.List name="conditions">
{(fields, { add, remove }) => (
<div style={{ display: 'flex', rowGap: 16, flexDirection: 'column' }}>
{fields.map((field) => (
<Card
size="small"
title={`Item ${field.name + 1}`}
title={`Case ${field.name + 1}`}
key={field.key}
extra={
<CloseOutlined
Expand Down Expand Up @@ -105,7 +99,7 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
])}
/>
</Form.Item>
<Form.Item label=" " colon={false}>
<Form.Item label="Condition">
<Form.List name={[field.name, 'items']}>
{(subFields, subOpt) => (
<div
Expand Down Expand Up @@ -165,7 +159,7 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
onClick={() => subOpt.add()}
block
>
+ {t('flow.addSubItem')}
+ Add Condition
</Button>
</div>
)}
Expand All @@ -175,11 +169,18 @@ const SwitchForm = ({ onValuesChange, node, form }: IOperatorForm) => {
))}

<Button type="dashed" onClick={() => add()} block>
+ {t('flow.addItem')}
+ Add Case
</Button>
</div>
)}
</Form.List>
<Divider />
<Form.Item label={'ELSE'} name={[SwitchElseTo]}>
<Select
allowClear
options={buildCategorizeToOptions(getSelectedConditionTos())}
/>
</Form.Item>

<Form.Item noStyle shouldUpdate>
{() => (
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/flow/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,5 @@ export const getOtherFieldValues = (
);

export const generateSwitchHandleText = (idx: number) => {
return `Item ${idx + 1}`;
return `Case ${idx + 1}`;
};

0 comments on commit 7b1f816

Please sign in to comment.