From f043c152d6cbf7adc287a2542c49d7838e28c626 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Tue, 11 Jul 2017 10:14:03 +0200 Subject: [PATCH] Display missing data on the activity graph preview on the project dashboard page --- .../js/apps/overview/events/AnalysesList.js | 2 +- .../js/apps/overview/events/PreviewGraph.js | 31 +++++++++++++------ .../overview/events/PreviewGraphTooltips.js | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js index 05856e6601e..cf8aa197c0a 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js +++ b/server/sonar-web/src/main/js/apps/overview/events/AnalysesList.js @@ -29,7 +29,7 @@ import type { Analysis as AnalysisType } from '../../projectActivity/types'; import type { History, Metric } from '../types'; type Props = { - history: History, + history: ?History, project: string, router: { replace: ({ pathname: string, query?: {} }) => void } }; 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 148557d6b68..171c6d87975 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 @@ -19,7 +19,7 @@ */ // @flow import React from 'react'; -import { map } from 'lodash'; +import { minBy } from 'lodash'; import { AutoSizer } from 'react-virtualized'; import { generateSeries, GRAPHS_METRICS_DISPLAYED } from '../../projectActivity/utils'; import { getGraph } from '../../../helpers/storage'; @@ -30,7 +30,7 @@ import type { Serie } from '../../../components/charts/AdvancedTimeline'; import type { History, Metric } from '../types'; type Props = { - history: History, + history: ?History, metrics: Array, project: string, router: { replace: ({ pathname: string, query?: {} }) => void } @@ -88,12 +88,23 @@ export default class PreviewGraph extends React.PureComponent { return metrics; }; - getSeries = (history: History, graph: string, metricsType: string) => { - const measureHistory = map(history, (item, key) => ({ - metric: key, - history: item.filter(p => p.value != null) + getSeries = (history: ?History, graph: string, metricsType: string) => { + const myHistory = history; + if (!myHistory) { + return []; + } + const metrics = this.getDisplayedMetrics(graph); + const firstValid = minBy( + metrics.map(metric => myHistory[metric].find(p => p.value || p.value === 0)), + 'date' + ); + const measureHistory = metrics.map(metric => ({ + metric, + history: firstValid + ? myHistory[metric].filter(p => p.date >= firstValid.date) + : myHistory[metric] })); - return generateSeries(measureHistory, graph, metricsType, this.getDisplayedMetrics(graph)); + return generateSeries(measureHistory, graph, metricsType, metrics); }; getMetricType = (metrics: Array, graph: string) => { @@ -110,7 +121,7 @@ export default class PreviewGraph extends React.PureComponent { this.setState({ selectedDate, tooltipXPos, tooltipIdx }); render() { - const { graph, selectedDate, tooltipIdx, tooltipXPos } = this.state; + const { graph, selectedDate, series, tooltipIdx, tooltipXPos } = this.state; return (
@@ -143,7 +154,7 @@ export default class PreviewGraph extends React.PureComponent { graphWidth={width} metrics={this.props.metrics} selectedDate={selectedDate} - series={this.state.series} + series={series} tooltipIdx={tooltipIdx} tooltipPos={tooltipXPos} />} diff --git a/server/sonar-web/src/main/js/apps/overview/events/PreviewGraphTooltips.js b/server/sonar-web/src/main/js/apps/overview/events/PreviewGraphTooltips.js index dfcf88e1289..982320a3a7c 100644 --- a/server/sonar-web/src/main/js/apps/overview/events/PreviewGraphTooltips.js +++ b/server/sonar-web/src/main/js/apps/overview/events/PreviewGraphTooltips.js @@ -45,7 +45,7 @@ export default class PreviewGraphTooltips extends React.PureComponent { const top = 16; let left = this.props.tooltipPos; let customClass; - if (left > this.props.graphWidth - TOOLTIP_WIDTH + 20) { + if (left > this.props.graphWidth - TOOLTIP_WIDTH) { left -= TOOLTIP_WIDTH; customClass = 'bubble-popup-right'; } -- 2.39.5