]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9401 Add leak period on the project activity page graphs
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 16 Jun 2017 07:51:08 +0000 (09:51 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 4 Jul 2017 12:15:34 +0000 (14:15 +0200)
server/sonar-web/src/main/js/api/components.js
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityApp.js
server/sonar-web/src/main/js/apps/projectActivity/components/ProjectActivityGraphs.js
server/sonar-web/src/main/js/apps/projectActivity/components/StaticGraphs.js
server/sonar-web/src/main/js/apps/projectActivity/types.js
server/sonar-web/src/main/js/store/rootActions.js

index e024ce947f5acdb948a254e0b3049e55821bd824..60d33b1f3464435b0be5e0e493b2c6279acd71b4 100644 (file)
@@ -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) {
index e23b67da52e7826ff0550c3f03dd93e2ef3dca32..b5e2589e567560cc91a15b1e43dbffa388b43d54 100644 (file)
@@ -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()}
index 167567a89182836f141cd9a503a3d5dc48ab7924..b824565b302ba261da396147f17a80dd74df54f1 100644 (file)
@@ -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}
index 1207d20439b9b9170a7aac39fe7f0260bffc7720..92966f7bad3b19246dbab04924dca639eff42143 100644 (file)
@@ -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]}
             />
index 51cc48cbea420e4698e5bfcb6d332dae6459a5cd..ddd64281ed9aa67cf244ea64d7cc6637171e166c 100644 (file)
@@ -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> };
index ec276c40f297ac2116bd974119eae37bc93523c4..a3d3902cf1e5de1a44b0314a4c9aa85f93e5cf3e 100644 (file)
@@ -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]));