From ba116aa74c68625be4bedbca31a10e21d5b86055 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Mon, 14 Aug 2017 17:10:50 +0200 Subject: [PATCH] SONAR-8805 In measures page treemap use new_lines as the size measure for the leak metrics --- .../components/MeasureContent.js | 18 +++++++++--------- .../drilldown/TreeMapView.js | 14 +++++++++++--- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js index 13973073e8a..b4c91f405cc 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.js @@ -111,22 +111,22 @@ export default class MeasureContent extends React.PureComponent { const strategy = view === 'list' ? 'leaves' : 'children'; const metricKeys = [metric.key]; const opts /*: Object */ = { metricSortFilter: 'withMeasuresOnly' }; + const isDiff = isDiffMetric(metric.key); + if (isDiff) { + opts.metricPeriodSort = 1; + } if (view === 'treemap') { - metricKeys.push('ncloc'); + const sizeMetric = isDiff ? 'new_lines' : 'ncloc'; + metricKeys.push(sizeMetric); + opts.metricSort = sizeMetric; + opts.s = isDiff ? 'metricPeriod' : 'metric'; opts.asc = false; - opts.metricSort = 'ncloc'; - opts.s = 'metric'; } else { metricKeys.push(...(complementary[metric.key] || [])); opts.asc = metric.direction === 1; opts.ps = 100; opts.metricSort = metric.key; - if (isDiffMetric(metric.key)) { - opts.s = 'metricPeriod,name'; - opts.metricPeriodSort = 1; - } else { - opts.s = 'metric,name'; - } + opts.s = isDiff ? 'metricPeriod,name' : 'metric,name'; } return { metricKeys, opts: { ...opts, ...options }, strategy }; }; diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.js b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.js index d6b2542f09b..5bfa9a7873f 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.js +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/TreeMapView.js @@ -169,20 +169,28 @@ export default class TreeMapView extends React.PureComponent { if (treemapItems.length <= 0) { return ; } - + const { components, metric } = this.props; + const sizeMeasure = + components.length > 0 + ? components[0].measures.find(measure => measure.metric.key !== metric.key) + : null; return (
  • {translateWithParameters( 'component_measures.legend.color_x', - getLocalizedMetricName(this.props.metric) + getLocalizedMetricName(metric) )}
  • {translateWithParameters( 'component_measures.legend.size_x', - translate('metric.ncloc.name') + translate( + 'metric', + sizeMeasure && sizeMeasure.metric ? sizeMeasure.metric.key : 'ncloc', + 'name' + ) )}
  • -- 2.39.5