@@ -36,6 +36,17 @@ const CleanupPolicyOptions: Array<SelectOption> = [
3636 { value : 'compact,delete' , label : 'Compact,Delete' } ,
3737] ;
3838
39+ export const getCleanUpPolicyValue = ( cleanUpPolicy ?: string ) => {
40+ if ( ! cleanUpPolicy ) return undefined ;
41+
42+ return CleanupPolicyOptions . find ( ( option : SelectOption ) => {
43+ return (
44+ option . value . toString ( ) . replace ( / , / g, '_' ) ===
45+ cleanUpPolicy ?. toLowerCase ( )
46+ ) ;
47+ } ) ?. value . toString ( ) ;
48+ } ;
49+
3950const RetentionBytesOptions : Array < SelectOption > = [
4051 { value : NOT_SET , label : 'Not Set' } ,
4152 { value : BYTES_IN_GB , label : '1 GB' } ,
@@ -61,12 +72,7 @@ const TopicForm: React.FC<Props> = ({
6172 const navigate = useNavigate ( ) ;
6273 const { clusterName } = useAppParams < { clusterName : ClusterName } > ( ) ;
6374 const getCleanUpPolicy =
64- CleanupPolicyOptions . find ( ( option : SelectOption ) => {
65- return (
66- option . value . toString ( ) . replace ( / , / g, '_' ) ===
67- cleanUpPolicy ?. toLowerCase ( )
68- ) ;
69- } ) ?. value || CleanupPolicyOptions [ 0 ] . value ;
75+ getCleanUpPolicyValue ( cleanUpPolicy ) || CleanupPolicyOptions [ 0 ] . value ;
7076
7177 const getRetentionBytes =
7278 RetentionBytesOptions . find ( ( option : SelectOption ) => {
@@ -97,8 +103,8 @@ const TopicForm: React.FC<Props> = ({
97103 </ S . NameField >
98104 </ S . Column >
99105
100- { ! isEditing && (
101- < S . Column >
106+ < S . Column >
107+ { ! isEditing && (
102108 < div >
103109 < InputLabel htmlFor = "topicFormNumberOfPartitions" >
104110 Number of partitions *
@@ -114,32 +120,33 @@ const TopicForm: React.FC<Props> = ({
114120 < ErrorMessage errors = { errors } name = "partitions" />
115121 </ FormError >
116122 </ div >
117- < div >
118- < InputLabel
119- id = "topicFormCleanupPolicyLabel"
120- htmlFor = "topicFormCleanupPolicy"
121- >
122- Cleanup policy
123- </ InputLabel >
124- < Controller
125- defaultValue = { CleanupPolicyOptions [ 0 ] . value }
126- control = { control }
127- name = "cleanupPolicy"
128- render = { ( { field : { name, onChange } } ) => (
129- < Select
130- id = "topicFormCleanupPolicy"
131- aria-labelledby = "topicFormCleanupPolicyLabel"
132- name = { name }
133- value = { getCleanUpPolicy }
134- onChange = { onChange }
135- minWidth = "250px"
136- options = { CleanupPolicyOptions }
137- />
138- ) }
139- />
140- </ div >
141- </ S . Column >
142- ) }
123+ ) }
124+
125+ < div >
126+ < InputLabel
127+ id = "topicFormCleanupPolicyLabel"
128+ htmlFor = "topicFormCleanupPolicy"
129+ >
130+ Cleanup policy
131+ </ InputLabel >
132+ < Controller
133+ defaultValue = { CleanupPolicyOptions [ 0 ] . value }
134+ control = { control }
135+ name = "cleanupPolicy"
136+ render = { ( { field : { name, onChange } } ) => (
137+ < Select
138+ id = "topicFormCleanupPolicy"
139+ aria-labelledby = "topicFormCleanupPolicyLabel"
140+ name = { name }
141+ value = { getCleanUpPolicy }
142+ onChange = { onChange }
143+ minWidth = "250px"
144+ options = { CleanupPolicyOptions }
145+ />
146+ ) }
147+ />
148+ </ div >
149+ </ S . Column >
143150 </ fieldset >
144151
145152 < S . Column >
0 commit comments