From eba3ef264982360575eb78360b395a2765bec6a0 Mon Sep 17 00:00:00 2001 From: liuqiufeng Date: Sun, 25 Feb 2024 21:50:48 +0800 Subject: [PATCH] feat: console supports configuration of multiple target services (#288) --- .../service/kubernetes/KubernetesModelConverter.java | 2 +- frontend/src/locales/en-US/translation.json | 4 ++-- frontend/src/locales/zh-CN/translation.json | 4 ++-- .../src/pages/route/components/RouteForm/index.tsx | 4 ++-- frontend/src/pages/route/index.tsx | 10 +++++++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java index c7e86cf1..aa655993 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java @@ -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()); diff --git a/frontend/src/locales/en-US/translation.json b/frontend/src/locales/en-US/translation.json index e5bbfbe4..427cb735 100644 --- a/frontend/src/locales/en-US/translation.json +++ b/frontend/src/locales/en-US/translation.json @@ -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": { @@ -494,4 +494,4 @@ "yes": "Yes", "no": "No" } -} \ No newline at end of file +} diff --git a/frontend/src/locales/zh-CN/translation.json b/frontend/src/locales/zh-CN/translation.json index 9a191580..679d7d2d 100644 --- a/frontend/src/locales/zh-CN/translation.json +++ b/frontend/src/locales/zh-CN/translation.json @@ -345,7 +345,7 @@ "customConfigsTip": "点击问号查看注解配置说明", "targetService": "目标服务", "targetServiceRequired": "请选择目标服务", - "targetServiceNamedPlaceholder": "搜索服务名称选择服务" + "targetServiceNamedPlaceholder": "搜索服务名称选择服务,可多选" } }, "chart": { @@ -494,4 +494,4 @@ "yes": "是", "no": "否" } -} \ No newline at end of file +} diff --git a/frontend/src/pages/route/components/RouteForm/index.tsx b/frontend/src/pages/route/components/RouteForm/index.tsx index 95b41aed..0973305b 100644 --- a/frontend/src/pages/route/components/RouteForm/index.tsx +++ b/frontend/src/pages/route/components/RouteForm/index.tsx @@ -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() }; }); @@ -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, }); } @@ -254,6 +253,7 @@ const RouteForm: React.FC = forwardRef((props, ref) => { ]} >