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 827a739077 [INLONG-11379][Dashboard] Redis sink Properties saving 
problem (#11380)
827a739077 is described below

commit 827a739077f05c6a6eb7cf72b72a8ba44fa08ce8
Author: kamianlaida <[email protected]>
AuthorDate: Tue Oct 22 09:53:15 2024 +0800

    [INLONG-11379][Dashboard] Redis sink Properties saving problem (#11380)
---
 .../src/plugins/sinks/defaults/Redis.ts            | 57 +++++++++++-----------
 .../pages/GroupDetail/DataStorage/DetailModal.tsx  | 19 ++++++++
 2 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/inlong-dashboard/src/plugins/sinks/defaults/Redis.ts 
b/inlong-dashboard/src/plugins/sinks/defaults/Redis.ts
index 03ce1db567..533cc803ff 100644
--- a/inlong-dashboard/src/plugins/sinks/defaults/Redis.ts
+++ b/inlong-dashboard/src/plugins/sinks/defaults/Redis.ts
@@ -295,35 +295,6 @@ export default class RedisSink extends SinkInfo implements 
DataWithBackend, Rend
   @I18n('meta.Sinks.Redis.Ttl')
   ttl: number;
 
-  @FieldDecorator({
-    type: EditableTable,
-    props: values => ({
-      size: 'small',
-      editing: ![110].includes(values?.status),
-      columns: getFieldListColumns(values),
-      canBatchAdd: true,
-      upsertByFieldKey: true,
-    }),
-  })
-  @IngestionField()
-  sinkFieldList: Record<string, unknown>[];
-
-  @FieldDecorator({
-    type: EditableTable,
-    initialValue: [],
-    props: values => ({
-      size: 'small',
-      editing: ![110].includes(values?.status),
-      columns: getFieldListColumns(values).filter(
-        item => item.dataIndex !== 'sourceFieldName' && item.dataIndex !== 
'sourceFieldType',
-      ),
-      canBatchAdd: true,
-      upsertByFieldKey: true,
-    }),
-  })
-  @SyncCreateTableField()
-  createTableField: Record<string, unknown>[];
-
   @FieldDecorator({
     type: EditableTable,
     rules: [{ required: false }],
@@ -352,6 +323,34 @@ export default class RedisSink extends SinkInfo implements 
DataWithBackend, Rend
   @IngestionField()
   @I18n('meta.Sinks.Redis.ExtList')
   properties: string;
+  @FieldDecorator({
+    type: EditableTable,
+    props: values => ({
+      size: 'small',
+      editing: ![110].includes(values?.status),
+      columns: getFieldListColumns(values),
+      canBatchAdd: true,
+      upsertByFieldKey: true,
+    }),
+  })
+  @IngestionField()
+  sinkFieldList: Record<string, unknown>[];
+
+  @FieldDecorator({
+    type: EditableTable,
+    initialValue: [],
+    props: values => ({
+      size: 'small',
+      editing: ![110].includes(values?.status),
+      columns: getFieldListColumns(values).filter(
+        item => item.dataIndex !== 'sourceFieldName' && item.dataIndex !== 
'sourceFieldType',
+      ),
+      canBatchAdd: true,
+      upsertByFieldKey: true,
+    }),
+  })
+  @SyncCreateTableField()
+  createTableField: Record<string, unknown>[];
 
   @FieldDecorator({
     type: 'inputnumber',
diff --git 
a/inlong-dashboard/src/ui/pages/GroupDetail/DataStorage/DetailModal.tsx 
b/inlong-dashboard/src/ui/pages/GroupDetail/DataStorage/DetailModal.tsx
index e2d4e2d69e..5819494b3a 100644
--- a/inlong-dashboard/src/ui/pages/GroupDetail/DataStorage/DetailModal.tsx
+++ b/inlong-dashboard/src/ui/pages/GroupDetail/DataStorage/DetailModal.tsx
@@ -73,6 +73,12 @@ const Comp: React.FC<DetailModalProps> = ({
       formatResult: result => new Entity()?.parse(result) || result,
       onSuccess: result => {
         setSinkType(result.sinkType);
+        if (result.sinkType === 'REDIS') {
+          result.properties = Object.entries(result.properties).map(([key, 
value]) => ({
+            keyName: key,
+            keyValue: value,
+          }));
+        }
         form.setFieldsValue(result);
       },
     },
@@ -158,6 +164,19 @@ const Comp: React.FC<DetailModalProps> = ({
     if (startProcess) {
       submitData.startProcess = true;
     }
+    if (sinkType === 'REDIS') {
+      if (Array.isArray(submitData.properties) && submitData.properties.length 
> 0) {
+        const propertiesObject = submitData.properties.reduce((acc, item) => {
+          if (item.keyName && item.keyValue !== undefined) {
+            acc[item.keyName] = item.keyValue;
+          }
+          return acc;
+        }, {});
+        submitData.properties = propertiesObject;
+      } else {
+        submitData.properties = {};
+      }
+    }
     await request({
       url: isUpdate ? '/sink/update' : '/sink/save',
       method: 'POST',

Reply via email to