@@ -32,6 +32,7 @@ import { Link } from "react-router-dom";
32
32
import { Paths } from "@app/Paths" ;
33
33
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing" ;
34
34
import RiskIcon from "@app/components/risk-icon/risk-icon" ;
35
+ import { FilterToolbar , FilterType } from "@app/components/FilterToolbar" ;
35
36
36
37
export interface IIdentifiedRisksTableProps {
37
38
assessmentRefs ?: IdRef [ ] ;
@@ -152,6 +153,7 @@ export const IdentifiedRisksTable: React.FC<IIdentifiedRisksTableProps> = ({
152
153
} ,
153
154
variant : "compact" ,
154
155
isPaginationEnabled : true ,
156
+ isFilterEnabled : true ,
155
157
isSortEnabled : true ,
156
158
hasActionsColumn : false ,
157
159
getSortValues : ( item ) => ( {
@@ -173,6 +175,86 @@ export const IdentifiedRisksTable: React.FC<IIdentifiedRisksTableProps> = ({
173
175
] ,
174
176
isExpansionEnabled : true ,
175
177
expandableVariant : "single" ,
178
+ filterCategories : [
179
+ {
180
+ key : "questionnaireName" ,
181
+ title : t ( "terms.questionnaire" ) ,
182
+ type : FilterType . multiselect ,
183
+ placeholderText :
184
+ t ( "actions.filterBy" , {
185
+ what : t ( "terms.questionnaire" ) . toLowerCase ( ) ,
186
+ } ) + "..." ,
187
+ getItemValue : ( item ) => item . questionnaireName || "" ,
188
+ selectOptions : [
189
+ ...new Set (
190
+ tableData . map ( ( item ) => item . questionnaireName ) . filter ( Boolean )
191
+ ) ,
192
+ ] . map ( ( name ) => ( { key : name , value : name } ) ) ,
193
+ } ,
194
+ {
195
+ key : "section" ,
196
+ title : t ( "terms.section" ) ,
197
+ type : FilterType . multiselect ,
198
+ placeholderText :
199
+ t ( "actions.filterBy" , {
200
+ what : t ( "terms.section" ) . toLowerCase ( ) ,
201
+ } ) + "..." ,
202
+ getItemValue : ( item ) => item . section || "" ,
203
+ selectOptions : [
204
+ ...new Set ( tableData . map ( ( item ) => item . section ) . filter ( Boolean ) ) ,
205
+ ] . map ( ( name ) => ( { key : name , value : name } ) ) ,
206
+ } ,
207
+ {
208
+ key : "question" ,
209
+ title : t ( "terms.question" ) ,
210
+ type : FilterType . multiselect ,
211
+ placeholderText :
212
+ t ( "actions.filterBy" , {
213
+ what : t ( "terms.question" ) . toLowerCase ( ) ,
214
+ } ) + "..." ,
215
+ getItemValue : ( item ) => item . question . text || "" ,
216
+ selectOptions : [
217
+ ...new Set (
218
+ tableData . map ( ( item ) => item . question . text ) . filter ( Boolean )
219
+ ) ,
220
+ ] . map ( ( name ) => ( { key : name , value : name } ) ) ,
221
+ } ,
222
+ {
223
+ key : "answer" ,
224
+ title : t ( "terms.answer" ) ,
225
+ type : FilterType . multiselect ,
226
+ placeholderText :
227
+ t ( "actions.filterBy" , {
228
+ what : t ( "terms.answer" ) . toLowerCase ( ) ,
229
+ } ) + "..." ,
230
+ getItemValue : ( item ) => item . answer . text || "" ,
231
+ selectOptions : [
232
+ ...new Set ( tableData . map ( ( item ) => item . answer . text ) . filter ( Boolean ) ) ,
233
+ ] . map ( ( name ) => ( { key : name , value : name } ) ) ,
234
+ } ,
235
+ {
236
+ key : "risk" ,
237
+ title : t ( "terms.risk" ) ,
238
+ type : FilterType . multiselect ,
239
+ placeholderText :
240
+ t ( "actions.filterBy" , { what : t ( "terms.risk" ) . toLowerCase ( ) } ) +
241
+ "..." ,
242
+ getItemValue : ( item : ITableRowData ) => {
243
+ const riskKey = item . answer . risk ;
244
+ const riskValue =
245
+ riskLevelMapping [ riskKey as keyof typeof riskLevelMapping ] ;
246
+ return riskValue . toString ( ) ;
247
+ } ,
248
+ selectOptions : [
249
+ { key : "3" , value : "High" } ,
250
+ { key : "2" , value : "Medium" } ,
251
+ { key : "1" , value : "Low" } ,
252
+ { key : "0" , value : "Unknown" } ,
253
+ ] ,
254
+ } ,
255
+ ] ,
256
+ initialItemsPerPage : 10 ,
257
+ isSelectionEnabled : false ,
176
258
} ) ;
177
259
178
260
const {
@@ -181,6 +263,7 @@ export const IdentifiedRisksTable: React.FC<IIdentifiedRisksTableProps> = ({
181
263
propHelpers : {
182
264
toolbarProps,
183
265
paginationToolbarItemProps,
266
+ filterToolbarProps,
184
267
paginationProps,
185
268
tableProps,
186
269
getThProps,
@@ -196,6 +279,8 @@ export const IdentifiedRisksTable: React.FC<IIdentifiedRisksTableProps> = ({
196
279
< >
197
280
< Toolbar { ...toolbarProps } >
198
281
< ToolbarContent >
282
+ < FilterToolbar < ITableRowData , string > { ...filterToolbarProps } />
283
+
199
284
< ToolbarItem { ...paginationToolbarItemProps } >
200
285
< SimplePagination
201
286
idPrefix = { `${ "identified-risks-table" } }` }
0 commit comments