aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx
diff options
context:
space:
mode:
author7PH <benjamin.raymond@sonarsource.com>2023-04-20 16:50:05 +0200
committersonartech <sonartech@sonarsource.com>2023-04-25 20:03:00 +0000
commitfc5bd48d213b39a83a3828eaec1a9e89b5b88fbd (patch)
tree0d81471df337e39de2e3c750f6a73852415cca4a /server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx
parent42cb161d1bfde44f942a0347057d916ea2113713 (diff)
downloadsonarqube-fc5bd48d213b39a83a3828eaec1a9e89b5b88fbd.tar.gz
sonarqube-fc5bd48d213b39a83a3828eaec1a9e89b5b88fbd.zip
SONAR-19069 Add Fit for Development and Fit for Production facets
Diffstat (limited to 'server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx')
-rw-r--r--server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx70
1 files changed, 42 insertions, 28 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx
index ffad87ea9bb..dc3e038eb77 100644
--- a/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx
+++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesApp.tsx
@@ -19,7 +19,7 @@
*/
import styled from '@emotion/styled';
import classNames from 'classnames';
-import { debounce, keyBy, omit, without } from 'lodash';
+import { debounce, get, keyBy, omit, set, without } from 'lodash';
import * as React from 'react';
import { Helmet } from 'react-helmet-async';
import { FormattedMessage } from 'react-intl';
@@ -69,6 +69,7 @@ import {
ASSIGNEE_ME,
Facet,
FetchIssuesPromise,
+ IssueCharacteristicFitFor,
ReferencedComponent,
ReferencedLanguage,
ReferencedRule,
@@ -82,6 +83,7 @@ import ConciseIssuesListHeader from '../conciseIssuesList/ConciseIssuesListHeade
import Sidebar from '../sidebar/Sidebar';
import '../styles.css';
import {
+ OpenFacets,
Query,
STANDARDS,
areMyIssuesSelected,
@@ -127,7 +129,7 @@ export interface State {
loadingMore: boolean;
locationsNavigator: boolean;
myIssues: boolean;
- openFacets: Dict<boolean>;
+ openFacets: OpenFacets;
openIssue?: Issue;
openPopup?: { issue: string; name: string };
openRuleDetails?: RuleDetails;
@@ -167,16 +169,19 @@ export class App extends React.PureComponent<Props, State> {
locationsNavigator: false,
myIssues: areMyIssuesSelected(props.location.query),
openFacets: {
+ characteristics: {
+ [IssueCharacteristicFitFor.Production]: true,
+ [IssueCharacteristicFitFor.Development]: true,
+ },
+ severities: true,
owaspTop10: shouldOpenStandardsChildFacet({}, query, SecurityStandard.OWASP_TOP10),
'owaspTop10-2021': shouldOpenStandardsChildFacet(
{},
query,
SecurityStandard.OWASP_TOP10_2021
),
- severities: true,
sonarsourceSecurity: shouldOpenSonarSourceSecurityFacet({}, query),
standards: shouldOpenStandardsFacet({}, query),
- types: true,
},
query,
referencedComponentsById: {},
@@ -700,32 +705,41 @@ export class App extends React.PureComponent<Props, State> {
}));
};
- handleFacetToggle = (property: string) => {
- this.setState((state) => {
- const willOpenProperty = !state.openFacets[property];
- const newState = {
- loadingFacets: state.loadingFacets,
- openFacets: { ...state.openFacets, [property]: willOpenProperty },
- };
-
- // Try to open sonarsource security "subfacet" by default if the standard facet is open
- if (willOpenProperty && property === STANDARDS) {
- newState.openFacets.sonarsourceSecurity = shouldOpenSonarSourceSecurityFacet(
- newState.openFacets,
- state.query
- );
- // Force loading of sonarsource security facet data
- property = newState.openFacets.sonarsourceSecurity ? 'sonarsourceSecurity' : property;
- }
+ /**
+ * @param property Facet property within openFacets. Can be a path, e.g. 'characteristics.PRODUCTION'
+ */
+ handleFacetToggle = async (property: string) => {
+ const willOpenProperty = !get(this.state.openFacets, property);
+ const newState = {
+ loadingFacets: this.state.loadingFacets,
+ openFacets: { ...this.state.openFacets },
+ };
+ set(newState.openFacets, property, willOpenProperty);
- // No need to load facets data for standard facet
- if (property !== STANDARDS && !state.facets[property]) {
- newState.loadingFacets[property] = true;
- this.fetchFacet(property);
- }
+ // Try to open sonarsource security "subfacet" by default if the standard facet is open
+ if (property === STANDARDS && willOpenProperty) {
+ newState.openFacets.sonarsourceSecurity = shouldOpenSonarSourceSecurityFacet(
+ newState.openFacets,
+ this.state.query
+ );
+ // Force loading of sonarsource security facet data
+ property = newState.openFacets.sonarsourceSecurity ? 'sonarsourceSecurity' : property;
+ }
- return newState;
- });
+ // No need to load facets data for standard facet
+ if (property !== STANDARDS) {
+ newState.loadingFacets[property] = true;
+ }
+
+ this.setState(newState);
+
+ // No need to load facets data for standard facet
+ if (property !== STANDARDS) {
+ // Fetch facet from the backend, only keeping first level of the property,
+ // eg will send 'characteristics' for property 'characteristics.PRODUCTION'
+ const facetName = property.split('.')[0];
+ await this.fetchFacet(facetName);
+ }
};
handleReset = () => {