diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-16 11:21:26 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-16 11:22:00 +0200 |
commit | c884d6186069ec70c4936dc084a2bc1b705e7928 (patch) | |
tree | 952dfb1063cb19fccce24d840a9e033903b4a725 /server/sonar-web | |
parent | 7295a1cb8b5edd9d8889a08fe5795e6c43788161 (diff) | |
download | sonarqube-c884d6186069ec70c4936dc084a2bc1b705e7928.tar.gz sonarqube-c884d6186069ec70c4936dc084a2bc1b705e7928.zip |
SONAR-6748 Display a warning when open non-existent file/rule
Diffstat (limited to 'server/sonar-web')
5 files changed, 163 insertions, 126 deletions
diff --git a/server/sonar-web/src/main/js/components/source-viewer/main.js b/server/sonar-web/src/main/js/components/source-viewer/main.js index 77d5c5ff8d2..6a0119d2357 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/main.js +++ b/server/sonar-web/src/main/js/components/source-viewer/main.js @@ -158,8 +158,19 @@ define([ requestComponent: function () { var that = this, url = baseUrl + '/api/components/app', - options = { uuid: this.model.id }; - return $.get(url, options).done(function (data) { + data = { uuid: this.model.id }; + return $.ajax({ + type: 'GET', + url: url, + data: data, + statusCode: { + 404: function () { + that.model.set({ exist: false }); + that.render(); + that.trigger('loaded'); + } + } + }).done(function (data) { that.model.set(data); that.model.set({ isUnitTest: data.q === 'UTS' }); }); diff --git a/server/sonar-web/src/main/js/components/source-viewer/source.js b/server/sonar-web/src/main/js/components/source-viewer/source.js index 168a86bb9c2..9040b5e89b4 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/source.js +++ b/server/sonar-web/src/main/js/components/source-viewer/source.js @@ -24,6 +24,8 @@ define(function () { defaults: function () { return { + exist: true, + hasSource: false, hasCoverage: false, hasITCoverage: false, diff --git a/server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer.hbs b/server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer.hbs index 172a55504a5..d5ac6aed718 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer.hbs +++ b/server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer.hbs @@ -2,93 +2,103 @@ {{#if canSeeCode}} - {{#if hasSourceBefore}} - <i class="spinner js-component-viewer-source-before"></i> - {{/if}} + {{#if exist}} - <table class="source-table"> - {{#each source}} - <tr class="source-line {{#eq line 0}}{{#empty issues}}hidden{{/empty}}{{/eq}}" {{#if line}}data-line-number="{{line}}"{{/if}}> - <td class="source-meta source-line-number" {{#if line}}data-line-number="{{line}}"{{/if}}></td> - - <td class="source-meta source-line-scm" {{#if line}}data-line-number="{{line}}"{{/if}}> - {{#ifSCMChanged2 ../source line}} - <div class="source-line-scm-inner" data-author="{{scmAuthor}}"></div> - {{/ifSCMChanged2}} - </td> - - {{#if ../hasUTCoverage}} - <td class="source-meta source-line-coverage {{#notNull utCoverageStatus}}source-line-{{utCoverageStatus}}{{/notNull}}" - data-tests="ut" - data-line-number="{{line}}" {{#notNull utCoverageStatus}}title="{{t 'source_viewer.tooltip.ut' utCoverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}> - <div class="source-line-bar"></div> + {{#if hasSourceBefore}} + <i class="spinner js-component-viewer-source-before"></i> + {{/if}} + + <table class="source-table"> + {{#each source}} + <tr class="source-line {{#eq line 0}}{{#empty issues}}hidden{{/empty}}{{/eq}}" {{#if line}}data-line-number="{{line}}"{{/if}}> + <td class="source-meta source-line-number" {{#if line}}data-line-number="{{line}}"{{/if}}></td> + + <td class="source-meta source-line-scm" {{#if line}}data-line-number="{{line}}"{{/if}}> + {{#ifSCMChanged2 ../source line}} + <div class="source-line-scm-inner" data-author="{{scmAuthor}}"></div> + {{/ifSCMChanged2}} </td> - {{/if}} - {{#if ../hasITCoverage}} - <td class="source-meta source-line-coverage {{#notNull itCoverageStatus}}source-line-{{itCoverageStatus}}{{/notNull}}" - data-tests="it" - data-line-number="{{line}}" {{#notNull itCoverageStatus}}title="{{t 'source_viewer.tooltip.it' itCoverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}> - <div class="source-line-bar"></div> + {{#if ../hasUTCoverage}} + <td class="source-meta source-line-coverage {{#notNull utCoverageStatus}}source-line-{{utCoverageStatus}}{{/notNull}}" + data-tests="ut" + data-line-number="{{line}}" {{#notNull utCoverageStatus}}title="{{t 'source_viewer.tooltip.ut' utCoverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}> + <div class="source-line-bar"></div> + </td> + {{/if}} + + {{#if ../hasITCoverage}} + <td class="source-meta source-line-coverage {{#notNull itCoverageStatus}}source-line-{{itCoverageStatus}}{{/notNull}}" + data-tests="it" + data-line-number="{{line}}" {{#notNull itCoverageStatus}}title="{{t 'source_viewer.tooltip.it' itCoverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}> + <div class="source-line-bar"></div> + </td> + {{/if}} + + {{#if ../hasDuplications}} + <td class="source-meta source-line-duplications {{#if duplicated}}source-line-duplicated{{/if}}" + {{#if duplicated}}title="{{t 'source_viewer.tooltip.duplicated_line'}}" data-placement="right" data-toggle="tooltip"{{/if}}> + <div class="source-line-bar"></div> + </td> + + {{#each duplications}} + <td class="source-meta source-line-duplications-extra {{#if this}}source-line-duplicated{{/if}}" + data-index="{{this}}" data-line-number="{{../line}}" + {{#if this}}title="{{t 'source_viewer.tooltip.duplicated_block'}}" data-placement="right" data-toggle="tooltip"{{/if}}> + <div class="source-line-bar"></div> + </td> + {{/each}} + {{/if}} + + <td class="source-meta source-line-issues {{#notEmpty issues}}source-line-with-issues{{/notEmpty}}" + data-line-number="{{line}}"> + {{#withFirst issues}} + {{severityIcon severity}} + {{/withFirst}} + {{#ifLengthGT issues 1}} + <span class="source-line-issues-counter">{{length issues}}</span> + {{/ifLengthGT}} </td> - {{/if}} - {{#if ../hasDuplications}} - <td class="source-meta source-line-duplications {{#if duplicated}}source-line-duplicated{{/if}}" - {{#if duplicated}}title="{{t 'source_viewer.tooltip.duplicated_line'}}" data-placement="right" data-toggle="tooltip"{{/if}}> + <td class="source-meta source-line-filtered-container" data-line-number="{{line}}"> <div class="source-line-bar"></div> </td> - {{#each duplications}} - <td class="source-meta source-line-duplications-extra {{#if this}}source-line-duplicated{{/if}}" - data-index="{{this}}" data-line-number="{{../line}}" - {{#if this}}title="{{t 'source_viewer.tooltip.duplicated_block'}}" data-placement="right" data-toggle="tooltip"{{/if}}> - <div class="source-line-bar"></div> - </td> - {{/each}} - {{/if}} - - <td class="source-meta source-line-issues {{#notEmpty issues}}source-line-with-issues{{/notEmpty}}" - data-line-number="{{line}}"> - {{#withFirst issues}} - {{severityIcon severity}} - {{/withFirst}} - {{#ifLengthGT issues 1}} - <span class="source-line-issues-counter">{{length issues}}</span> - {{/ifLengthGT}} - </td> - - <td class="source-meta source-line-filtered-container" data-line-number="{{line}}"> - <div class="source-line-bar"></div> - </td> - - <td class="source-line-code code {{#notEmpty issues}}has-issues{{/notEmpty}}" data-line-number="{{line}}"> - <div class="source-line-code-inner"> - {{#notNull code}} - <pre>{{{codeWithIssueLocations code issueLocations}}}</pre> - {{/notNull}} - - <div class="source-line-issue-locations"></div> - </div> - - {{#notEmpty issues}} - <div class="issue-list"> - {{#each issues}} - <div class="issue" id="issue-{{key}}"></div> - {{/each}} + <td class="source-line-code code {{#notEmpty issues}}has-issues{{/notEmpty}}" data-line-number="{{line}}"> + <div class="source-line-code-inner"> + {{#notNull code}} + <pre>{{{codeWithIssueLocations code issueLocations}}}</pre> + {{/notNull}} + + <div class="source-line-issue-locations"></div> </div> - {{/notEmpty}} - </td> - </tr> - {{/each}} - </table> - - {{#if hasSourceAfter}} - <i class="spinner js-component-viewer-source-after"></i> + + {{#notEmpty issues}} + <div class="issue-list"> + {{#each issues}} + <div class="issue" id="issue-{{key}}"></div> + {{/each}} + </div> + {{/notEmpty}} + </td> + </tr> + {{/each}} + </table> + + {{#if hasSourceAfter}} + <i class="spinner js-component-viewer-source-after"></i> + {{/if}} + + {{else}} + + {{! does not exist }} + <div class="alert alert-warning spacer-top">{{t 'component_viewer.no_component'}}</div> + {{/if}} {{else}} - <div class="alert alert-warning">{{t 'code_viewer.no_source_code_displayed_due_to_security'}}</div> + {{! can't see code }} + <div class="alert alert-warning spacer-top">{{t 'code_viewer.no_source_code_displayed_due_to_security'}}</div> {{/if}} diff --git a/server/sonar-web/src/main/js/components/workspace/main.js b/server/sonar-web/src/main/js/components/workspace/main.js index 01d1e60fb5b..55cf5d7ed0a 100644 --- a/server/sonar-web/src/main/js/components/workspace/main.js +++ b/server/sonar-web/src/main/js/components/workspace/main.js @@ -119,9 +119,14 @@ define([ showRule: function (model) { var that = this; - this.fetchRule(model).done(function () { - that.showViewer(RuleView, model); - }); + this.fetchRule(model) + .done(function () { + model.set({ exist: true }); + that.showViewer(RuleView, model); + }).fail(function () { + model.set({ exist: false }); + that.showViewer(RuleView, model); + }); }, fetchRule: function (model) { diff --git a/server/sonar-web/src/main/js/components/workspace/templates/workspace-rule.hbs b/server/sonar-web/src/main/js/components/workspace/templates/workspace-rule.hbs index 9b6cbeabea2..0624cedeafa 100644 --- a/server/sonar-web/src/main/js/components/workspace/templates/workspace-rule.hbs +++ b/server/sonar-web/src/main/js/components/workspace/templates/workspace-rule.hbs @@ -2,64 +2,73 @@ <div class="workspace-viewer-container"> - <ul class="coding-rules-detail-properties"> - {{#if severity}} - {{#unless isManual}} - <li class="coding-rules-detail-property" - data-toggle="tooltip" data-placement="bottom" title="Default rule severity"> - {{severityIcon severity}} {{t "severity" severity}} - </li> - {{/unless}} - {{/if}} + {{#if exist}} - {{#notEq status 'READY'}} - <li class="coding-rules-detail-property" - data-toggle="tooltip" data-placement="bottom" title="Rule status">{{status}}</li> - {{/notEq}} + <ul class="coding-rules-detail-properties"> + {{#if severity}} + {{#unless isManual}} + <li class="coding-rules-detail-property" + data-toggle="tooltip" data-placement="bottom" title="Default rule severity"> + {{severityIcon severity}} {{t "severity" severity}} + </li> + {{/unless}} + {{/if}} - <li class="coding-rules-detail-property coding-rules-detail-tag-list {{#if canWrite}}coding-rules-detail-tags-change{{/if}}" - data-toggle="tooltip" data-placement="bottom" title="Rule tags"> - <i class="icon-tags"></i> - <span>{{#if allTags}}{{join allTags ', '}}{{else}}{{t 'coding_rules.no_tags'}}{{/if}}</span> - </li> + {{#notEq status 'READY'}} + <li class="coding-rules-detail-property" + data-toggle="tooltip" data-placement="bottom" title="Rule status">{{status}}</li> + {{/notEq}} - <li class="coding-rules-detail-property">{{t 'coding_rules.available_since'}} {{d createdAt}}</li> + <li class="coding-rules-detail-property coding-rules-detail-tag-list {{#if canWrite}}coding-rules-detail-tags-change{{/if}}" + data-toggle="tooltip" data-placement="bottom" title="Rule tags"> + <i class="icon-tags"></i> + <span>{{#if allTags}}{{join allTags ', '}}{{else}}{{t 'coding_rules.no_tags'}}{{/if}}</span> + </li> - <li class="pull-right spacer-left"> - <a class="icon-link" target="_blank" href="{{rulePermalink key}}"></a> - </li> + <li class="coding-rules-detail-property">{{t 'coding_rules.available_since'}} {{d createdAt}}</li> - <li class="pull-right"> - <span class="note">{{key}}</span> - </li> - </ul> + <li class="pull-right spacer-left"> + <a class="icon-link" target="_blank" href="{{rulePermalink key}}"></a> + </li> - {{#if debtCharName}} - <ul class="coding-rules-detail-properties"> - <li class="coding-rules-detail-property" - data-toggle="tooltip" data-placement="bottom" title="Rule characteristic"> - {{debtCharName}}{{#if debtSubCharName}} > {{debtSubCharName}}{{/if}} + <li class="pull-right"> + <span class="note">{{key}}</span> </li> + </ul> - {{#if debtRemFnType}} + {{#if debtCharName}} + <ul class="coding-rules-detail-properties"> <li class="coding-rules-detail-property" - data-toggle="tooltip" data-placement="bottom" title="{{t 'coding_rules.remediation_function'}}"> - {{t 'coding_rules.remediation_function' debtRemFnType}}: - - {{#if debtRemFnOffset}}{{debtRemFnOffset}}{{/if}} - {{#if debtRemFnCoeff}}{{#if debtRemFnOffset}}+{{/if}}{{debtRemFnCoeff}}{{/if}} - {{#if effortToFixDescription}}{{effortToFixDescription}}{{/if}} + data-toggle="tooltip" data-placement="bottom" title="Rule characteristic"> + {{debtCharName}}{{#if debtSubCharName}} > {{debtSubCharName}}{{/if}} </li> - {{/if}} - </ul> - {{/if}} - <div class="coding-rules-detail-description rule-desc markdown">{{{htmlDesc}}}</div> + {{#if debtRemFnType}} + <li class="coding-rules-detail-property" + data-toggle="tooltip" data-placement="bottom" title="{{t 'coding_rules.remediation_function'}}"> + {{t 'coding_rules.remediation_function' debtRemFnType}}: + + {{#if debtRemFnOffset}}{{debtRemFnOffset}}{{/if}} + {{#if debtRemFnCoeff}}{{#if debtRemFnOffset}}+{{/if}}{{debtRemFnCoeff}}{{/if}} + {{#if effortToFixDescription}}{{effortToFixDescription}}{{/if}} + </li> + {{/if}} + </ul> + {{/if}} + + <div class="coding-rules-detail-description rule-desc markdown">{{{htmlDesc}}}</div> + + {{#if htmlNote}} + <div id="coding-rules-detail-description-extra"> + <div class="rule-desc markdown">{{{htmlNote}}}</div> + </div> + {{/if}} + + {{else}} + + {{! does not exist}} + <div class="alert alert-warning">{{t 'workspace.no_rule'}}</div> - {{#if htmlNote}} - <div id="coding-rules-detail-description-extra"> - <div class="rule-desc markdown">{{{htmlNote}}}</div> - </div> {{/if}} </div> |