From 544c4c57a45afbea604cf0cf02eeb268f59565e6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Fri, 21 Jul 2017 11:38:41 +0200 Subject: [PATCH] Rename project activity graph Overview to Issues --- .../main/js/apps/overview/components/OverviewApp.js | 4 ++-- .../src/main/js/apps/overview/events/PreviewGraph.js | 3 ++- .../events/__tests__/PreviewGraphTooltips-test.js | 3 ++- .../js/apps/projectActivity/__tests__/utils-test.js | 12 ++++++------ .../projectActivity/components/GraphsTooltips.js | 7 ++++--- ...entOverview.js => GraphsTooltipsContentIssues.js} | 4 ++-- .../components/ProjectActivityAppContainer.js | 3 ++- .../components/__tests__/GraphHistory-test.js | 3 ++- .../components/__tests__/GraphsHistory-test.js | 3 ++- .../components/__tests__/GraphsTooltips-test.js | 9 +++++---- ...w-test.js => GraphsTooltipsContentIssues-test.js} | 10 +++++----- .../__tests__/ProjectActivityAnalysesList-test.js | 2 +- .../components/__tests__/ProjectActivityApp-test.js | 2 +- .../__tests__/ProjectActivityGraphs-test.js | 3 ++- .../__snapshots__/GraphsHistory-test.js.snap | 6 +++--- .../__snapshots__/GraphsTooltips-test.js.snap | 8 ++++---- ...snap => GraphsTooltipsContentIssues-test.js.snap} | 4 ++-- .../__snapshots__/ProjectActivityApp-test.js.snap | 4 ++-- .../__snapshots__/ProjectActivityGraphs-test.js.snap | 4 ++-- .../projectActivity/components/projectActivity.css | 2 +- .../src/main/js/apps/projectActivity/utils.js | 11 ++++++----- server/sonar-web/src/main/js/helpers/storage.js | 2 +- .../main/resources/org/sonar/l10n/core.properties | 2 +- 23 files changed, 60 insertions(+), 51 deletions(-) rename server/sonar-web/src/main/js/apps/projectActivity/components/{GraphsTooltipsContentOverview.js => GraphsTooltipsContentIssues.js} (96%) rename server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/{GraphsTooltipsContentOverview-test.js => GraphsTooltipsContentIssues-test.js} (82%) rename server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/{GraphsTooltipsContentOverview-test.js.snap => GraphsTooltipsContentIssues-test.js.snap} (88%) diff --git a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.js b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.js index 8ca0ce8f45c..bbde489216a 100644 --- a/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.js +++ b/server/sonar-web/src/main/js/apps/overview/components/OverviewApp.js @@ -35,7 +35,7 @@ import { getLeakPeriod } from '../../../helpers/periods'; import { TooltipsContainer } from '../../../components/mixins/tooltips-mixin'; import { getCustomGraph, getGraph } from '../../../helpers/storage'; import { METRICS, HISTORY_METRICS_LIST } from '../utils'; -import { getDisplayedHistoryMetrics } from '../../projectActivity/utils'; +import { DEFAULT_GRAPH, getDisplayedHistoryMetrics } from '../../projectActivity/utils'; import type { Component, History, MeasuresList, Period } from '../types'; import '../styles.css'; @@ -103,7 +103,7 @@ export default class OverviewApp extends React.PureComponent { loadHistory(component: Component) { let graphMetrics = getDisplayedHistoryMetrics(getGraph(), getCustomGraph()); if (!graphMetrics || graphMetrics.length <= 0) { - graphMetrics = getDisplayedHistoryMetrics('overview', []); + graphMetrics = getDisplayedHistoryMetrics(DEFAULT_GRAPH, []); } const metrics = uniq(HISTORY_METRICS_LIST.concat(graphMetrics)); diff --git a/server/sonar-web/src/main/js/apps/overview/events/PreviewGraph.js b/server/sonar-web/src/main/js/apps/overview/events/PreviewGraph.js index ed1bc391b18..2f84509a196 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/PreviewGraph.js +++ b/server/sonar-web/src/main/js/apps/overview/events/PreviewGraph.js @@ -22,6 +22,7 @@ import React from 'react'; import { minBy } from 'lodash'; import { AutoSizer } from 'react-virtualized'; import { + DEFAULT_GRAPH, getDisplayedHistoryMetrics, generateSeries, getSeriesMetricType, @@ -100,7 +101,7 @@ export default class PreviewGraph extends React.PureComponent { getDisplayedMetrics = (graph: string, customMetrics: Array): Array => { const metrics: Array = getDisplayedHistoryMetrics(graph, customMetrics); if (!metrics || metrics.length <= 0) { - return getDisplayedHistoryMetrics('overview', customMetrics); + return getDisplayedHistoryMetrics(DEFAULT_GRAPH, customMetrics); } return metrics; }; diff --git a/server/sonar-web/src/main/js/apps/overview/events/__tests__/PreviewGraphTooltips-test.js b/server/sonar-web/src/main/js/apps/overview/events/__tests__/PreviewGraphTooltips-test.js index 6292808b788..a26d4d7daf2 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/__tests__/PreviewGraphTooltips-test.js +++ b/server/sonar-web/src/main/js/apps/overview/events/__tests__/PreviewGraphTooltips-test.js @@ -20,6 +20,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import PreviewGraphTooltips from '../PreviewGraphTooltips'; +import { DEFAULT_GRAPH } from '../../../projectActivity/utils'; const SERIES_OVERVIEW = [ { @@ -74,7 +75,7 @@ const METRICS = [ const DEFAULT_PROPS = { formatValue: val => 'Formated.' + val, - graph: 'overview', + graph: DEFAULT_GRAPH, graphWidth: 150, metrics: METRICS, selectedDate: new Date('2011-10-01T22:01:00.000Z'), diff --git a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js index 371294178f6..54cae93e0ee 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/__tests__/utils-test.js @@ -80,7 +80,7 @@ const METRICS = [ const QUERY = { category: '', from: new Date('2017-04-27T08:21:32+0200'), - graph: 'overview', + graph: utils.DEFAULT_GRAPH, project: 'foo', to: undefined, selectedDate: undefined, @@ -117,7 +117,7 @@ describe('getAnalysesByVersionByDay', () => { utils.getAnalysesByVersionByDay(ANALYSES, { category: '', customMetrics: [], - graph: 'overview', + graph: utils.DEFAULT_GRAPH, project: 'foo' }) ).toMatchSnapshot(); @@ -127,7 +127,7 @@ describe('getAnalysesByVersionByDay', () => { utils.getAnalysesByVersionByDay(ANALYSES, { category: 'QUALITY_PROFILE', customMetrics: [], - graph: 'overview', + graph: utils.DEFAULT_GRAPH, project: 'foo' }) ).toMatchSnapshot(); @@ -135,7 +135,7 @@ describe('getAnalysesByVersionByDay', () => { utils.getAnalysesByVersionByDay(ANALYSES, { category: '', customMetrics: [], - graph: 'overview', + graph: utils.DEFAULT_GRAPH, project: 'foo', to: new Date('2017-06-09T11:12:27+0200'), from: new Date('2017-05-18T14:13:07+0200') @@ -147,7 +147,7 @@ describe('getAnalysesByVersionByDay', () => { describe('getDisplayedHistoryMetrics', () => { const customMetrics = ['foo', 'bar']; it('should return only displayed metrics on the graph', () => { - expect(utils.getDisplayedHistoryMetrics('overview', [])).toEqual([ + expect(utils.getDisplayedHistoryMetrics(utils.DEFAULT_GRAPH, [])).toEqual([ 'bugs', 'code_smells', 'vulnerabilities' @@ -165,7 +165,7 @@ describe('getDisplayedHistoryMetrics', () => { describe('getHistoryMetrics', () => { const customMetrics = ['foo', 'bar']; it('should return all metrics', () => { - expect(utils.getHistoryMetrics('overview', [])).toEqual([ + expect(utils.getHistoryMetrics(utils.DEFAULT_GRAPH, [])).toEqual([ 'bugs', 'code_smells', 'vulnerabilities', diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.js b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.js index 977fd6298fc..8a60dd4e0c9 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/GraphsTooltips.js @@ -25,7 +25,8 @@ import GraphsTooltipsContent from './GraphsTooltipsContent'; import GraphsTooltipsContentEvents from './GraphsTooltipsContentEvents'; import GraphsTooltipsContentCoverage from './GraphsTooltipsContentCoverage'; import GraphsTooltipsContentDuplication from './GraphsTooltipsContentDuplication'; -import GraphsTooltipsContentOverview from './GraphsTooltipsContentOverview'; +import GraphsTooltipsContentIssues from './GraphsTooltipsContentIssues'; +import { DEFAULT_GRAPH } from '../utils'; import type { Event, MeasureHistory } from '../types'; import type { Serie } from '../../../components/charts/AdvancedTimeline'; @@ -68,9 +69,9 @@ export default class GraphsTooltips extends React.PureComponent { if (!point || (!point.y && point.y !== 0)) { return null; } - if (this.props.graph === 'overview') { + if (this.props.graph === DEFAULT_GRAPH) { return ( - measure.metric === METRIC_RATING[props.name] ); @@ -48,7 +48,7 @@ export default function GraphsTooltipsContentOverview(props: Props) { } const ratingValue = rating.history[props.tooltipIdx].value; return ( - + 'Formated.' + val, - graph: 'overview', + graph: DEFAULT_GRAPH, graphWidth: 500, measuresHistory: [], selectedDate: new Date('2011-10-01T22:01:00.000Z'), - series: SERIES_OVERVIEW, + series: SERIES_ISSUES, tooltipIdx: 0, tooltipPos: 666 }; -it('should render correctly for overview graphs', () => { +it('should render correctly for issues graphs', () => { expect(shallow()).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/GraphsTooltipsContentOverview-test.js b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/GraphsTooltipsContentIssues-test.js similarity index 82% rename from server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/GraphsTooltipsContentOverview-test.js rename to server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/GraphsTooltipsContentIssues-test.js index c0e67204522..95e398e42a2 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/GraphsTooltipsContentOverview-test.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/GraphsTooltipsContentIssues-test.js @@ -19,9 +19,9 @@ */ import React from 'react'; import { shallow } from 'enzyme'; -import GraphsTooltipsContentOverview from '../GraphsTooltipsContentOverview'; +import GraphsTooltipsContentIssues from '../GraphsTooltipsContentIssues'; -const MEASURES_OVERVIEW = [ +const MEASURES_ISSUES = [ { metric: 'bugs', history: [ @@ -50,7 +50,7 @@ const MEASURES_OVERVIEW = [ ]; const DEFAULT_PROPS = { - measuresHistory: MEASURES_OVERVIEW, + measuresHistory: MEASURES_ISSUES, name: 'bugs', style: '2', tooltipIdx: 1, @@ -59,11 +59,11 @@ const DEFAULT_PROPS = { }; it('should render correctly', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow()).toMatchSnapshot(); }); it('should render correctly when rating data is missing', () => { expect( - shallow() + shallow() ).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.js b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.js index 762c2d5efe3..7a6660d6a96 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityAnalysesList-test.js @@ -77,7 +77,7 @@ const DEFAULT_PROPS = { deleteAnalysis: () => {}, deleteEvent: () => {}, loading: false, - query: { category: '', graph: 'overview', project: 'org.sonarsource.sonarqube:sonarqube' }, + query: { category: '', graph: 'issues', project: 'org.sonarsource.sonarqube:sonarqube' }, updateQuery: () => {} }; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-test.js b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-test.js index 21c0a40d10c..d5c40161288 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-test.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-test.js @@ -80,7 +80,7 @@ const DEFAULT_PROPS = { ] } ], - query: { category: '', graph: 'overview', project: 'org.sonarsource.sonarqube:sonarqube' }, + query: { category: '', graph: 'issues', project: 'org.sonarsource.sonarqube:sonarqube' }, updateQuery: () => {} }; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityGraphs-test.js b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityGraphs-test.js index 4a6f3ba02e2..64c9f8b420b 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityGraphs-test.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityGraphs-test.js @@ -20,6 +20,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import ProjectActivityGraphs from '../ProjectActivityGraphs'; +import { DEFAULT_GRAPH } from '../../utils'; const ANALYSES = [ { @@ -73,7 +74,7 @@ const DEFAULT_PROPS = { } ], metrics: METRICS, - query: { category: '', graph: 'overview', project: 'org.sonarsource.sonarqube:sonarqube' }, + query: { category: '', graph: DEFAULT_GRAPH, project: 'org.sonarsource.sonarqube:sonarqube' }, updateQuery: () => {} }; diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/GraphsHistory-test.js.snap b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/GraphsHistory-test.js.snap index 0621e71f029..fb809d1f599 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/GraphsHistory-test.js.snap +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/__snapshots__/GraphsHistory-test.js.snap @@ -31,7 +31,7 @@ exports[`should correctly render a graph 1`] = ` > - - - ): const parseGraph = (value?: string): string => { const graph = parseAsString(value); - return GRAPH_TYPES.includes(graph) ? graph : 'overview'; + return GRAPH_TYPES.includes(graph) ? graph : DEFAULT_GRAPH; }; -const serializeGraph = (value: string): ?string => (value === 'overview' ? undefined : value); +const serializeGraph = (value: string): ?string => (value === DEFAULT_GRAPH ? undefined : value); export const parseQuery = (urlQuery: RawQuery): Query => ({ category: parseAsString(urlQuery['category']), diff --git a/server/sonar-web/src/main/js/helpers/storage.js b/server/sonar-web/src/main/js/helpers/storage.js index d9bee866b8b..977f184443e 100644 --- a/server/sonar-web/src/main/js/helpers/storage.js +++ b/server/sonar-web/src/main/js/helpers/storage.js @@ -71,4 +71,4 @@ export const getCustomGraph = (): Array => export const saveGraph = (graph: ?string) => save(PROJECT_ACTIVITY_GRAPH, graph); export const getGraph = (): string => - window.localStorage.getItem(PROJECT_ACTIVITY_GRAPH) || 'overview'; + window.localStorage.getItem(PROJECT_ACTIVITY_GRAPH) || 'issues'; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 26ee1514d81..1b33eaf4464 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1285,7 +1285,7 @@ project_activity.delete_analysis=Delete Analysis project_activity.delete_analysis.question=Are you sure you want to delete this analysis from the project history? project_activity.filter_events=Filter events -project_activity.graphs.overview=Overview +project_activity.graphs.issues=Issues project_activity.graphs.coverage=Coverage project_activity.graphs.duplications=Duplications project_activity.graphs.custom=Custom -- 2.39.5