]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6766 show issue execution flow
authorStas Vilchik <vilchiks@gmail.com>
Thu, 13 Aug 2015 11:55:24 +0000 (13:55 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 14 Aug 2015 14:01:30 +0000 (16:01 +0200)
server/sonar-web/src/main/js/components/issue/issue-view.js
server/sonar-web/src/main/js/components/issue/models/issue.js
server/sonar-web/src/main/js/components/issue/templates/issue.hbs
server/sonar-web/src/main/js/components/source-viewer/main.js
server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer-flow-location.hbs [deleted file]
server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer-issue-location.hbs [new file with mode: 0644]
server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer.hbs
server/sonar-web/src/main/less/components/source.less
server/sonar-web/test/medium/source-viewer.spec.js

index aad34a2d04c39e8d4e2d8ce8045233d667390456..3a48d4e3dd2f26b27659d3e0dbd2196cec76dd66 100644 (file)
@@ -225,7 +225,8 @@ define([
     serializeData: function () {
       var issueKey = encodeURIComponent(this.model.get('key'));
       return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        permalink: baseUrl + '/issues/search#issues=' + issueKey
+        permalink: baseUrl + '/issues/search#issues=' + issueKey,
+        hasSecondaryLocations: this.model.get('secondaryLocations').length || this.model.get('executionFlows').length
       });
     }
   });
