]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5209 Differential mode feedback
authorStas Vilchik <vilchiks@gmail.com>
Thu, 19 Jun 2014 06:37:10 +0000 (12:37 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 19 Jun 2014 06:37:10 +0000 (12:37 +0600)
sonar-core/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/coffee/component-viewer/header.coffee
sonar-server/src/main/coffee/component-viewer/header/coverage-header.coffee
sonar-server/src/main/coffee/component-viewer/header/issues-header.coffee
sonar-server/src/main/coffee/component-viewer/main.coffee
sonar-server/src/main/hbs/component-viewer/header/coverage-header.hbs
sonar-server/src/main/hbs/component-viewer/header/issues-header.hbs
sonar-server/src/main/hbs/component-viewer/header/scm-header.hbs
sonar-server/src/main/js/common/handlebars-extensions.js

index 0d85961de5fabd55101b31a52ee561c0588e6cb3..28c894bae3691bb9bac87db5830734ddeaae8b22 100644 (file)
@@ -2655,6 +2655,10 @@ component_viewer.x_lines_are_covered={0} lines are covered
 component_viewer.details=Details
 component_viewer.add_manual_issue=Add Manual Issue
 component_viewer.line_actions=Line Actions
+component_viewer.no_issues=No Issues
+component_viewer.no_coverage=No Coverage
+component_viewer.time_changes=Time Changes
+component_viewer.added=Added
 
 component_viewer.workspace=Workspace
 component_viewer.workspace.tooltip=Keeps track of history of navigation
index f46a87fa4bba8a5720946d64c1fafd1a83e523e4..47483ea3a143b754e145dab421d351ddf7333690 100644 (file)
@@ -131,7 +131,11 @@ define [
 
 
     enableBarItem: (item) ->
-      @$(item).click()
+      $item = @$(item)
+      if $item.length > 0
+        @$(item).click()
+      else
+        @options.main.hideAllLines()
 
 
     showExpandedBar: (e) ->
index 9be848b52cc919c6a1beecd55574a8f36755e63e..1c426b35379f9b6d8655903898fe24c5bd089795 100644 (file)
@@ -38,7 +38,7 @@ define [
         main: @options.main
         bottom: true
       popup.render()
-      popup.on 'change', (period) => @main.enablePeriod period
+      popup.on 'change', (period) => @main.enablePeriod period, 'coverage'
 
 
     filterByLinesToCover: (e) ->
index 54e2c93dc25364d8f77d8482f7e5f2a1351e827a..fa066fe02989df0f67a38ce6426989910f442e51 100644 (file)
@@ -48,7 +48,7 @@ define [
         triggerEl: $(e.currentTarget)
         main: @options.main
         bottom: true
-        prefix: 'Added'
+        prefix: t 'component_viewer.added'
       popup.render()
       popup.on 'change', (period) => @main.enablePeriod period, 'issues'
 
@@ -110,4 +110,6 @@ define [
 
 
     serializeData: ->
-      _.extend super, period: @state.get('period')?.toJSON()
\ No newline at end of file
+      _.extend super,
+        period: @state.get('period')?.toJSON()
+        hasIssues: @state.get('severities')?.length || @state.get('rules')?.length
\ No newline at end of file
index 68a95f0f34ce7d1cffbe52c086e35035255e295b..8dd9ad705e11c6625d560ba544bf6eca2b2788a7 100644 (file)
@@ -184,7 +184,7 @@ define [
         measures = @component.get 'measures'
         measuresList.forEach (m) ->
           key = m.key.substr(4)
-          variation = "var#{period}"
+          variation = "fvar#{period}"
           measures[key] = m[variation]
         @component.set 'measures', measures
 
@@ -251,15 +251,22 @@ define [
       @sourceView.render()
 
 
+    hideAllLines: ->
+      @sourceView.resetShowBlocks()
+      @sourceView.render()
+
+
     enablePeriod: (periodKey, scope = 'scm') ->
       period = if periodKey == '' then null else @periods.findWhere key: periodKey
       @state.set 'period', period
       $.when(@requestMeasures(@key, period?.get('key')), @requestIssuesPeriod(@key, period?.get('key')), @requestSCM(@key)).done =>
-        @headerView.render()
         if scope == 'issues'
-          @filterByUnresolvedIssues() unless @state.get('activeHeaderItem')
-        else
-          @filterBySCM()
+          @state.set 'activeHeaderItem', '.js-filter-unresolved-issues'
+          @headerView.render()
+        else if scope == 'coverage'
+          @state.set 'activeHeaderItem', '.js-filter-lines-to-cover'
+          @headerView.render()
+        else @filterBySCM()
 
 
     addTransition: (transition, options) ->
index c2b0a87ab817bbf2563aab00233d8be02fc4ebec..f2b084d9c2b43f2c7cbdf3048d8c4b200f2a28fe 100644 (file)
@@ -1,10 +1,18 @@
 <div class="component-viewer-header-time-changes">
   <a class="highlighted-link js-coverage-time-changes">
-    {{#if period}}Δ {{period.label}}{{else}}<i class="icon-period"></i> Time Changes{{/if}}
+    {{#if period}}Δ {{period.label}}{{else}}<i class="icon-period"></i> {{t 'component_viewer.time_changes'}}{{/if}}
   </a>
 </div>
 
 {{#with component.measures}}
+  {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines branch_coverage conditions_to_cover covered_conditions uncovered_conditions it_coverage it_line_coverage it_lines_to_cover it_covered_lines it_uncovered_lines it_branch_coverage it_conditions_to_cover it_covered_conditions it_uncovered_conditions}}
+  {{else}}
+    <div class="component-viewer-header-expanded-bar-section">
+      <div class="component-viewer-header-expanded-bar-section-title">
+        {{t 'component_viewer.no_coverage'}}
+      </div>
+  {{/any}}
+
   <span class="nowrap">
     {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines}}
       <div class="component-viewer-header-expanded-bar-section">
 
     {{#any branch_coverage conditions_to_cover covered_conditions uncovered_conditions}}
       <div class="component-viewer-header-expanded-bar-section">
-        <div class="component-viewer-header-expanded-bar-section-title">&nbsp;</div>
+        <div class="component-viewer-header-expanded-bar-section-title">
+          {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines}}
+            &nbsp;
+          {{else}}
+            {{t 'component_viewer.measure_section.unit_tests'}}
+          {{/any}}
+        </div>
         <ul class="component-viewer-header-expanded-bar-section-list">
-          <li><span class="item">&nbsp;</span></li>
+          {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines}}
+            <li><span class="item">&nbsp;</span></li>
+          {{/any}}
           {{{componentViewerHeaderItem branch_coverage 'branch_coverage'}}}
           {{{componentViewerHeaderLink conditions_to_cover 'conditions_to_cover' 'js-filter-branches-to-cover'}}}
           {{{componentViewerHeaderLink uncovered_conditions 'uncovered_conditions' 'js-filter-uncovered-branches'}}}
 
     {{#any it_branch_coverage it_conditions_to_cover it_covered_conditions it_uncovered_conditions}}
       <div class="component-viewer-header-expanded-bar-section">
-        <div class="component-viewer-header-expanded-bar-section-title">&nbsp;</div>
+        <div class="component-viewer-header-expanded-bar-section-title">
+          {{#any it_coverage it_line_coverage it_lines_to_cover it_covered_lines it_uncovered_lines}}
+            &nbsp;
+          {{else}}
+            {{t 'component_viewer.measure_section.integration_tests'}}
+          {{/any}}
+        </div>
         <ul class="component-viewer-header-expanded-bar-section-list">
-          <li><span class="item">&nbsp;</span></li>
+          {{#any it_coverage it_line_coverage it_lines_to_cover it_covered_lines it_uncovered_lines}}
+              <li><span class="item">&nbsp;</span></li>
+          {{/any}}
           {{{componentViewerHeaderItem it_branch_coverage 'branch_coverage'}}}
           {{{componentViewerHeaderLink it_conditions_to_cover 'conditions_to_cover' 'js-filter-branches-to-cover-it'}}}
           {{{componentViewerHeaderLink it_uncovered_conditions 'uncovered_conditions' 'js-filter-uncovered-branches-it'}}}
index bca87c9c4a059bd7d18c75ac3e9a38cbdf9c74b5..3a6236b677944dfe3e679e74e02eac2650277824 100644 (file)
@@ -1,6 +1,6 @@
 <div class="component-viewer-header-time-changes">
   <a class="highlighted-link js-issues-time-changes">
-    {{#if period}}Added {{period.label}}{{else}}<i class="icon-period"></i> Time Changes{{/if}}
+    {{#if period}}{{t 'component_viewer.added'}} {{period.label}}{{else}}<i class="icon-period"></i> {{t 'component_viewer.time_changes'}}{{/if}}
   </a>
 </div>
 
@@ -40,7 +40,7 @@
 
 <div class="component-viewer-header-expanded-bar-section">
   <div class="component-viewer-header-expanded-bar-section-title">
-    {{t 'component_viewer.measure_section.issues'}}
+    {{#if hasIssues}}&nbsp;{{else}}{{t 'component_viewer.no_issues'}}{{/if}}
   </div>
   <ul class="component-viewer-header-expanded-bar-section-list">
     {{#if currentIssue}}
   </ul>
 </div>
 
-<div class="component-viewer-header-expanded-bar-section component-viewer-header-expanded-bar-section-actions">
-  <div class="component-viewer-header-expanded-bar-section-title">&nbsp;</div>
-  <ul class="component-viewer-header-expanded-bar-section-list">
-    {{#if state.canBulkChange}}
-      <li><a class="link-action js-issues-bulk-change">
-        <span><i class="icon-bulk-change"></i> {{t 'bulk_change'}}</span>
-      </a></li>
-    {{/if}}
-  </ul>
-</div>
+{{#if hasIssues}}
+  <div class="component-viewer-header-expanded-bar-section component-viewer-header-expanded-bar-section-actions">
+    <div class="component-viewer-header-expanded-bar-section-title">&nbsp;</div>
+    <ul class="component-viewer-header-expanded-bar-section-list">
+      {{#if state.canBulkChange}}
+        <li><a class="link-action js-issues-bulk-change">
+          <span><i class="icon-bulk-change"></i> {{t 'bulk_change'}}</span>
+        </a></li>
+      {{/if}}
+    </ul>
+  </div>
+{{/if}}
index 8f60976ae3bc1bb3ebf580ae51fd93717414a1e4..d5802abdd570043d7a0752f5a616bd0bd040bde9 100644 (file)
@@ -1,5 +1,5 @@
 <div class="component-viewer-header-time-changes">
   <a class="highlighted-link js-scm-time-changes">
-    {{#if period}}Δ {{period.label}}{{else}}<i class="icon-period"></i> Time Changes{{/if}}
+    {{#if period}}Δ {{period.label}}{{else}}<i class="icon-period"></i> {{t 'component_viewer.time_changes'}}{{/if}}
   </a>
 </div>
\ No newline at end of file
index 9f6348a61c82c0e74623ea0b3e387065f57023c2..b0fc9ccb818c9e76d46bb90dd411852e5e7ca6db 100644 (file)
@@ -138,7 +138,7 @@ define(['handlebars', 'moment'], function (Handlebars, moment) {
         notEmpty = args.reduce(function(prev, current) {
           return prev || (current && current.length > 0);
         }, false);
-    return notEmpty ? options.fn(this) : '';
+    return notEmpty ? options.fn(this) : options.inverse(this);
   });
 
   Handlebars.registerHelper('join', function(array, separator) {