Browse Source

Updated implementation (#576)

dwikov 4 years ago
parent
commit
cdcba2d2e9
1 changed files with 12 additions and 18 deletions
  1. 12 18
      kafka-ui-react-app/src/redux/actions/thunks/topics.ts

+ 12 - 18
kafka-ui-react-app/src/redux/actions/thunks/topics.ts

@@ -173,6 +173,16 @@ export const fetchTopicConfig =
     }
     }
   };
   };
 
 
+const topicReducer = (
+  result: TopicFormFormattedParams,
+  customParam: TopicConfig
+) => {
+  return {
+    ...result,
+    [customParam.name]: customParam.value,
+  };
+};
+
 const formatTopicCreation = (form: TopicFormDataRaw): TopicCreation => {
 const formatTopicCreation = (form: TopicFormDataRaw): TopicCreation => {
   const {
   const {
     name,
     name,
@@ -196,15 +206,7 @@ const formatTopicCreation = (form: TopicFormDataRaw): TopicCreation => {
       'retention.bytes': retentionBytes,
       'retention.bytes': retentionBytes,
       'max.message.bytes': maxMessageBytes,
       'max.message.bytes': maxMessageBytes,
       'min.insync.replicas': minInSyncReplicas,
       'min.insync.replicas': minInSyncReplicas,
-      ...Object.values(customParams || {}).reduce(
-        (result: TopicFormFormattedParams, customParam: TopicConfig) => {
-          return {
-            ...result,
-            [customParam.name]: customParam.value,
-          };
-        },
-        {}
-      ),
+      ...Object.values(customParams || {}).reduce(topicReducer, {}),
     },
     },
   };
   };
 };
 };
@@ -226,15 +228,7 @@ const formatTopicUpdate = (form: TopicFormDataRaw): TopicUpdate => {
       'retention.bytes': retentionBytes,
       'retention.bytes': retentionBytes,
       'max.message.bytes': maxMessageBytes,
       'max.message.bytes': maxMessageBytes,
       'min.insync.replicas': minInSyncReplicas,
       'min.insync.replicas': minInSyncReplicas,
-      ...Object.values(customParams || {}).reduce(
-        (result: TopicFormFormattedParams, customParam: TopicConfig) => {
-          return {
-            ...result,
-            [customParam.name]: customParam.value,
-          };
-        },
-        {}
-      ),
+      ...Object.values(customParams || {}).reduce(topicReducer, {}),
     },
     },
   };
   };
 };
 };