]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7035 apply feedback
authorStas Vilchik <vilchiks@gmail.com>
Thu, 26 Nov 2015 08:41:54 +0000 (09:41 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 26 Nov 2015 08:41:54 +0000 (09:41 +0100)
server/sonar-web/src/main/js/components/shared/drilldown-link.js
server/sonar-web/src/main/js/helpers/urls.js

index 107398699ffecc7db53547b80d00c9f6886f85de..7623209e8a56fd9500c987c10618d18197dc8a14 100644 (file)
@@ -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 <a className={this.props.className} href={url}>{this.props.children}</a>;
   }
 });
index 4af420e6a2ba23da30e9a8022f492e8b3931a631..8280af1c6ea28e5ed21184b8557d30d4e5f1b601 100644 (file)
@@ -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;
 }