diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-06-16 09:51:08 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-07-04 14:15:34 +0200 |
commit | bd8acc0bfb05d9c2bc488b61f5493d3f8bc676be (patch) | |
tree | 7b334de3c2b8c6cca9b50a795e2243cf627a415c /server/sonar-web | |
parent | 5b03b1c707168fcd83a3eee3bae40ad0d2c7022f (diff) | |
download | sonarqube-bd8acc0bfb05d9c2bc488b61f5493d3f8bc676be.tar.gz sonarqube-bd8acc0bfb05d9c2bc488b61f5493d3f8bc676be.zip |
SONAR-9401 Add leak period on the project activity page graphs
Diffstat (limited to 'server/sonar-web')
6 files changed, 21 insertions, 22 deletions
diff --git a/server/sonar-web/src/main/js/api/components.js b/server/sonar-web/src/main/js/api/components.js index e024ce947f5..60d33b1f346 100644 --- a/server/sonar-web/src/main/js/api/components.js +++ b/server/sonar-web/src/main/js/api/components.js @@ -124,8 +124,8 @@ export function getBreadcrumbs(component: string) { }); } -export function getComponentTags(component: string) { - return getComponentShow(component).then(r => r.component.tags || []); +export function getComponentData(component: string) { + return getComponentShow(component).then(r => r.component); } export function getMyProjects(data?: Object) { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js index e23b67da52e..b5e2589e567 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js @@ -32,18 +32,17 @@ import { getMetrics } from '../../../api/metrics'; import { GRAPHS_METRICS, parseQuery, serializeQuery, serializeUrlQuery } from '../utils'; import { translate } from '../../../helpers/l10n'; import './projectActivity.css'; -import type { Analysis, LeakPeriod, MeasureHistory, Metric, Query, Paging } from '../types'; +import type { Analysis, MeasureHistory, Metric, Query, Paging } from '../types'; import type { RawQuery } from '../../../helpers/query'; type Props = { location: { pathname: string, query: RawQuery }, - project: { configuration?: { showHistory: boolean }, key: string }, + project: { configuration?: { showHistory: boolean }, key: string, leakPeriodDate: string }, router: { push: ({ pathname: string, query?: RawQuery }) => void } }; export type State = { analyses: Array<Analysis>, - leakPeriod?: LeakPeriod, loading: boolean, measures: Array<*>, metrics: Array<Metric>, @@ -232,7 +231,7 @@ export default class ProjectActivityApp extends React.PureComponent { <ProjectActivityGraphs analyses={this.state.analyses} - leakPeriod={this.state.leakPeriod} + leakPeriodDate={moment(this.props.project.leakPeriodDate).toDate()} loading={this.state.loading} measuresHistory={this.state.measuresHistory} metricsType={this.getMetricType()} 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 167567a8918..b824565b302 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 @@ -26,6 +26,7 @@ import type { Analysis, MeasureHistory, Query } from '../types'; type Props = { analyses: Array<Analysis>, + leakPeriodDate: Date, loading: boolean, measuresHistory: Array<MeasureHistory>, metricsType: string, @@ -41,6 +42,7 @@ export default function ProjectActivityGraphs(props: Props) { <ProjectActivityGraphsHeader graph={props.query.graph} updateQuery={props.updateQuery} /> <StaticGraphs analyses={props.analyses} + leakPeriodDate={props.leakPeriodDate} loading={props.loading} measuresHistory={props.measuresHistory} metricsType={props.metricsType} 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 1207d20439b..92966f7bad3 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 @@ -29,6 +29,7 @@ import type { Analysis, MeasureHistory } from '../types'; type Props = { analyses: Array<Analysis>, + leakPeriodDate: Date, loading: boolean, measuresHistory: Array<MeasureHistory>, metricsType: string @@ -37,6 +38,10 @@ type Props = { export default class StaticGraphs extends React.PureComponent { props: Props; + formatYTick = tick => formatMeasure(tick, getShortType(this.props.metricsType)); + + formatValue = value => formatMeasure(value, this.props.metricsType); + getEvents = () => { const events = this.props.analyses.reduce((acc, analysis) => { return acc.concat( @@ -85,9 +90,6 @@ export default class StaticGraphs extends React.PureComponent { ); } - const { metricsType } = this.props; - const formatValue = value => formatMeasure(value, metricsType); - const formatYTick = tick => formatMeasure(tick, getShortType(metricsType)); const series = this.getSeries(); return ( <div className="project-activity-graph-container"> @@ -97,11 +99,11 @@ export default class StaticGraphs extends React.PureComponent { <AdvancedTimeline basisCurve={false} series={series} - metricType={metricsType} + metricType={this.props.metricsType} events={this.getEvents()} interpolate="linear" - formatValue={formatValue} - formatYTick={formatYTick} + formatValue={this.formatValue} + formatYTick={this.formatYTick} leakPeriodDate={this.props.leakPeriodDate} padding={[25, 25, 30, 60]} /> diff --git a/server/sonar-web/src/main/js/apps/projectActivity/types.js b/server/sonar-web/src/main/js/apps/projectActivity/types.js index 51cc48cbea4..ddd64281ed9 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/types.js +++ b/server/sonar-web/src/main/js/apps/projectActivity/types.js @@ -32,13 +32,6 @@ export type Analysis = { events: Array<Event> }; -export type LeakPeriod = { - date: string, - index: number, - mode: string, - parameter: string -}; - export type HistoryItem = { date: Date, value: string }; export type MeasureHistory = { metric: string, history: Array<HistoryItem> }; diff --git a/server/sonar-web/src/main/js/store/rootActions.js b/server/sonar-web/src/main/js/store/rootActions.js index ec276c40f29..a3d3902cf1e 100644 --- a/server/sonar-web/src/main/js/store/rootActions.js +++ b/server/sonar-web/src/main/js/store/rootActions.js @@ -19,7 +19,7 @@ */ import { getLanguages } from '../api/languages'; import { getGlobalNavigation, getComponentNavigation } from '../api/nav'; -import { getComponentTags } from '../api/components'; +import { getComponentData } from '../api/components'; import * as auth from '../api/auth'; import { getOrganizations } from '../api/organizations'; import { receiveLanguages } from './languages/actions'; @@ -51,8 +51,11 @@ const addQualifier = project => ({ }); export const fetchProject = key => dispatch => - Promise.all([getComponentNavigation(key), getComponentTags(key)]).then(([component, tags]) => { - component.tags = tags; + Promise.all([ + getComponentNavigation(key), + getComponentData(key) + ]).then(([componentNav, componentData]) => { + const component = { ...componentData, ...componentNav }; dispatch(receiveComponents([addQualifier(component)])); if (component.organization != null) { dispatch(fetchOrganizations([component.organization])); |