From: Philippe Perrin Date: Fri, 29 Apr 2022 10:23:37 +0000 (+0200) Subject: SONAR-16300 Fix activity graph options availability X-Git-Tag: 9.5.0.56709~185 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6bf84edcc61f2ffbf0cc2dfb84f97c0f8214417b;p=sonarqube.git SONAR-16300 Fix activity graph options availability --- diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx index 2ac68912d7c..57b70d18ebe 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.tsx @@ -142,14 +142,16 @@ export default class ProjectActivityGraphs extends React.PureComponent graph[0].type); }; - updateSelectedMetrics = (selectedMetrics: string[]) => { - saveActivityGraph( - PROJECT_ACTIVITY_GRAPH, - this.props.project, - GraphType.custom, - selectedMetrics - ); - this.props.updateQuery({ customMetrics: selectedMetrics }); + addCustomMetric = (metric: string) => { + const customMetrics = [...this.props.query.customMetrics, metric]; + saveActivityGraph(PROJECT_ACTIVITY_GRAPH, this.props.project, GraphType.custom, customMetrics); + this.props.updateQuery({ customMetrics }); + }; + + removeCustomMetric = (removedMetric: string) => { + const customMetrics = this.props.query.customMetrics.filter(metric => metric !== removedMetric); + saveActivityGraph(PROJECT_ACTIVITY_GRAPH, this.props.project, GraphType.custom, customMetrics); + this.props.updateQuery({ customMetrics }); }; updateGraph = (graph: GraphType) => { @@ -193,10 +195,12 @@ export default class ProjectActivityGraphs extends React.PureComponent @@ -209,6 +213,7 @@ export default class ProjectActivityGraphs extends React.PureComponent @@ -106,6 +108,7 @@ exports[`should render correctly the graph and legends 1`] = ` }, ] } + removeCustomMetric={[Function]} series={ Array [ Object {