diff options
author | Philippe Perrin <philippe.perrin@sonarsource.com> | 2022-04-29 12:23:37 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-04-29 20:03:19 +0000 |
commit | 6bf84edcc61f2ffbf0cc2dfb84f97c0f8214417b (patch) | |
tree | e2dff1c44cb657963e9c5b2742857e4a6c7d10b9 /server/sonar-web/src | |
parent | 445764544cfc10e3b157a4337caed91ec684217e (diff) | |
download | sonarqube-6bf84edcc61f2ffbf0cc2dfb84f97c0f8214417b.tar.gz sonarqube-6bf84edcc61f2ffbf0cc2dfb84f97c0f8214417b.zip |
SONAR-16300 Fix activity graph options availability
Diffstat (limited to 'server/sonar-web/src')
2 files changed, 16 insertions, 8 deletions
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<Props, St .map(graph => 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<Props, St return ( <div className="project-activity-layout-page-main-inner boxed-group boxed-group-inner"> <GraphsHeader + addCustomMetric={this.addCustomMetric} className="big-spacer-bottom" graph={query.graph} metrics={metrics} metricsTypeFilter={this.getMetricsTypeFilter()} + removeCustomMetric={this.removeCustomMetric} selectedMetrics={this.props.query.customMetrics} updateGraph={this.updateGraph} /> @@ -209,6 +213,7 @@ export default class ProjectActivityGraphs extends React.PureComponent<Props, St leakPeriodDate={leakPeriodDate} loading={loading} measuresHistory={this.props.measuresHistory} + removeCustomMetric={this.removeCustomMetric} selectedDate={this.props.query.selectedDate} series={series} updateGraphZoom={this.updateGraphZoom} diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityGraphs-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityGraphs-test.tsx.snap index cbc6c857b88..b817fd80c5e 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityGraphs-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/ProjectActivityGraphs-test.tsx.snap @@ -5,6 +5,7 @@ exports[`should render correctly the graph and legends 1`] = ` className="project-activity-layout-page-main-inner boxed-group boxed-group-inner" > <GraphsHeader + addCustomMetric={[Function]} className="big-spacer-bottom" graph="issues" metrics={ @@ -17,6 +18,7 @@ exports[`should render correctly the graph and legends 1`] = ` }, ] } + removeCustomMetric={[Function]} selectedMetrics={Array []} updateGraph={[Function]} /> @@ -106,6 +108,7 @@ exports[`should render correctly the graph and legends 1`] = ` }, ] } + removeCustomMetric={[Function]} series={ Array [ Object { |