From 0699bd08464de1f080051ee93aff1d5a5c0cbead Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 19 Jun 2014 18:19:45 +0600 Subject: SONAR-5209 Handle corner cases --- .../component-viewer/extensions-popup.coffee | 1 + .../src/main/coffee/component-viewer/header.coffee | 5 +- .../src/main/coffee/component-viewer/main.coffee | 22 +- .../mixins/main-duplications.coffee | 1 + .../component-viewer/mixins/main-issues.coffee | 10 +- .../src/main/coffee/component-viewer/source.coffee | 3 +- .../src/main/coffee/component-viewer/utils.coffee | 2 + .../src/main/hbs/component-viewer/header.hbs | 234 +++++++++++---------- .../component-viewer/header/coverage-header.hbs | 48 +++-- .../header/duplications-header.hbs | 6 +- .../hbs/component-viewer/header/issues-header.hbs | 85 +++++--- .../src/main/hbs/component-viewer/source.hbs | 2 +- sonar-server/src/main/js/issues/extra.js | 2 +- sonar-server/src/main/less/component-viewer.less | 2 + 14 files changed, 253 insertions(+), 170 deletions(-) (limited to 'sonar-server') diff --git a/sonar-server/src/main/coffee/component-viewer/extensions-popup.coffee b/sonar-server/src/main/coffee/component-viewer/extensions-popup.coffee index fbe48909ee2..01701107e8a 100644 --- a/sonar-server/src/main/coffee/component-viewer/extensions-popup.coffee +++ b/sonar-server/src/main/coffee/component-viewer/extensions-popup.coffee @@ -20,6 +20,7 @@ define [ showExtension: (e) -> + e.preventDefault() key = $(e.currentTarget).data 'key' @trigger 'extension', key diff --git a/sonar-server/src/main/coffee/component-viewer/header.coffee b/sonar-server/src/main/coffee/component-viewer/header.coffee index 729ee508649..13c3a40488f 100644 --- a/sonar-server/src/main/coffee/component-viewer/header.coffee +++ b/sonar-server/src/main/coffee/component-viewer/header.coffee @@ -112,10 +112,11 @@ define [ showExtension: (key) -> - @ui.expandedBar.html('').addClass 'active' + bar = @ui.expandedBar + bar.html('').addClass 'active' @ui.expandLinks.removeClass 'active' $.get API_EXTENSION, id: @options.main.component.get('key'), tab: key, (r) => - @ui.expandedBar.html r + bar.html r closeExtension: -> diff --git a/sonar-server/src/main/coffee/component-viewer/main.coffee b/sonar-server/src/main/coffee/component-viewer/main.coffee index 7b38f0fb8a1..891acfbcf0f 100644 --- a/sonar-server/src/main/coffee/component-viewer/main.coffee +++ b/sonar-server/src/main/coffee/component-viewer/main.coffee @@ -132,7 +132,8 @@ define [ # Component @component.clear() if clear COMPONENT_FIELDS.forEach (f) => @component.set f, data[f] - @component.set 'dir', utils.splitLongName(data.path).dir + if data.path? + @component.set 'dir', utils.splitLongName(data.path).dir @component.set 'isUnitTest', data.q == 'UTS' @@ -217,15 +218,22 @@ define [ source = @requestSource key component = @requestComponent key @currentIssue = null - $.when(source, component).done => + component.done => @workspace.where(key: key).forEach (model) => model.set 'component': @component.toJSON() + @state.set 'removed', false + source.always => + @state.set 'hasSource', (source.status != 404) + @render() + @showAllLines() if showFullSource + if @settings.get('issues') then @showIssues() else @hideIssues() + if @settings.get('coverage') then @showCoverage() else @hideCoverage() + if @settings.get('duplications') then @showDuplications() else @hideDuplications() + if @settings.get('scm') then @showSCM() else @hideSCM() + .fail => + @state.set 'removed', true + @state.set 'hasSource', false @render() - @showAllLines() if showFullSource - if @settings.get('issues') then @showIssues() else @hideIssues() - if @settings.get('coverage') then @showCoverage() else @hideCoverage() - if @settings.get('duplications') then @showDuplications() else @hideDuplications() - if @settings.get('scm') then @showSCM() else @hideSCM() toggleWorkspace: (store = false) -> diff --git a/sonar-server/src/main/coffee/component-viewer/mixins/main-duplications.coffee b/sonar-server/src/main/coffee/component-viewer/mixins/main-duplications.coffee index 15c651fc44d..7dbbe896c83 100644 --- a/sonar-server/src/main/coffee/component-viewer/mixins/main-duplications.coffee +++ b/sonar-server/src/main/coffee/component-viewer/mixins/main-duplications.coffee @@ -18,6 +18,7 @@ define [], () -> augmentWithDuplications: (duplications) -> formattedSource = @source.get 'formattedSource' + return unless formattedSource formattedSource.forEach (line) -> lineDuplications = [] duplications.forEach (d, i) -> diff --git a/sonar-server/src/main/coffee/component-viewer/mixins/main-issues.coffee b/sonar-server/src/main/coffee/component-viewer/mixins/main-issues.coffee index b60f4ca27be..eb3fdcd007a 100644 --- a/sonar-server/src/main/coffee/component-viewer/mixins/main-issues.coffee +++ b/sonar-server/src/main/coffee/component-viewer/mixins/main-issues.coffee @@ -61,7 +61,10 @@ define [ @sourceView.resetShowBlocks() issues.forEach (issue) => line = issue.line || 0 - @sourceView.addShowBlock line - LINES_AROUND_ISSUE, line + LINES_AROUND_ISSUE, line == 0 + if issue.resolution == 'FIXED' || issue.resolution == 'REMOVED' + @sourceView.addShowBlock 0, 0, true + else + @sourceView.addShowBlock line - LINES_AROUND_ISSUE, line + LINES_AROUND_ISSUE, line == 0 @sourceView.render() @@ -86,7 +89,10 @@ define [ issues.forEach (issue) => if predicate issue line = issue.line || 0 - @sourceView.addShowBlock line - LINES_AROUND_ISSUE, line + LINES_AROUND_ISSUE, line == 0 + if issue.resolution == 'FIXED' || issue.resolution == 'REMOVED' + @sourceView.addShowBlock 0, 0, true + else + @sourceView.addShowBlock line - LINES_AROUND_ISSUE, line + LINES_AROUND_ISSUE, line == 0 activeIssues.push issue @source.set 'activeIssues', activeIssues @sourceView.render() diff --git a/sonar-server/src/main/coffee/component-viewer/source.coffee b/sonar-server/src/main/coffee/component-viewer/source.coffee index 2420985c1fc..7eae208323d 100644 --- a/sonar-server/src/main/coffee/component-viewer/source.coffee +++ b/sonar-server/src/main/coffee/component-viewer/source.coffee @@ -37,7 +37,7 @@ define [ events: 'click .sym': 'highlightUsages' - 'click .lid': 'highlightLine' + 'click .js-line-actions': 'highlightLine' 'click .coverage-tests': 'showCoveragePopup' @@ -101,6 +101,7 @@ define [ issues = @model.get 'activeIssues' issues.forEach (issue) => line = issue.line || 0 + line = 0 if issue.resolution == 'FIXED' || issue.resolution == 'REMOVED' row = @$("[data-line-number=#{line}]") if row.length > 0 row.removeClass 'row-hidden' diff --git a/sonar-server/src/main/coffee/component-viewer/utils.coffee b/sonar-server/src/main/coffee/component-viewer/utils.coffee index d2bdb1f00bf..46d6379cf07 100644 --- a/sonar-server/src/main/coffee/component-viewer/utils.coffee +++ b/sonar-server/src/main/coffee/component-viewer/utils.coffee @@ -2,6 +2,8 @@ define -> splitLongName: (longName) -> lastSeparator = longName.lastIndexOf '/' + if lastSeparator == -1 + lastSeparator = longName.lastIndexOf '.' dir: longName.substr 0, lastSeparator name: longName.substr lastSeparator + 1 diff --git a/sonar-server/src/main/hbs/component-viewer/header.hbs b/sonar-server/src/main/hbs/component-viewer/header.hbs index c1eaf500d2e..99a36d1fbdf 100644 --- a/sonar-server/src/main/hbs/component-viewer/header.hbs +++ b/sonar-server/src/main/hbs/component-viewer/header.hbs @@ -1,139 +1,145 @@
- {{#if component.projectName}} -
- {{qualifierIcon 'TRK'}} - {{component.projectName}} - {{#if component.subProjectName}} - / {{component.subProjectName}} - {{/if}} -
- {{/if}} - -
- {{qualifierIcon component.q}} {{component.path}} - - {{#if state.canMarkAsFavourite}} - - - + {{#unless state.removed}} + {{#if component.projectName}} +
+ {{qualifierIcon 'TRK'}} + {{component.projectName}} + {{#if component.subProjectName}} + / {{component.subProjectName}} + {{/if}} +
{{/if}} -
-
- +
+ {{qualifierIcon component.q}} {{default component.path component.name}} -
- {{#if component.isUnitTest}} - - {{/if}} + {{else}} +
Removed
+ {{/unless}} +
- {{#unless component.isUnitTest}} - -
- -
- {{default component.measures.fDebt '–'}} - {{t 'component_viewer.header.debt'}} -
- {{#if component.measures.fIssues}} -
- {{component.measures.fIssues}} - {{t 'metric.violations.name'}} -
- {{/if}} - {{#if component.measures.fIssues}} -
+ {{#inArray state.tabs 'coverage'}} + + {{/inArray}} + + {{#inArray state.tabs 'duplications'}} + + {{/inArray}} + + {{#inArray state.tabs 'scm'}} + + {{/inArray}} +
+ {{/unless}}
\ No newline at end of file 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 f2b084d9c2b..f43fcf32b12 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,8 +1,10 @@ - +{{#if state.hasSource}} + +{{/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}} @@ -22,8 +24,13 @@
{{/any}} @@ -42,8 +49,13 @@
  •  
  • {{/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'}}} + {{#if ../../state.hasSource}} + {{{componentViewerHeaderLink conditions_to_cover 'conditions_to_cover' 'js-filter-branches-to-cover'}}} + {{{componentViewerHeaderLink uncovered_conditions 'uncovered_conditions' 'js-filter-uncovered-branches'}}} + {{else}} + {{{componentViewerHeaderItem conditions_to_cover 'conditions_to_cover'}}} + {{{componentViewerHeaderItem uncovered_conditions 'uncovered_conditions'}}} + {{/if}} {{/any}} @@ -58,8 +70,13 @@ {{/any}} @@ -78,8 +95,13 @@
  •  
  • {{/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'}}} + {{#if ../../state.hasSource}} + {{{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'}}} + {{else}} + {{{componentViewerHeaderItem it_conditions_to_cover 'conditions_to_cover'}}} + {{{componentViewerHeaderItem it_uncovered_conditions 'uncovered_conditions'}}} + {{/if}} {{/any}} diff --git a/sonar-server/src/main/hbs/component-viewer/header/duplications-header.hbs b/sonar-server/src/main/hbs/component-viewer/header/duplications-header.hbs index b0ffccc3a57..f6f599f97fe 100644 --- a/sonar-server/src/main/hbs/component-viewer/header/duplications-header.hbs +++ b/sonar-server/src/main/hbs/component-viewer/header/duplications-header.hbs @@ -2,7 +2,11 @@
    {{t 'duplications'}}
    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 3a6236b6779..adf29fcb868 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,8 +1,10 @@ -
    - - {{#if period}}{{t 'component_viewer.added'}} {{period.label}}{{else}} {{t 'component_viewer.time_changes'}}{{/if}} - -
    +{{#if state.hasSource}} +
    + + {{#if period}}{{t 'component_viewer.added'}} {{period.label}}{{else}} {{t 'component_viewer.time_changes'}}{{/if}} + +
    +{{/if}} {{#ifNotEmpty state.severities}}
    @@ -11,11 +13,18 @@
    @@ -28,11 +37,18 @@ @@ -49,19 +65,32 @@ {{/if}} -
  • - {{t 'component_viewer.issues.unresolved_issues'}} - -
  • -
  • - {{t 'component_viewer.issues.fixed_issues'}} - -
  • -
  • - {{t 'component_viewer.issues.false_positive_issues'}} - {{component.measures.false_positive_issues}} - -
  • + {{#if state.hasSource}} +
  • + {{t 'component_viewer.issues.unresolved_issues'}} + +
  • + {{/if}} + {{#if state.hasSource}} +
  • + {{t 'component_viewer.issues.fixed_issues'}} + +
  • + {{/if}} + {{#if state.hasSource}} +
  • + {{t 'component_viewer.issues.false_positive_issues'}} + {{component.measures.false_positive_issues}} + +
  • + {{else}} + {{#if component.measures.false_positive_issues}} +
  • + {{t 'component_viewer.issues.false_positive_issues'}} + {{component.measures.false_positive_issues}} +
  • + {{/if}} + {{/if}} diff --git a/sonar-server/src/main/hbs/component-viewer/source.hbs b/sonar-server/src/main/hbs/component-viewer/source.hbs index 25d0a4e3e3d..ba9fc1444ec 100644 --- a/sonar-server/src/main/hbs/component-viewer/source.hbs +++ b/sonar-server/src/main/hbs/component-viewer/source.hbs @@ -60,7 +60,7 @@ {{/if}} - {{lineNumber}} + {{lineNumber}}
    {{{code}}}
    diff --git a/sonar-server/src/main/js/issues/extra.js b/sonar-server/src/main/js/issues/extra.js index bd1be25048a..073a8122876 100644 --- a/sonar-server/src/main/js/issues/extra.js +++ b/sonar-server/src/main/js/issues/extra.js @@ -156,7 +156,7 @@ define( jQuery('.navigator-details').removeClass('navigator-fetching'); app.detailsRegion.show(componentViewer); componentViewer.settings.set('issues', false); - componentViewer.open(that.model.get('component')).done(function() { + componentViewer.open(that.model.get('component')).always(function() { componentViewer.showIssues(false, that.model.toJSON()); }); }; diff --git a/sonar-server/src/main/less/component-viewer.less b/sonar-server/src/main/less/component-viewer.less index b90034eba1b..0a6c4d8fcc3 100644 --- a/sonar-server/src/main/less/component-viewer.less +++ b/sonar-server/src/main/less/component-viewer.less @@ -332,6 +332,8 @@ .component-viewer-header-component-project { color: #777; font-size: @smallFontSize; + + &.removed { text-decoration: line-through; } } .component-viewer-header-component-name { -- cgit v1.2.3