From 5d4a9fb5d210cd943ddfa8876ecbda0ef514f1a3 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 26 Nov 2015 09:41:54 +0100 Subject: [PATCH] SONAR-7035 apply feedback --- .../js/components/shared/drilldown-link.js | 32 ++++++++++++++++++- server/sonar-web/src/main/js/helpers/urls.js | 6 +++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/components/shared/drilldown-link.js b/server/sonar-web/src/main/js/components/shared/drilldown-link.js index 107398699ff..7623209e8a5 100644 --- a/server/sonar-web/src/main/js/components/shared/drilldown-link.js +++ b/server/sonar-web/src/main/js/components/shared/drilldown-link.js @@ -26,6 +26,33 @@ const ISSUE_MEASURES = [ ]; +const HIGHLIGHT_MAPPING = { + 'coverage': 'uncovered_lines', + 'line_coverage': 'uncovered_lines', + 'branch_coverage': 'uncovered_conditions', + + 'new_coverage': 'new_uncovered_lines', + 'new_line_coverage': 'new_uncovered_lines', + 'new_branch_coverage': 'new_uncovered_conditions', + + 'it_coverage': 'it_uncovered_lines', + 'it_line_coverage': 'it_uncovered_lines', + 'it_branch_coverage': 'it_uncovered_conditions', + + 'new_it_coverage': 'new_it_uncovered_lines', + 'new_it_line_coverage': 'new_it_uncovered_lines', + 'new_it_branch_coverage': 'new_it_uncovered_conditions', + + 'overall_coverage': 'overall_uncovered_lines', + 'overall_line_coverage': 'overall_uncovered_lines', + 'overall_branch_coverage': 'overall_uncovered_conditions', + + 'new_overall_coverage': 'new_overall_uncovered_lines', + 'new_overall_line_coverage': 'new_overall_uncovered_lines', + 'new_overall_branch_coverage': 'new_overall_uncovered_conditions' +}; + + export const DrilldownLink = React.createClass({ isIssueMeasure() { return ISSUE_MEASURES.indexOf(this.props.metric) !== -1; @@ -86,7 +113,10 @@ export const DrilldownLink = React.createClass({ return this.renderIssuesLink(); } - let url = getComponentDrilldownUrl(this.props.component, this.props.metric, this.props.period); + let highlightedMetric = HIGHLIGHT_MAPPING[this.props.metric]; + let url = highlightedMetric ? + getComponentDrilldownUrl(this.props.component, highlightedMetric, this.props.period, this.props.metric) : + getComponentDrilldownUrl(this.props.component, this.props.metric, this.props.period); return {this.props.children}; } }); diff --git a/server/sonar-web/src/main/js/helpers/urls.js b/server/sonar-web/src/main/js/helpers/urls.js index 4af420e6a2b..8280af1c6ea 100644 --- a/server/sonar-web/src/main/js/helpers/urls.js +++ b/server/sonar-web/src/main/js/helpers/urls.js @@ -27,13 +27,17 @@ export function getComponentIssuesUrl (componentKey, query) { * @param {string} componentKey * @param {string} metric * @param {string|number} [period] + * @param {string} [highlightedMetric] * @returns {string} */ -export function getComponentDrilldownUrl (componentKey, metric, period) { +export function getComponentDrilldownUrl (componentKey, metric, period, highlightedMetric) { let url = window.baseUrl + '/drilldown/measures?id=' + encodeURIComponent(componentKey) + '&metric=' + encodeURIComponent(metric); if (period) { url += '&period=' + period; } + if (highlightedMetric) { + url += '&highlight=' + encodeURIComponent(highlightedMetric); + } return url; } -- 2.39.5