Updated implementation (#576)

This commit is contained in:
dwikov 2021-06-22 12:40:22 +03:00 committed by GitHub
parent dbebb440ac
commit cdcba2d2e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {
name,
@ -196,15 +206,7 @@ const formatTopicCreation = (form: TopicFormDataRaw): TopicCreation => {
'retention.bytes': retentionBytes,
'max.message.bytes': maxMessageBytes,
'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,
'max.message.bytes': maxMessageBytes,
'min.insync.replicas': minInSyncReplicas,
...Object.values(customParams || {}).reduce(
(result: TopicFormFormattedParams, customParam: TopicConfig) => {
return {
...result,
[customParam.name]: customParam.value,
};
},
{}
),
...Object.values(customParams || {}).reduce(topicReducer, {}),
},
};
};