@@ -100,40 +100,22 @@ const OsExposureReportModal = ({
100
100
const [ selectedOsVersions , setSelectedOsVersions ] = useState ( [ ] ) ;
101
101
const [ filterData , setFilterData ] = useState ( {
102
102
impact : [ ] ,
103
- advisory_available : [ 'true' ]
103
+ advisory_available : [ 'true' , 'false' ]
104
104
} ) ;
105
105
const [ userNote , setUserNoteChange ] = useState ( '' ) ;
106
106
const [ isFetchLoading , setisFetchLoading ] = useState ( true ) ;
107
107
108
108
const CVE_REPORT_FILTERS = getCveReportFilters ( false , true ) ;
109
109
110
110
const selectedTotal = useMemo ( ( ) => {
111
- /**
112
- * Counts the total number of OS item objects in the provided data structure.
113
- *
114
- * @param {Array<Object> } selectedOsVersions - An array of dictionaries, where each dictionary
115
- * contains a key (e.g., "RHEL 8") and a value
116
- * that is an array of OS item objects.
117
- * @returns {number } An integer representing the total count of OS item objects.
118
- */
119
-
120
- // Initialize total_count to 0. This variable will store the cumulative count.
121
111
let totalCount = 0 ;
122
112
123
- // Iterate through each category object in the main dataStructure array.
124
- // For example, the first category object is { "RHEL 8": [...] }
125
113
for ( const categoryObject of selectedOsVersions ) {
126
- // For each categoryObject, iterate through its keys.
127
- // For example, the key would be "RHEL 8" or "RHEL 7".
128
114
for ( const key in categoryObject ) {
129
- // Ensure that the key belongs to the object itself and not its prototype.
130
115
if ( Object . prototype . hasOwnProperty . call ( categoryObject , key ) ) {
131
- // Get the array of OS items associated with the current key.
132
116
const osItemsArray = categoryObject [ key ] ;
133
117
134
- // Check if osItemsArray is actually an array before trying to get its length.
135
118
if ( Array . isArray ( osItemsArray ) ) {
136
- // Add the number of items in the current osItemsArray to the totalCount.
137
119
totalCount += osItemsArray . length ;
138
120
} else {
139
121
console . warn ( `Expected an array for key "${ key } ", but found:` , osItemsArray ) ;
@@ -142,7 +124,6 @@ const OsExposureReportModal = ({
142
124
}
143
125
}
144
126
145
- // Return the final total count.
146
127
return totalCount ;
147
128
} , [ selectedOsVersions ] ) ;
148
129
@@ -308,47 +289,39 @@ const OsExposureReportModal = ({
308
289
< Flex >
309
290
{ selectedOsVersions . length === 0
310
291
? < Text style = { { color : '#6a6e73' } } >
311
- Select at least 1 minor version of RHEL to further select the desired life cycle.
292
+ Select at least 1 minor version of RHEL to further select the desired life cycle.
312
293
</ Text >
313
- : exposureMap . map (
314
- ( majorVersionEntry , majorIndex ) => {
315
- return (
316
- Object . entries ( majorVersionEntry ) . map (
317
- ( [ majorVersion , minorValues ] ) => {
318
- return (
319
- minorValues . map ( ( {
320
- isSelected,
321
- os,
322
- osMinorVersion,
323
- lifecycles,
324
- selectedLifecycle
325
- } , minorIndex ) => {
326
- if ( isSelected ) {
327
- return (
328
- < FlexItem key = { `lifecycle-select-${ os } ` } >
329
- < LifecycleSelect
330
- isFetchLoading = { isFetchLoading }
331
- lifecycles = { lifecycles }
332
- osVersion = { os }
333
- selectedLifecycle = { selectedLifecycle }
334
- setSelectedLifecycle = { ( value ) => setSelectedLifecycle (
335
- majorVersion ,
336
- majorIndex ,
337
- osMinorVersion ,
338
- minorIndex ,
339
- value
340
- ) }
341
- />
342
- </ FlexItem >
343
- ) ;
344
- }
345
- } )
346
- ) ;
347
- }
348
- )
349
- ) ;
350
- }
351
- )
294
+ : exposureMap . map ( ( majorVersionEntry , majorIndex ) => {
295
+ Object . entries ( majorVersionEntry ) . map ( ( [ majorVersion , minorValues ] ) =>
296
+ minorValues . map ( ( {
297
+ isSelected,
298
+ os,
299
+ osMinorVersion,
300
+ lifecycles,
301
+ selectedLifecycle
302
+ } , minorIndex ) => {
303
+ if ( isSelected ) {
304
+ return (
305
+ < FlexItem key = { `lifecycle-select-${ os } ` } >
306
+ < LifecycleSelect
307
+ isFetchLoading = { isFetchLoading }
308
+ lifecycles = { lifecycles }
309
+ osVersion = { os }
310
+ selectedLifecycle = { selectedLifecycle }
311
+ setSelectedLifecycle = { ( value ) => setSelectedLifecycle (
312
+ majorVersion ,
313
+ majorIndex ,
314
+ osMinorVersion ,
315
+ minorIndex ,
316
+ value
317
+ ) }
318
+ />
319
+ </ FlexItem >
320
+ ) ;
321
+ }
322
+ } )
323
+ ) ;
324
+ } )
352
325
}
353
326
</ Flex >
354
327
</ FormGroup >
0 commit comments