Skip to content

Commit

Permalink
feat: console supports configuration of multiple target services (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuqiufeng authored Feb 25, 2024
1 parent 056686d commit eba3ef2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ private static void fillIngressDestination(V1ObjectMeta metadata, Route route) {
if (!valueBuilder.isEmpty()) {
valueBuilder.append("\n");
}
valueBuilder.append(service.getWeight()).append("% ");
valueBuilder.append(service.getWeight() == null ? DEFAULT_WEIGHT : service.getWeight()).append("% ");
valueBuilder.append(service.getName());
if (service.getPort() != null) {
valueBuilder.append(":").append(service.getPort());
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
"customConfigsTip": "Click this \"?\" to view the configuration guide.",
"targetService": "Target Service",
"targetServiceRequired": "Please choose the target service.",
"targetServiceNamedPlaceholder": "Search target service by name"
"targetServiceNamedPlaceholder": "Search target service by name. Multiple selections are allowed."
}
},
"chart": {
Expand Down Expand Up @@ -494,4 +494,4 @@
"yes": "Yes",
"no": "No"
}
}
}
4 changes: 2 additions & 2 deletions frontend/src/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
"customConfigsTip": "点击问号查看注解配置说明",
"targetService": "目标服务",
"targetServiceRequired": "请选择目标服务",
"targetServiceNamedPlaceholder": "搜索服务名称选择服务"
"targetServiceNamedPlaceholder": "搜索服务名称选择服务,可多选"
}
},
"chart": {
Expand Down Expand Up @@ -494,4 +494,4 @@
"yes": "",
"no": ""
}
}
}
4 changes: 2 additions & 2 deletions frontend/src/pages/route/components/RouteForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const RouteForm: React.FC = forwardRef((props, ref) => {
if (value) {
// eslint-disable-next-line @typescript-eslint/no-shadow
const { name, domains, path, headers, methods, urlParams, services, customConfigs } = value;
const [service] = services;
headers && headers.map((header) => {
return { ...header, uid: uniqueId() };
});
Expand All @@ -80,7 +79,7 @@ const RouteForm: React.FC = forwardRef((props, ref) => {
methods: methods || [],
headers: headers || [],
urlParams: urlParams || [],
services: service ? upstreamServiceToString(service) : null,
services: services ? services.map(upstreamServiceToString) : null,
customConfigs: customConfigArray,
});
}
Expand Down Expand Up @@ -254,6 +253,7 @@ const RouteForm: React.FC = forwardRef((props, ref) => {
]}
>
<Select
mode="multiple"
showSearch
allowClear
placeholder={t('route.routeForm.targetServiceNamedPlaceholder')}
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/pages/route/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface RouteFormProps {
methods: string[];
path: RoutePredicate;
urlParams: KeyedRoutePredicate[];
services: string;
services: string[];
customConfigs: {
[key: string]: string;
};
Expand Down Expand Up @@ -135,7 +135,7 @@ const RouteList: React.FC = () => {
const handleDrawerOK = async () => {
try {
const values: RouteFormProps = formRef.current && (await formRef.current.handleSubmit());
const { name, domains, headers, methods, urlParams, path, services: service, customConfigs } = values;
const { name, domains, headers, methods, urlParams, path, services, customConfigs } = values;
path && normalizeRoutePredicate(path);
headers && headers.forEach((h) => normalizeRoutePredicate(h));
urlParams && urlParams.forEach((h) => normalizeRoutePredicate(h));
Expand All @@ -147,7 +147,11 @@ const RouteList: React.FC = () => {
path,
urlParams,
customConfigs,
services: [{ name: service }],
services: services.map((service) => {
return {
name: service,
};
}),
};
if (currentRoute) {
route.version = currentRoute.version;
Expand Down

0 comments on commit eba3ef2

Please sign in to comment.