This is an automated email from the ASF dual-hosted git repository.

dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 903a4e9e3e [INLONG-10591][Dashboard] Audit item query ignores case 
(#10596)
903a4e9e3e is described below

commit 903a4e9e3e7092c9bc9d14272fba331f9efdacf1
Author: kamianlaida <[email protected]>
AuthorDate: Wed Jul 10 20:48:41 2024 +0800

    [INLONG-10591][Dashboard] Audit item query ignores case (#10596)
---
 .../src/ui/pages/GroupDetail/Audit/config.tsx      | 23 ++++++++---
 .../src/ui/pages/ModuleAudit/IdModule/config.tsx   | 44 ++++++++++++++++------
 .../src/ui/pages/ModuleAudit/IpModule/config.tsx   | 44 ++++++++++++++++------
 3 files changed, 81 insertions(+), 30 deletions(-)

diff --git a/inlong-dashboard/src/ui/pages/GroupDetail/Audit/config.tsx 
b/inlong-dashboard/src/ui/pages/GroupDetail/Audit/config.tsx
index d98162c712..9f406c6c60 100644
--- a/inlong-dashboard/src/ui/pages/GroupDetail/Audit/config.tsx
+++ b/inlong-dashboard/src/ui/pages/GroupDetail/Audit/config.tsx
@@ -304,14 +304,25 @@ export const getFormContent = (inlongGroupId, 
initialValues, onSearch, onDataStr
           return request('/audit/getAuditBases');
         },
         requestParams: {
-          formatResult: result =>
-            result?.map(item => ({
-              label: item.nameInChinese,
-              value: item.auditId,
-            })) || [],
+          formatResult: result => {
+            return result?.reduce((accumulator, item) => {
+              const existingItem = accumulator.find(
+                (i: { value: any }) => i.value === item.auditId,
+              );
+              if (!existingItem) {
+                accumulator.push({
+                  label: i18n?.language === 'cn' ? item.nameInChinese : 
item.nameInEnglish,
+                  value: item.auditId,
+                });
+              }
+              return accumulator;
+            }, []);
+          },
         },
       },
-      filterOption: (keyword, option) => option.label.includes(keyword),
+      filterOption: (keyword: string, option: { label: any }) => {
+        return (option?.label ?? 
'').toLowerCase().includes(keyword.toLowerCase());
+      },
     },
   },
   {
diff --git a/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/config.tsx 
b/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/config.tsx
index 4eed3b4e26..c65e0ecdff 100644
--- a/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/config.tsx
+++ b/inlong-dashboard/src/ui/pages/ModuleAudit/IdModule/config.tsx
@@ -145,14 +145,24 @@ export const getFormContent = (initialValues, onSearch) 
=> [
           return request('/audit/getAuditBases');
         },
         requestParams: {
-          formatResult: result =>
-            result?.map(item => ({
-              label: item.nameInChinese,
-              value: item.auditId,
-            })) || [],
+          formatResult: (result: any[]) => {
+            return result?.reduce((accumulator, item) => {
+              const existingItem = accumulator.find(
+                (i: { value: any }) => i.value === item.auditId,
+              );
+              if (!existingItem) {
+                accumulator.push({
+                  label: i18n?.language === 'cn' ? item.nameInChinese : 
item.nameInEnglish,
+                  value: item.auditId,
+                });
+              }
+              return accumulator;
+            }, []);
+          },
         },
       },
-      filterOption: (keyword, option) => option.label.includes(keyword),
+      filterOption: (keyword: string, option: { label: any }) =>
+        (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()),
     },
   },
   {
@@ -170,14 +180,24 @@ export const getFormContent = (initialValues, onSearch) 
=> [
           return request('/audit/getAuditBases');
         },
         requestParams: {
-          formatResult: result =>
-            result?.map(item => ({
-              label: item.nameInChinese,
-              value: item.auditId,
-            })) || [],
+          formatResult: (result: any[]) => {
+            return result?.reduce((accumulator, item) => {
+              const existingItem = accumulator.find(
+                (i: { value: any }) => i.value === item.auditId,
+              );
+              if (!existingItem) {
+                accumulator.push({
+                  label: i18n?.language === 'cn' ? item.nameInChinese : 
item.nameInEnglish,
+                  value: item.auditId,
+                });
+              }
+              return accumulator;
+            }, []);
+          },
         },
       },
-      filterOption: (keyword, option) => option.label.includes(keyword),
+      filterOption: (keyword: string, option: { label: any }) =>
+        (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()),
     },
   },
   {
diff --git a/inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/config.tsx 
b/inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/config.tsx
index 2c738c7bb1..21eccefa95 100644
--- a/inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/config.tsx
+++ b/inlong-dashboard/src/ui/pages/ModuleAudit/IpModule/config.tsx
@@ -99,14 +99,24 @@ export const getFormContent = (initialValues, onSearch) => [
           return request('/audit/getAuditBases');
         },
         requestParams: {
-          formatResult: result =>
-            result?.map(item => ({
-              label: item.nameInChinese,
-              value: item.auditId,
-            })) || [],
+          formatResult: (result: any[]) => {
+            return result?.reduce((accumulator, item) => {
+              const existingItem = accumulator.find(
+                (i: { value: any }) => i.value === item.auditId,
+              );
+              if (!existingItem) {
+                accumulator.push({
+                  label: i18n?.language === 'cn' ? item.nameInChinese : 
item.nameInEnglish,
+                  value: item.auditId,
+                });
+              }
+              return accumulator;
+            }, []);
+          },
         },
       },
-      filterOption: (keyword, option) => option.label.includes(keyword),
+      filterOption: (keyword: any, option: { label: any }) =>
+        (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()),
     },
   },
   {
@@ -124,14 +134,24 @@ export const getFormContent = (initialValues, onSearch) 
=> [
           return request('/audit/getAuditBases');
         },
         requestParams: {
-          formatResult: result =>
-            result?.map(item => ({
-              label: item.nameInChinese,
-              value: item.auditId,
-            })) || [],
+          formatResult: (result: any[]) => {
+            return result?.reduce((accumulator, item) => {
+              const existingItem = accumulator.find(
+                (i: { value: any }) => i.value === item.auditId,
+              );
+              if (!existingItem) {
+                accumulator.push({
+                  label: i18n?.language === 'cn' ? item.nameInChinese : 
item.nameInEnglish,
+                  value: item.auditId,
+                });
+              }
+              return accumulator;
+            }, []);
+          },
         },
       },
-      filterOption: (keyword, option) => option.label.includes(keyword),
+      filterOption: (keyword: string, option: { label: any }) =>
+        (option?.label ?? '').toLowerCase().includes(keyword.toLowerCase()),
     },
   },
   {

Reply via email to