issue-14/update-custom-params-key-to-work-as-object-not-array
This commit is contained in:
parent
ea9426e8dd
commit
df6884e575
2 changed files with 15 additions and 1 deletions
|
@ -26,7 +26,7 @@ const CustomParams: React.FC<Props> = ({
|
||||||
const onAdd = (event: React.MouseEvent<HTMLButtonElement>) => {
|
const onAdd = (event: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const newIndex = `${INDEX_PREFIX}.${new Date().getTime()}`;
|
const newIndex = `${INDEX_PREFIX}.${new Date().getTime()}ts`;
|
||||||
|
|
||||||
setFormCustomParams({
|
setFormCustomParams({
|
||||||
...formCustomParams,
|
...formCustomParams,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { reduce } from 'lodash';
|
||||||
import {
|
import {
|
||||||
TopicName,
|
TopicName,
|
||||||
Topic,
|
Topic,
|
||||||
|
@ -5,6 +6,7 @@ import {
|
||||||
TopicDetails,
|
TopicDetails,
|
||||||
TopicConfig,
|
TopicConfig,
|
||||||
TopicFormData,
|
TopicFormData,
|
||||||
|
TopicFormCustomParam,
|
||||||
} from 'redux/interfaces';
|
} from 'redux/interfaces';
|
||||||
import {
|
import {
|
||||||
BASE_URL,
|
BASE_URL,
|
||||||
|
@ -23,6 +25,10 @@ export const getTopics = (clusterName: ClusterName): Promise<Topic[]> =>
|
||||||
fetch(`${BASE_URL}/clusters/${clusterName}/topics`, { ...BASE_PARAMS })
|
fetch(`${BASE_URL}/clusters/${clusterName}/topics`, { ...BASE_PARAMS })
|
||||||
.then(res => res.json());
|
.then(res => res.json());
|
||||||
|
|
||||||
|
interface Result {
|
||||||
|
[index: string]: string,
|
||||||
|
}
|
||||||
|
|
||||||
export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promise<Topic> => {
|
export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promise<Topic> => {
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
|
@ -34,6 +40,12 @@ export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promis
|
||||||
maxMessageBytes,
|
maxMessageBytes,
|
||||||
minInSyncReplicas,
|
minInSyncReplicas,
|
||||||
} = form;
|
} = form;
|
||||||
|
|
||||||
|
const customParams = reduce(Object.values(form.customParams), (result: Result, customParam: TopicFormCustomParam) => {
|
||||||
|
result[customParam.name] = customParam.value;
|
||||||
|
return result;
|
||||||
|
}, {});
|
||||||
|
|
||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
name,
|
name,
|
||||||
partitions,
|
partitions,
|
||||||
|
@ -44,8 +56,10 @@ export const postTopic = (clusterName: ClusterName, form: TopicFormData): Promis
|
||||||
'retention.bytes': retentionBytes,
|
'retention.bytes': retentionBytes,
|
||||||
'max.message.bytes': maxMessageBytes,
|
'max.message.bytes': maxMessageBytes,
|
||||||
'min.insync.replicas': minInSyncReplicas,
|
'min.insync.replicas': minInSyncReplicas,
|
||||||
|
...customParams,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return fetch(`${BASE_URL}/clusters/${clusterName}/topics`, {
|
return fetch(`${BASE_URL}/clusters/${clusterName}/topics`, {
|
||||||
...BASE_PARAMS,
|
...BASE_PARAMS,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
Loading…
Add table
Reference in a new issue