File tree 3 files changed +35
-1
lines changed
3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
22
22
getUnresolvedExternalAttributions ,
23
23
} from '../../state/selectors/resource-selectors' ;
24
24
import { useShowClassifications } from '../../state/variables/use-show-classifications' ;
25
+ import { useShowCriticality } from '../../state/variables/use-show-criticality' ;
25
26
import { useUserSetting } from '../../state/variables/use-user-setting' ;
26
27
import { AttributionCountPerSourcePerLicenseTable } from '../AttributionCountPerSourcePerLicenseTable/AttributionCountPerSourcePerLicenseTable' ;
27
28
import { BarChart } from '../BarChart/BarChart' ;
@@ -94,6 +95,7 @@ export const ProjectStatisticsPopup: React.FC = () => {
94
95
const [ selectedTab , setSelectedTab ] = useState ( 0 ) ;
95
96
96
97
const [ showClassifications ] = useShowClassifications ( ) ;
98
+ const [ showCriticality ] = useShowCriticality ( ) ;
97
99
98
100
return (
99
101
< NotificationPopup
@@ -137,7 +139,9 @@ export const ProjectStatisticsPopup: React.FC = () => {
137
139
< PieChart segments = { mostFrequentLicenseCountData } />
138
140
</ ChartGridItem >
139
141
< ChartGridItem
140
- shouldRender = { criticalSignalsCount . length > 0 }
142
+ shouldRender = {
143
+ criticalSignalsCount . length > 0 && showCriticality
144
+ }
141
145
testId = { 'criticalSignalsCountPieChart' }
142
146
>
143
147
< MuiTypography variant = "subtitle1" >
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { Attributions, Criticality } from '../../../../shared/shared-types';
9
9
import { text } from '../../../../shared/text' ;
10
10
import { loadFromFile } from '../../../state/actions/resource-actions/load-actions' ;
11
11
import { SHOW_CLASSIFICATIONS_KEY } from '../../../state/variables/use-show-classifications' ;
12
+ import { SHOW_CRITICALITY_KEY } from '../../../state/variables/use-show-criticality' ;
12
13
import { getParsedInputFileEnrichedWithTestData } from '../../../test-helpers/general-test-helpers' ;
13
14
import { renderComponent } from '../../../test-helpers/render' ;
14
15
import { setUserSetting } from '../../../test-helpers/user-settings-helpers' ;
@@ -319,6 +320,21 @@ describe('The ProjectStatisticsPopup', () => {
319
320
) . not . toBeInTheDocument ( ) ;
320
321
} ) ;
321
322
323
+ it ( 'does not show the criticality statistics if it has been disabled' , ( ) => {
324
+ renderComponent ( < ProjectStatisticsPopup /> , {
325
+ actions : [
326
+ setUserSetting ( SHOW_CRITICALITY_KEY , false ) ,
327
+ loadFromFile ( getParsedInputFileEnrichedWithTestData ( fileSetup ) ) ,
328
+ ] ,
329
+ } ) ;
330
+
331
+ expect (
332
+ screen . queryByText (
333
+ text . projectStatisticsPopup . charts . criticalSignalsCountPieChart . title ,
334
+ ) ,
335
+ ) . not . toBeInTheDocument ( ) ;
336
+ } ) ;
337
+
322
338
it ( 'allows toggling of show-on-startup checkbox' , async ( ) => {
323
339
renderComponent ( < ProjectStatisticsPopup /> ) ;
324
340
Original file line number Diff line number Diff line change
1
+ // SPDX-FileCopyrightText: Meta Platforms, Inc. and its affiliates
2
+ // SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
3
+ //
4
+ // SPDX-License-Identifier: Apache-2.0
5
+ import { useUserSetting } from './use-user-setting' ;
6
+
7
+ export const SHOW_CRITICALITY_KEY = 'showCriticality' ;
8
+
9
+ export function useShowCriticality ( ) {
10
+ return useUserSetting ( {
11
+ key : SHOW_CRITICALITY_KEY ,
12
+ defaultValue : true ,
13
+ } ) ;
14
+ }
You can’t perform that action at this time.
0 commit comments