aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/projectActivity
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/projectActivity')
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/Events.js22
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js1
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js7
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js3
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js39
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/components/StaticGraphs.js7
-rw-r--r--server/sonar-web/src/main/js/apps/projectActivity/utils.js42
7 files changed, 62 insertions, 59 deletions
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js
index 6f2725388d9..0dd5f89c054 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/Events.js
@@ -19,31 +19,23 @@
*/
// @flow
import React from 'react';
-import { sortBy } from 'lodash';
import Event from './Event';
+import './projectActivity.css';
import type { Event as EventType } from '../types';
type Props = {
- analysis: string,
- canAdmin: boolean,
- changeEvent: (event: string, name: string) => Promise<*>,
- deleteEvent: (analysis: string, event: string) => Promise<*>,
+ analysis?: string,
+ canAdmin?: boolean,
+ changeEvent?: (event: string, name: string) => Promise<*>,
+ deleteEvent?: (analysis: string, event: string) => Promise<*>,
events: Array<EventType>,
- isFirst: boolean
+ isFirst?: boolean
};
export default function Events(props: Props) {
- const sortedEvents: Array<EventType> = sortBy(
- props.events,
- // versions last
- (event: EventType) => (event.category === 'VERSION' ? 1 : 0),
- // then the rest sorted by category
- 'category'
- );
-
return (
<div className="project-activity-events">
- {sortedEvents.map(event => (
+ {props.events.map(event => (
<Event
analysis={props.analysis}
canAdmin={props.canAdmin}
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js
index e6dd14181e0..c44ac7e4e79 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysesList.js
@@ -83,6 +83,7 @@ export default function ProjectActivityAnalysesList(props: Props) {
deleteEvent={props.deleteEvent}
isFirst={analysis.key === firstAnalysisKey}
key={analysis.key}
+ version={version.version}
/>
))}
</ul>
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js
index 406f963f0a3..41133f90f55 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAnalysis.js
@@ -30,19 +30,18 @@ type Props = {
addCustomEvent: (analysis: string, name: string, category?: string) => Promise<*>,
addVersion: (analysis: string, version: string) => Promise<*>,
analysis: Analysis,
+ canAdmin: boolean,
changeEvent: (event: string, name: string) => Promise<*>,
deleteAnalysis: (analysis: string) => Promise<*>,
deleteEvent: (analysis: string, event: string) => Promise<*>,
isFirst: boolean,
- canAdmin: boolean
+ version: ?string
};
export default function ProjectActivityAnalysis(props: Props) {
const { date, events } = props.analysis;
const { isFirst, canAdmin } = props;
- const version = events.find(event => event.category === 'VERSION');
-
return (
<li className="project-activity-analysis clearfix">
<div className="project-activity-time spacer-right">
@@ -64,7 +63,7 @@ export default function ProjectActivityAnalysis(props: Props) {
<i className="icon-dropdown" />
</button>
<ul className="dropdown-menu dropdown-menu-right">
- {version == null &&
+ {props.version == null &&
<li>
<AddEventForm
addEvent={props.addVersion}
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js
index 58b855b49f0..e7a4e2505ef 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityAppContainer.js
@@ -258,7 +258,8 @@ class ProjectActivityAppContainer extends React.PureComponent {
);
// if there is no filter, but there are saved preferences in the localStorage
- return !filtered && getGraph();
+ const graph = getGraph();
+ return !filtered && graph != null && graph !== 'overview';
}
};
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js
index 004ef709197..008cbc7869a 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js
@@ -23,13 +23,7 @@ import { debounce, sortBy } from 'lodash';
import ProjectActivityGraphsHeader from './ProjectActivityGraphsHeader';
import GraphsZoom from './GraphsZoom';
import StaticGraphs from './StaticGraphs';
-import {
- GRAPHS_METRICS,
- datesQueryChanged,
- generateCoveredLinesMetric,
- historyQueryChanged
-} from '../utils';
-import { translate } from '../../../helpers/l10n';
+import { datesQueryChanged, generateSeries, historyQueryChanged } from '../utils';
import type { RawQuery } from '../../../helpers/query';
import type { Analysis, MeasureHistory, Query } from '../types';
import type { Serie } from '../../../components/charts/AdvancedTimeline';
@@ -57,7 +51,7 @@ export default class ProjectActivityGraphs extends React.PureComponent {
constructor(props: Props) {
super(props);
- const series = this.getSeries(props.measuresHistory);
+ const series = generateSeries(props.measuresHistory, props.query.graph, props.metricsType);
this.state = {
graphStartDate: props.query.from || null,
graphEndDate: props.query.to || null,
@@ -71,8 +65,13 @@ export default class ProjectActivityGraphs extends React.PureComponent {
nextProps.measuresHistory !== this.props.measuresHistory ||
historyQueryChanged(this.props.query, nextProps.query)
) {
- const series = this.getSeries(nextProps.measuresHistory);
- this.setState({ series });
+ this.setState({
+ series: generateSeries(
+ nextProps.measuresHistory,
+ nextProps.query.graph,
+ nextProps.metricsType
+ )
+ });
}
if (
nextProps.query !== this.props.query &&
@@ -82,26 +81,6 @@ export default class ProjectActivityGraphs extends React.PureComponent {
}
}
- getSeries = (measuresHistory: Array<MeasureHistory>): Array<Serie> =>
- measuresHistory.map(measure => {
- if (measure.metric === 'uncovered_lines') {
- return generateCoveredLinesMetric(
- measure,
- measuresHistory,
- GRAPHS_METRICS[this.props.query.graph].indexOf(measure.metric)
- );
- }
- return {
- name: measure.metric,
- translatedName: translate('metric', measure.metric, 'name'),
- style: GRAPHS_METRICS[this.props.query.graph].indexOf(measure.metric),
- data: measure.history.map(analysis => ({
- x: analysis.date,
- y: this.props.metricsType === 'LEVEL' ? analysis.value : Number(analysis.value)
- }))
- };
- });
-
updateGraphZoom = (graphStartDate: ?Date, graphEndDate: ?Date) => {
if (graphEndDate != null && graphStartDate != null) {
const msDiff = Math.abs(graphEndDate.valueOf() - graphStartDate.valueOf());
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/StaticGraphs.js b/server/sonar-web/src/main/js/apps/projectActivity/components/StaticGraphs.js
index 7428bdd3282..86379691768 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/components/StaticGraphs.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/components/StaticGraphs.js
@@ -47,8 +47,6 @@ export default class StaticGraphs extends React.PureComponent {
formatYTick = tick => formatMeasure(tick, getShortType(this.props.metricsType));
- formatValue = value => formatMeasure(value, this.props.metricsType);
-
getEvents = () => {
const { analyses, eventFilter } = this.props;
const filteredEvents = analyses.reduce((acc, analysis) => {
@@ -73,7 +71,7 @@ export default class StaticGraphs extends React.PureComponent {
return sortBy(filteredEvents, 'date');
};
- hasHistoryData = () => some(this.props.series, serie => serie.data && serie.data.length > 2);
+ hasSeriesData = () => some(this.props.series, serie => serie.data && serie.data.length > 2);
render() {
const { loading } = this.props;
@@ -88,7 +86,7 @@ export default class StaticGraphs extends React.PureComponent {
);
}
- if (!this.hasHistoryData()) {
+ if (!this.hasSeriesData()) {
return (
<div className="project-activity-graph-container">
<div className="note text-center">
@@ -111,7 +109,6 @@ export default class StaticGraphs extends React.PureComponent {
height={height}
width={width}
interpolate="linear"
- formatValue={this.formatValue}
formatYTick={this.formatYTick}
leakPeriodDate={this.props.leakPeriodDate}
metricType={this.props.metricsType}
diff --git a/server/sonar-web/src/main/js/apps/projectActivity/utils.js b/server/sonar-web/src/main/js/apps/projectActivity/utils.js
index 70447874ed1..2c0c3c818bc 100644
--- a/server/sonar-web/src/main/js/apps/projectActivity/utils.js
+++ b/server/sonar-web/src/main/js/apps/projectActivity/utils.js
@@ -19,6 +19,7 @@
*/
// @flow
import moment from 'moment';
+import { sortBy } from 'lodash';
import {
cleanQuery,
parseAsDate,
@@ -29,6 +30,7 @@ import {
import { translate } from '../../helpers/l10n';
import type { Analysis, MeasureHistory, Query } from './types';
import type { RawQuery } from '../../helpers/query';
+import type { Serie } from '../../components/charts/AdvancedTimeline';
export const EVENT_TYPES = ['VERSION', 'QUALITY_GATE', 'QUALITY_PROFILE', 'OTHER'];
export const GRAPH_TYPES = ['overview', 'coverage', 'duplications', 'remediation'];
@@ -69,6 +71,30 @@ export const generateCoveredLinesMetric = (
};
};
+export const generateSeries = (
+ measuresHistory: Array<MeasureHistory>,
+ graph: string,
+ dataType: string
+): Array<Serie> =>
+ measuresHistory.map(measure => {
+ if (measure.metric === 'uncovered_lines') {
+ return generateCoveredLinesMetric(
+ measure,
+ measuresHistory,
+ GRAPHS_METRICS[graph].indexOf(measure.metric)
+ );
+ }
+ return {
+ name: measure.metric,
+ translatedName: translate('metric', measure.metric, 'name'),
+ style: GRAPHS_METRICS[graph].indexOf(measure.metric),
+ data: measure.history.map(analysis => ({
+ x: analysis.date,
+ y: dataType === 'LEVEL' ? analysis.value : Number(analysis.value)
+ }))
+ };
+ });
+
export const getAnalysesByVersionByDay = (
analyses: Array<Analysis>
): Array<{
@@ -84,10 +110,18 @@ export const getAnalysesByVersionByDay = (
if (!currentVersion.byDay[day]) {
currentVersion.byDay[day] = [];
}
- currentVersion.byDay[day].push(analysis);
- const versionEvent = analysis.events.find(event => event.category === 'VERSION');
- if (versionEvent) {
- currentVersion.version = versionEvent.name;
+ const sortedEvents = sortBy(
+ analysis.events,
+ // versions last
+ event => (event.category === 'VERSION' ? 1 : 0),
+ // then the rest sorted by category
+ 'category'
+ );
+ currentVersion.byDay[day].push({ ...analysis, events: sortedEvents });
+
+ const lastEvent = sortedEvents[sortedEvents.length - 1];
+ if (lastEvent && lastEvent.category === 'VERSION') {
+ currentVersion.version = lastEvent.name;
acc.push({ version: undefined, byDay: {} });
}
return acc;