Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxiran committed Apr 26, 2021
1 parent 0fe93b2 commit d75b137
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
3 changes: 0 additions & 3 deletions web/src/components/Upstream/components/UpstreamSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ const UpstreamSelector: React.FC<Props> = ({ onChange, list = [], disabled, requ
{item.name}
</Select.Option>
))}
<Select.Option value={formatMessage({ id: 'page.upstream.step.select.upstream.select.none' })}>{
formatMessage({ id: 'page.upstream.step.select.upstream.select.none' })
}</Select.Option>
</Select>
</Form.Item>
)
Expand Down
18 changes: 9 additions & 9 deletions web/src/pages/Service/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ const Page: React.FC = (props) => {
fetchItem(serviceId).then(({ data }) => {
if (data.upstream_id) {
upstreamForm.setFieldsValue({ upstream_id: data.upstream_id })
}
if (data.upstream) {
} else if (data.upstream) {
upstreamForm.setFieldsValue(convertToFormData(data.upstream))
} else {
upstreamForm.setFieldsValue({ upstream_id: 'None' })
}

form.setFieldsValue(omit(data, ['upstream_id', 'upstream', 'plugins']));
setPlugins(data.plugins || {});
});
Expand All @@ -68,13 +70,11 @@ const Page: React.FC = (props) => {
};

const upstreamFormData = upstreamRef.current?.getData();
if (!upstreamFormData) {
return
}
if (!upstreamFormData.upstream_id) {
data.upstream = upstreamFormData;
} else if (upstreamFormData.upstream_id !== 'None') {
data.upstream_id = upstreamFormData.upstream_id;

if (!upstreamFormData?.upstream_id) {
data.upstream = upstreamFormData
} else {
data.upstream_id = upstreamFormData.upstream_id
}

const { serviceId } = (props as any).match.params;
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/Service/components/Step1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const Step1: React.FC<ServiceModule.Step1PassProps> = ({
</Form>
<UpstreamForm
ref={upstreamRef}
required
required={false}
form={upstreamForm}
disabled={disabled}
list={list}
Expand Down
3 changes: 2 additions & 1 deletion web/src/pages/Service/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export default {
'page.service.list': 'Service List',
'page.service.description': 'A service consists of a combination of public plugin configuration and upstream target information in a route. Services are associated with Routes and Upstreams, and a service can correspond to a set of upstream nodes and can be bound by multiple routes.',
'page.service.create': 'Create Service',
'page.service.configure': 'Configure Service'
'page.service.configure': 'Configure Service',
'page.service.fields.name.required': 'Please enter the service name',
};

0 comments on commit d75b137

Please sign in to comment.