index 4eaf340f12d22d40c1be3833806d7fe62c6855e1..c5b1eacc70d69ac59fd81ba6531af1eadcf290ed 100644 (file)
@@ -3,6 +3,13 @@ define(function () {
   return Backbone.Model.extend({
     idAttribute: 'key',
 
+    defaults: function () {
+      return {
+        secondaryLocations: [],
+        executionFlows: []
+      }
+    },
+
     url: function () {
       return baseUrl + '/api/issues/show?key=' + this.get('key');
     },
index 06e878f7b8fe05411cefdd8a79d14965f3b7b385..7b12f2db96ebc35cd897441d20b1e0d30a5761b3 100644 (file)
             </li>
           {{/if}}
 
-          {{#notEmpty secondaryLocations}}
+          {{#if hasSecondaryLocations}}
             <li class="issue-meta issue-meta-locations">
               <button class="button-link issue-action js-issue-locations">
                 <i class="icon-issue-flow"></i>
               </button>
             </li>
-          {{/notEmpty}}
+          {{/if}}
 
           <li class="issue-meta">
             <a class="js-issue-permalink icon-link" href="{{permalink}}" target="_blank"></a>
index a73b56a315f08e63b8e4ff1a3b2d923b9c520250..62129a4e376d7716cb78f85a662b2d9fef4b94ef 100644 (file)
@@ -48,7 +48,7 @@ define([
       return Marionette.LayoutView.extend({
         className: 'source-viewer',
         template: Templates['source-viewer'],
-        flowLocationTemplate: Templates['source-viewer-flow-location'],
+        issueLocationTemplate: Templates['source-viewer-issue-location'],
 
         ISSUES_LIMIT: 3000,
         LINES_LIMIT: 1000,
@@ -752,7 +752,11 @@ define([
                 msg: issue.get('message'),
                 textRange: issue.get('textRange')
               },
-              _locations = [primaryLocation].concat(issue.get('secondaryLocations'));
+              secondaryLocations = issue.get('secondaryLocations'),
+              _locations = [primaryLocation].concat(secondaryLocations);
+          issue.get('executionFlows').forEach(function (flow) {
+            _locations = [].concat(_locations, flow.locations);
+          });
           _locations.forEach(this.showFlowLocation, this);
         },
 
@@ -761,14 +765,14 @@ define([
             var line = location.textRange.startLine,
                 row = this.$('.source-line-code[data-line-number="' + line + '"]'),
                 renderedFlowLocation = this.renderFlowLocation(location);
-            row.append(renderedFlowLocation);
+            row.find('.source-line-issue-locations').append(renderedFlowLocation);
             this.highlightFlowLocationInCode(location);
           }
         },
 
         renderFlowLocation: function (location) {
           location.msg = location.msg ? location.msg : ' ';
-          return this.flowLocationTemplate(location);
+          return this.issueLocationTemplate(location);
         },
 
         highlightFlowLocationInCode: function (location) {
@@ -789,7 +793,7 @@ define([
 
         hideFlowLocations: function () {
           this.locationsShowFor = null;
-          this.$('.source-viewer-flow-location').remove();
+          this.$('.source-line-issue-locations').empty();
           this.$('.source-line-code-secondary-issue').removeClass('source-line-code-secondary-issue');
         }
       });
diff --git a/server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer-flow-location.hbs b/server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer-flow-location.hbs
deleted file mode 100644 (file)
index e11d220..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<div class="source-viewer-flow-location" title="{{msg}}">{{limitString msg}} </div>
diff --git a/server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer-issue-location.hbs b/server/sonar-web/src/main/js/components/source-viewer/templates/source-viewer-issue-location.hbs
new file mode 100644 (file)
index 0000000..52ff583
--- /dev/null
@@ -0,0 +1 @@
+<div class="source-viewer-issue-location" title="{{msg}}">{{limitString msg}}</div>
index 23bed5935165404a99bc6f1cec99334773d3443c..4600706741ebb53d84ad7e299a02f95b231f8ca9 100644 (file)
         </td>
 
         <td class="source-line-code code {{#notEmpty issues}}has-issues{{/notEmpty}}" data-line-number="{{line}}">
-          {{#notNull code}}
-            <pre>{{{codeWithIssueLocations code issueLocations}}}</pre>
-          {{/notNull}}
+          <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">
index bddf7ae578604bb65d11298451311f84bc9ae282..fd9b82435dab5f06587a1bb7e3647468f0450fa0 100644 (file)
   position: relative;
   padding: 0 10px;
 
+  pre {
+    float: left;
+  }
+
   .issue-list {
     margin-left: -10px;
     margin-right: -10px;
   }
 }
 
+.source-line-code-inner {
+  .clearfix;
+}
+
 .source-line-code-issue {
   display: inline-block;
   background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAGCAYAAAAPDoR2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM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uWi4sSGW8yAAAAABJRU5ErkJggg==);
   text-align: right;
 }
 
-.source-viewer-flow-location {
-  position: absolute;
-  top: 0;
-  right: 10px;
+.source-viewer-issue-location {
+  float: left;
   height: @source-line-height - 1px;
   line-height: @source-line-height - 1px;
   padding: 0 10px;
   background-color: @red;
   color: #fff;
   font-size: 12px;
-  z-index: @issue-flow-location-z-index;
+}
+
+.source-viewer-issue-location + .source-viewer-issue-location {
+  margin-left: 10px;
 }
 
 .source-viewer-flow-location + .source-viewer-flow-location {
   z-index: @issue-flow-location-z-index - 1;
 }
+
+.source-line-issue-locations {
+  float: right;
+  padding-bottom: 1px;
+
+  &:empty {
+    display: none;
+  }
+}
index 95d33dbab18706f9c6b8c0dae87dadc301834e29..544dfa394271bca6fdbe86217a4b69be8ad4b64b 100644 (file)
@@ -42,7 +42,7 @@ define(function (require) {
             .checkElementInclude('.source-line-code[data-line-number="3"] .source-line-code-issue', '14 So')
             .clickElement('.source-line-with-issues[data-line-number="3"]')
             .clickElement('.js-issue-locations')
-            .checkElementExist('.source-line-code[data-line-number="3"] .source-viewer-flow-location')
+            .checkElementExist('.source-line-code[data-line-number="3"] .source-viewer-issue-location')
             .checkElementCount('.source-line-code[data-line-number="3"] .source-line-code-secondary-issue', 2)
             .checkElementInclude('.source-line-code[data-line-number="3"] .source-line-code-secondary-issue', ') 200')
             .checkElementInclude('.source-line-code[data-line-number="3"] .source-line-code-secondary-issue', '14 So');
@@ -61,8 +61,8 @@ define(function (require) {
             .checkElementInclude('.source-line-code[data-line-number="9"] .source-line-code-issue', 'sion')
             .clickElement('.source-line-with-issues[data-line-number="9"]')
             .clickElement('.js-issue-locations')
-            .checkElementExist('.source-line-code[data-line-number="8"] .source-viewer-flow-location')
-            .checkElementExist('.source-line-code[data-line-number="9"] .source-viewer-flow-location')
+            .checkElementExist('.source-line-code[data-line-number="8"] .source-viewer-issue-location')
+            .checkElementExist('.source-line-code[data-line-number="9"] .source-viewer-issue-location')
             .checkElementCount('.source-line-code[data-line-number="8"] .source-line-code-secondary-issue', 1)
             .checkElementCount('.source-line-code[data-line-number="9"] .source-line-code-secondary-issue', 1)
             .checkElementInclude('.source-line-code[data-line-number="8"] .source-line-code-secondary-issue', 'ense ')