4
4
DATE_TIME_FORMATS ,
5
5
DEFAULT_BASE_PAGE_SIZE ,
6
6
ErrorScreenManager ,
7
- FilterButton ,
8
7
GenericEmptyState ,
9
8
Pagination ,
10
9
SearchBar ,
@@ -19,6 +18,8 @@ import {
19
18
SortableTableHeaderCell ,
20
19
abortPreviousRequests ,
21
20
getIsRequestAborted ,
21
+ FilterSelectPicker ,
22
+ SelectPickerOptionType ,
22
23
} from '@devtron-labs/devtron-fe-common-lib'
23
24
import { useMemo , useRef , useState } from 'react'
24
25
import { ScanDetailsModal , getSeverityWithCount } from '@Components/common'
@@ -117,22 +118,37 @@ export const SecurityScansTab = () => {
117
118
[ filterConfig ] ,
118
119
)
119
120
120
- const updateSeverityFilters = ( selectedOptions : string [ ] ) => {
121
- updateSearchParams ( { severity : selectedOptions } )
121
+ const updateSeverityFilters = ( selectedOptions : SelectPickerOptionType [ ] ) => {
122
+ updateSearchParams ( { severity : selectedOptions . map ( ( severityOption ) => String ( severityOption . value ) ) } )
122
123
}
123
124
124
- const updateEnvironmentFilters = ( selectedOptions : string [ ] ) => {
125
- updateSearchParams ( { environment : selectedOptions } )
125
+ const updateEnvironmentFilters = ( selectedOptions : SelectPickerOptionType [ ] ) => {
126
+ updateSearchParams ( { environment : selectedOptions . map ( ( envOption ) => String ( envOption . value ) ) } )
126
127
}
127
128
128
- const updateClusterFilters = ( selectedOptions : string [ ] ) => {
129
- updateSearchParams ( { cluster : selectedOptions } )
129
+ const updateClusterFilters = ( selectedOptions : SelectPickerOptionType [ ] ) => {
130
+ updateSearchParams ( { cluster : selectedOptions . map ( ( clusterOption ) => String ( clusterOption . value ) ) } )
130
131
}
131
132
132
133
const updateSearchType = ( selectedOption : OptionType ) => {
133
134
updateSearchParams ( { searchType : selectedOption . value } )
134
135
}
135
136
137
+ const selectedSeverities = severity . map ( ( severityId ) => ( {
138
+ label : getSeverityFilterLabelFromValue ( severityId ) ,
139
+ value : severityId ,
140
+ } ) )
141
+
142
+ const selectedEnvironments = environment . map ( ( envId ) => ( {
143
+ label : getLabelFromValue ( SecurityScansTabMultiFilterKeys . environment , envId ) ,
144
+ value : envId ,
145
+ } ) )
146
+
147
+ const selectedClusters = cluster . map ( ( clusterId ) => ( {
148
+ label : getLabelFromValue ( SecurityScansTabMultiFilterKeys . cluster , clusterId ) ,
149
+ value : clusterId ,
150
+ } ) )
151
+
136
152
const handleAppNameSorting = ( ) => handleSorting ( SecurityListSortableKeys . APP_NAME )
137
153
const handleEnvNameSorting = ( ) => handleSorting ( SecurityListSortableKeys . ENV_NAME )
138
154
const handleLastCheckedSorting = ( ) => handleSorting ( SecurityListSortableKeys . LAST_CHECKED )
@@ -225,30 +241,33 @@ export const SecurityScansTab = () => {
225
241
/>
226
242
</ div >
227
243
< div className = "flexbox dc__gap-8" >
228
- < FilterButton
244
+ < FilterSelectPicker
245
+ inputId = "security-severity-filter"
229
246
placeholder = "Severity"
230
- disabled = { clusterEnvListLoading }
231
- appliedFilters = { severity }
232
- options = { clusterEnvListResult ?. filters ?. severity }
233
- handleApplyChange = { updateSeverityFilters }
234
- controlWidth = "140px"
247
+ isDisabled = { clusterEnvListLoading }
248
+ isLoading = { clusterEnvListLoading }
249
+ appliedFilterOptions = { selectedSeverities }
250
+ handleApplyFilter = { updateSeverityFilters }
251
+ options = { clusterEnvListResult ?. filters . severity }
235
252
/>
236
- < FilterButton
253
+ < FilterSelectPicker
254
+ inputId = "security-cluster-filter"
237
255
placeholder = "Cluster"
238
- disabled = { clusterEnvListLoading }
239
- appliedFilters = { cluster }
240
- options = { clusterEnvListResult ?. filters ?. clusters || [ ] }
241
- handleApplyChange = { updateClusterFilters }
242
- controlWidth = "140px"
256
+ isDisabled = { clusterEnvListLoading }
257
+ isLoading = { clusterEnvListLoading }
258
+ appliedFilterOptions = { selectedClusters }
259
+ handleApplyFilter = { updateClusterFilters }
260
+ options = { clusterEnvListResult ?. filters . clusters }
243
261
/>
244
- < FilterButton
262
+ < FilterSelectPicker
263
+ inputId = "security-environment-filter"
245
264
placeholder = "Environment"
246
- disabled = { clusterEnvListLoading }
247
- appliedFilters = { environment }
248
- options = { clusterEnvListResult ?. filters ?. environments || [ ] }
249
- handleApplyChange = { updateEnvironmentFilters }
250
- menuAlignFromRight
251
- controlWidth = "175px"
265
+ isDisabled = { clusterEnvListLoading }
266
+ isLoading = { clusterEnvListLoading }
267
+ appliedFilterOptions = { selectedEnvironments }
268
+ handleApplyFilter = { updateEnvironmentFilters }
269
+ options = { clusterEnvListResult ?. filters . environments }
270
+ shouldMenuAlignRight
252
271
/>
253
272
</ div >
254
273
</ div >
0 commit comments