From 2f90b1d6cf95f275d8dfc891c9b4f116ff3d7d0d Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 19 Jun 2014 12:37:10 +0600 Subject: SONAR-5209 Differential mode feedback --- .../src/main/coffee/component-viewer/header.coffee | 6 +++- .../component-viewer/header/coverage-header.coffee | 2 +- .../component-viewer/header/issues-header.coffee | 6 ++-- .../src/main/coffee/component-viewer/main.coffee | 17 +++++++---- .../component-viewer/header/coverage-header.hbs | 34 ++++++++++++++++++---- .../hbs/component-viewer/header/issues-header.hbs | 26 +++++++++-------- .../hbs/component-viewer/header/scm-header.hbs | 2 +- .../src/main/js/common/handlebars-extensions.js | 2 +- 8 files changed, 67 insertions(+), 28 deletions(-) (limited to 'sonar-server') diff --git a/sonar-server/src/main/coffee/component-viewer/header.coffee b/sonar-server/src/main/coffee/component-viewer/header.coffee index f46a87fa4bb..47483ea3a14 100644 --- a/sonar-server/src/main/coffee/component-viewer/header.coffee +++ b/sonar-server/src/main/coffee/component-viewer/header.coffee @@ -131,7 +131,11 @@ define [ enableBarItem: (item) -> - @$(item).click() + $item = @$(item) + if $item.length > 0 + @$(item).click() + else + @options.main.hideAllLines() showExpandedBar: (e) -> diff --git a/sonar-server/src/main/coffee/component-viewer/header/coverage-header.coffee b/sonar-server/src/main/coffee/component-viewer/header/coverage-header.coffee index 9be848b52cc..1c426b35379 100644 --- a/sonar-server/src/main/coffee/component-viewer/header/coverage-header.coffee +++ b/sonar-server/src/main/coffee/component-viewer/header/coverage-header.coffee @@ -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) -> diff --git a/sonar-server/src/main/coffee/component-viewer/header/issues-header.coffee b/sonar-server/src/main/coffee/component-viewer/header/issues-header.coffee index 54e2c93dc25..fa066fe0298 100644 --- a/sonar-server/src/main/coffee/component-viewer/header/issues-header.coffee +++ b/sonar-server/src/main/coffee/component-viewer/header/issues-header.coffee @@ -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 diff --git a/sonar-server/src/main/coffee/component-viewer/main.coffee b/sonar-server/src/main/coffee/component-viewer/main.coffee index 68a95f0f34c..8dd9ad705e1 100644 --- a/sonar-server/src/main/coffee/component-viewer/main.coffee +++ b/sonar-server/src/main/coffee/component-viewer/main.coffee @@ -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) -> diff --git a/sonar-server/src/main/hbs/component-viewer/header/coverage-header.hbs b/sonar-server/src/main/hbs/component-viewer/header/coverage-header.hbs index c2b0a87ab81..f2b084d9c2b 100644 --- a/sonar-server/src/main/hbs/component-viewer/header/coverage-header.hbs +++ b/sonar-server/src/main/hbs/component-viewer/header/coverage-header.hbs @@ -1,10 +1,18 @@
- {{#if period}}Δ {{period.label}}{{else}} Time Changes{{/if}} + {{#if period}}Δ {{period.label}}{{else}} {{t 'component_viewer.time_changes'}}{{/if}}
{{#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}} +
+
+ {{t 'component_viewer.no_coverage'}} +
+ {{/any}} + {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines}}
@@ -22,9 +30,17 @@ {{#any branch_coverage conditions_to_cover covered_conditions uncovered_conditions}}
-
 
+
+ {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines}} +   + {{else}} + {{t 'component_viewer.measure_section.unit_tests'}} + {{/any}} +
    -
  •  
  • + {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines}} +
  •  
  • + {{/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'}}} @@ -50,9 +66,17 @@ {{#any it_branch_coverage it_conditions_to_cover it_covered_conditions it_uncovered_conditions}}
    -
     
    +
    + {{#any it_coverage it_line_coverage it_lines_to_cover it_covered_lines it_uncovered_lines}} +   + {{else}} + {{t 'component_viewer.measure_section.integration_tests'}} + {{/any}} +
      -
    •  
    • + {{#any it_coverage it_line_coverage it_lines_to_cover it_covered_lines it_uncovered_lines}} +
    •  
    • + {{/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'}}} diff --git a/sonar-server/src/main/hbs/component-viewer/header/issues-header.hbs b/sonar-server/src/main/hbs/component-viewer/header/issues-header.hbs index bca87c9c4a0..3a6236b6779 100644 --- a/sonar-server/src/main/hbs/component-viewer/header/issues-header.hbs +++ b/sonar-server/src/main/hbs/component-viewer/header/issues-header.hbs @@ -1,6 +1,6 @@ @@ -40,7 +40,7 @@
      - {{t 'component_viewer.measure_section.issues'}} + {{#if hasIssues}} {{else}}{{t 'component_viewer.no_issues'}}{{/if}}
        {{#if currentIssue}} @@ -65,13 +65,15 @@
      -
      -
       
      - -
      +{{#if hasIssues}} +
      +
       
      + +
      +{{/if}} diff --git a/sonar-server/src/main/hbs/component-viewer/header/scm-header.hbs b/sonar-server/src/main/hbs/component-viewer/header/scm-header.hbs index 8f60976ae3b..d5802abdd57 100644 --- a/sonar-server/src/main/hbs/component-viewer/header/scm-header.hbs +++ b/sonar-server/src/main/hbs/component-viewer/header/scm-header.hbs @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/sonar-server/src/main/js/common/handlebars-extensions.js b/sonar-server/src/main/js/common/handlebars-extensions.js index 9f6348a61c8..b0fc9ccb818 100644 --- a/sonar-server/src/main/js/common/handlebars-extensions.js +++ b/sonar-server/src/main/js/common/handlebars-extensions.js @@ -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) { -- cgit v1.2.3