@@ -36,6 +36,17 @@ const CleanupPolicyOptions: Array<SelectOption> = [
36
36
{ value : 'compact,delete' , label : 'Compact,Delete' } ,
37
37
] ;
38
38
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
+
39
50
const RetentionBytesOptions : Array < SelectOption > = [
40
51
{ value : NOT_SET , label : 'Not Set' } ,
41
52
{ value : BYTES_IN_GB , label : '1 GB' } ,
@@ -61,12 +72,7 @@ const TopicForm: React.FC<Props> = ({
61
72
const navigate = useNavigate ( ) ;
62
73
const { clusterName } = useAppParams < { clusterName : ClusterName } > ( ) ;
63
74
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 ;
70
76
71
77
const getRetentionBytes =
72
78
RetentionBytesOptions . find ( ( option : SelectOption ) => {
@@ -97,8 +103,8 @@ const TopicForm: React.FC<Props> = ({
97
103
</ S . NameField >
98
104
</ S . Column >
99
105
100
- { ! isEditing && (
101
- < S . Column >
106
+ < S . Column >
107
+ { ! isEditing && (
102
108
< div >
103
109
< InputLabel htmlFor = "topicFormNumberOfPartitions" >
104
110
Number of partitions *
@@ -114,32 +120,33 @@ const TopicForm: React.FC<Props> = ({
114
120
< ErrorMessage errors = { errors } name = "partitions" />
115
121
</ FormError >
116
122
</ 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 >
143
150
</ fieldset >
144
151
145
152
< S . Column >
0 commit comments