-
Notifications
You must be signed in to change notification settings - Fork 576
feat: improve route #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve route #483
Changes from all commits
d4ac812
430cb2f
48d6dc3
e2fd3c4
9005b0c
b071b2e
9888730
b27a98c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,19 +23,22 @@ import PluginOrchestration from '@api7-dashboard/pluginchart'; | |
| import Step1 from '../Step1'; | ||
| import Step2 from '../Step2'; | ||
|
|
||
| interface Props extends RouteModule.Data { | ||
| type Props = { | ||
| form1: FormInstance; | ||
| form2: FormInstance; | ||
| redirect?: boolean; | ||
| } | ||
| step3Data: RouteModule.Step3Data; | ||
| advancedMatchingRules: RouteModule.MatchingRule[]; | ||
| upstreamHeaderList: RouteModule.UpstreamHeader[]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we'd better have a unified style on List variables, e.g advancedMatchingRuleList or upstramHeaders, I would prefer the former one. |
||
| }; | ||
|
|
||
| const style = { | ||
| marginTop: '40px', | ||
| }; | ||
|
|
||
| const CreateStep4: React.FC<Props> = ({ form1, form2, redirect, ...rest }) => { | ||
| const { formatMessage } = useIntl(); | ||
| const { plugins = {}, script = {} } = rest.data.step3Data; | ||
| const { plugins = {}, script = {} } = rest.step3Data; | ||
|
|
||
| return ( | ||
| <> | ||
|
|
@@ -44,17 +47,18 @@ const CreateStep4: React.FC<Props> = ({ form1, form2, redirect, ...rest }) => { | |
| {!redirect && ( | ||
| <> | ||
| <h2 style={style}>{formatMessage({ id: 'route.create.define.api.backend.server' })}</h2> | ||
| <Step2 {...rest} form={form2} disabled /> | ||
| <Step2 | ||
| upstreamHeaderList={rest.upstreamHeaderList} | ||
| form={form2} | ||
| disabled | ||
| onChange={() => {}} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. , |
||
| /> | ||
| <h2 style={style}>{formatMessage({ id: 'route.create.plugin.configuration' })}</h2> | ||
| {Boolean(Object.keys(plugins).length !== 0) && ( | ||
| <PluginPage initialData={rest.data.step3Data.plugins} readonly /> | ||
| <PluginPage initialData={rest.step3Data.plugins} readonly /> | ||
| )} | ||
| {Boolean(Object.keys(script).length !== 0) && ( | ||
| <PluginOrchestration | ||
| data={rest.data.step3Data.script.chart} | ||
| readonly | ||
| onChange={() => {}} | ||
| /> | ||
| <PluginOrchestration data={rest.step3Data.script.chart} readonly onChange={() => {}} /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. , |
||
| )} | ||
| </> | ||
| )} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,11 +19,11 @@ import { Button, Table, Modal, Form, Select, Input, Space } from 'antd'; | |
| import { useIntl } from 'umi'; | ||
| import { PanelSection } from '@api7-dashboard/ui'; | ||
|
|
||
| interface Props extends RouteModule.Data {} | ||
|
|
||
| const MatchingRulesView: React.FC<Props> = ({ data, disabled, onChange }) => { | ||
| const { advancedMatchingRules } = data.step1Data; | ||
|
|
||
| const MatchingRulesView: React.FC<RouteModule.Step1PassProps> = ({ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pass? |
||
| advancedMatchingRules, | ||
| disabled, | ||
| onChange = () => {}, | ||
| }) => { | ||
| const [visible, setVisible] = useState(false); | ||
| const [mode, setMode] = useState<RouteModule.ModalType>('CREATE'); | ||
| const [namePlaceholder, setNamePlaceholder] = useState(''); | ||
|
|
@@ -38,8 +38,8 @@ const MatchingRulesView: React.FC<Props> = ({ data, disabled, onChange }) => { | |
| if (mode === 'EDIT') { | ||
| const key = modalForm.getFieldValue('key'); | ||
| onChange({ | ||
| ...data.step1Data, | ||
| advancedMatchingRules: advancedMatchingRules.map((rule) => { | ||
| action: 'advancedMatchingRulesChange', | ||
| data: advancedMatchingRules.map((rule) => { | ||
| if (rule.key === key) { | ||
| return { ...(value as RouteModule.MatchingRule), key }; | ||
| } | ||
|
|
@@ -51,7 +51,10 @@ const MatchingRulesView: React.FC<Props> = ({ data, disabled, onChange }) => { | |
| ...(value as RouteModule.MatchingRule), | ||
| key: Math.random().toString(36).slice(2), | ||
| }; | ||
| onChange({ ...data.step1Data, advancedMatchingRules: advancedMatchingRules.concat(rule) }); | ||
| onChange({ | ||
| action: 'advancedMatchingRulesChange', | ||
| data: advancedMatchingRules.concat(rule), | ||
| }); | ||
| } | ||
| modalForm.resetFields(); | ||
| setVisible(false); | ||
|
|
@@ -66,8 +69,8 @@ const MatchingRulesView: React.FC<Props> = ({ data, disabled, onChange }) => { | |
|
|
||
| const handleRemove = (key: string) => { | ||
| onChange({ | ||
| ...data.step1Data, | ||
| advancedMatchingRules: advancedMatchingRules.filter((item) => item.key !== key), | ||
| action: 'advancedMatchingRulesChange', | ||
| data: advancedMatchingRules.filter((item) => item.key !== key), | ||
| }); | ||
| }; | ||
|
|
||
|
|
@@ -164,7 +167,7 @@ const MatchingRulesView: React.FC<Props> = ({ data, disabled, onChange }) => { | |
| cancelText={formatMessage({ id: 'route.match.cancel' })} | ||
| destroyOnClose | ||
| > | ||
| <Form form={modalForm} labelCol={{ span: 9 }} wrapperCol={{ span: 15 }}> | ||
| <Form form={modalForm} labelCol={{ span: 4 }}> | ||
| <Form.Item | ||
| label={formatMessage({ id: 'route.match.parameter.position' })} | ||
| name="position" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.