Support "compact,delete" cleanup policy (#983)
* Fix #973 * Fix topic edition errors Fixed two errors 1. The error with cleanup policy. Since some of the custom params (like, cleanup policy) are moved to the general form, we were not supposed to add them to the custom params section. Added filtration for this. 2. Fixed the variable name for Min In Sync Replicas to match the name in the contract Co-authored-by: Alexander <mr.afigitelniychuvak@gmail.com>
This commit is contained in:
parent
cf3708a3e1
commit
77226a2144
4 changed files with 14 additions and 8 deletions
|
@ -13,6 +13,7 @@ import { camelCase } from 'lodash';
|
|||
import TopicForm from 'components/Topics/shared/Form/TopicForm';
|
||||
import { clusterTopicPath } from 'lib/paths';
|
||||
import { useHistory } from 'react-router';
|
||||
import { TOPIC_CUSTOM_PARAMS } from 'lib/constants';
|
||||
|
||||
import DangerZoneContainer from './DangerZoneContainer';
|
||||
|
||||
|
@ -65,7 +66,11 @@ const topicParams = (topic: TopicWithDetailedInfo | undefined) => {
|
|||
partitions: topic.partitionCount || DEFAULTS.partitions,
|
||||
replicationFactor,
|
||||
customParams: topic.config
|
||||
?.filter((el) => el.value !== el.defaultValue)
|
||||
?.filter(
|
||||
(el) =>
|
||||
el.value !== el.defaultValue &&
|
||||
Object.keys(TOPIC_CUSTOM_PARAMS).includes(el.name)
|
||||
)
|
||||
.map((el) => ({ name: el.name, value: el.value })),
|
||||
...configs,
|
||||
};
|
||||
|
|
|
@ -98,7 +98,7 @@ const TopicForm: React.FC<Props> = ({
|
|||
type="number"
|
||||
placeholder="Min In Sync Replicas"
|
||||
defaultValue="1"
|
||||
{...register('minInSyncReplicas', {
|
||||
{...register('minInsyncReplicas', {
|
||||
required: 'Min In Sync Replicas is required.',
|
||||
})}
|
||||
/>
|
||||
|
@ -115,6 +115,7 @@ const TopicForm: React.FC<Props> = ({
|
|||
<select defaultValue="delete" {...register('cleanupPolicy')}>
|
||||
<option value="delete">Delete</option>
|
||||
<option value="compact">Compact</option>
|
||||
<option value="compact,delete">Compact,Delete</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -171,7 +171,7 @@ export const formatTopicCreation = (form: TopicFormData): TopicCreation => {
|
|||
retentionBytes,
|
||||
retentionMs,
|
||||
maxMessageBytes,
|
||||
minInSyncReplicas,
|
||||
minInsyncReplicas,
|
||||
customParams,
|
||||
} = form;
|
||||
|
||||
|
@ -184,7 +184,7 @@ export const formatTopicCreation = (form: TopicFormData): TopicCreation => {
|
|||
'retention.ms': retentionMs.toString(),
|
||||
'retention.bytes': retentionBytes.toString(),
|
||||
'max.message.bytes': maxMessageBytes.toString(),
|
||||
'min.insync.replicas': minInSyncReplicas.toString(),
|
||||
'min.insync.replicas': minInsyncReplicas.toString(),
|
||||
...Object.values(customParams || {}).reduce(topicReducer, {}),
|
||||
},
|
||||
};
|
||||
|
@ -196,7 +196,7 @@ const formatTopicUpdate = (form: TopicFormDataRaw): TopicUpdate => {
|
|||
retentionBytes,
|
||||
retentionMs,
|
||||
maxMessageBytes,
|
||||
minInSyncReplicas,
|
||||
minInsyncReplicas,
|
||||
customParams,
|
||||
} = form;
|
||||
|
||||
|
@ -206,7 +206,7 @@ const formatTopicUpdate = (form: TopicFormDataRaw): TopicUpdate => {
|
|||
'retention.ms': retentionMs,
|
||||
'retention.bytes': retentionBytes,
|
||||
'max.message.bytes': maxMessageBytes,
|
||||
'min.insync.replicas': minInSyncReplicas,
|
||||
'min.insync.replicas': minInsyncReplicas,
|
||||
...Object.values(customParams || {}).reduce(topicReducer, {}),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -62,7 +62,7 @@ export interface TopicFormDataRaw {
|
|||
name: string;
|
||||
partitions: number;
|
||||
replicationFactor: number;
|
||||
minInSyncReplicas: number;
|
||||
minInsyncReplicas: number;
|
||||
cleanupPolicy: string;
|
||||
retentionMs: number;
|
||||
retentionBytes: number;
|
||||
|
@ -74,7 +74,7 @@ export interface TopicFormData {
|
|||
name: string;
|
||||
partitions: number;
|
||||
replicationFactor: number;
|
||||
minInSyncReplicas: number;
|
||||
minInsyncReplicas: number;
|
||||
cleanupPolicy: string;
|
||||
retentionMs: number;
|
||||
retentionBytes: number;
|
||||
|
|
Loading…
Add table
Reference in a new issue