]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5209 Issues drilldown integration
authorStas Vilchik <vilchiks@gmail.com>
Mon, 16 Jun 2014 09:38:03 +0000 (15:38 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 16 Jun 2014 09:38:12 +0000 (15:38 +0600)
sonar-server/Gruntfile.coffee
sonar-server/src/main/coffee/component-viewer/header.coffee
sonar-server/src/main/coffee/component-viewer/main.coffee
sonar-server/src/main/coffee/component-viewer/mixins/main-issues.coffee
sonar-server/src/main/coffee/drilldown/app.coffee [new file with mode: 0644]
sonar-server/src/main/coffee/issues/views/assign-form-view.coffee
sonar-server/src/main/hbs/issues/issue.hbs
sonar-server/src/main/js/common/handlebars-extensions.js
sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb

index d98373f3c25bf36ef02c52909f0beb08deabe9d3..1cea3c8cde9d3bbb40d183aaf3618527708ec45f 100644 (file)
@@ -163,6 +163,10 @@ module.exports = (grunt) ->
         name: 'api-documentation/app'
         out: '<%= pkg.assets %>build/js/api-documentation/app.js'
 
+      drilldown: options:
+        name: 'drilldown/app'
+        out: '<%= pkg.assets %>build/js/drilldown/app.js'
+
 
     handlebars:
       options:
index 8e2fa9457b8b957374f141d2765a973778d8933f..f46a87fa4bba8a5720946d64c1fafd1a83e523e4 100644 (file)
@@ -130,6 +130,10 @@ define [
           @$(activeHeaderItem).addClass 'active'
 
 
+    enableBarItem: (item) ->
+      @$(item).click()
+
+
     showExpandedBar: (e) ->
       el = $(e.currentTarget)
       active = el.is '.active'
index 9d3c8c990e2ace6790db12ecca4cbe03856c2028..5f8bbe84eb5d12a6b8252bd71ba19ede1efd897b 100644 (file)
@@ -249,7 +249,7 @@ define [
       @sourceView.render()
 
 
-    enablePeriod: (periodKey, scope = 'scm') ->
+    enablePeriod: (periodKey) ->
       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'))).done =>
index f242a91e1c052c79637480b8d88f6ce2b742867f..10b7e1a2612c34cf25cb8c342124e21a926b02f5 100644 (file)
@@ -27,7 +27,10 @@ define [], () ->
         @filterByCurrentIssue()
         @headerView.render()
       else
-        @sourceView.render()
+        unless @state.get 'hasIssues'
+          @requestIssues(@key).done => @sourceView.render()
+        else
+          @sourceView.render()
 
 
     hideIssues: (store = false) ->
diff --git a/sonar-server/src/main/coffee/drilldown/app.coffee b/sonar-server/src/main/coffee/drilldown/app.coffee
new file mode 100644 (file)
index 0000000..5f1c15f
--- /dev/null
@@ -0,0 +1,78 @@
+requirejs.config
+  baseUrl: "#{baseUrl}/js"
+
+  paths:
+    'backbone': 'third-party/backbone'
+    'backbone.marionette': 'third-party/backbone.marionette'
+    'handlebars': 'third-party/handlebars'
+    'jquery.mockjax': 'third-party/jquery.mockjax'
+
+  shim:
+    'backbone.marionette':
+      deps: ['backbone']
+      exports: 'Marionette'
+    'backbone':
+      exports: 'Backbone'
+    'handlebars':
+      exports: 'Handlebars'
+
+
+requirejs [
+  'backbone.marionette'
+  'component-viewer/main'
+], (
+  Marionette
+  ComponentViewer
+) ->
+
+  $ = jQuery
+  App = new Marionette.Application()
+
+
+  App.addRegions
+    viewerRegion: '#accordion-panel'
+
+
+  App.requestComponentViewer = ->
+    unless App.componentViewer?
+      App.componentViewer = new ComponentViewer()
+      App.viewerRegion.show App.componentViewer
+    App.componentViewer
+
+
+
+  App.addInitializer ->
+    # Define parameters
+    drilldown = window.drilldown || {}
+    activeHeaderTab = 'issues'
+    activeHeaderItem = '.js-filter-unresolved-issues'
+    if drilldown.rule?
+      activeHeaderTab = 'issues'
+      activeHeaderItem = ".js-filter-rule[data-rule='#{drilldown.rule}']"
+    else if drilldown.severity?
+      activeHeaderTab = 'issues'
+      activeHeaderItem = ".js-filter-#{drilldown.severity}-issues"
+
+    # Add event listeners
+    $('.js-drilldown-link').on 'click', (e) ->
+      e.preventDefault()
+      key = $(e.currentTarget).data 'key'
+      viewer = App.requestComponentViewer()
+      viewer.open(key).done ->
+        if activeHeaderTab? && activeHeaderItem?
+          viewer.state.set activeHeaderTab: activeHeaderTab, activeHeaderItem: activeHeaderItem
+          viewer.headerView.render()
+        if drilldown.period?
+          viewer.enablePeriod drilldown.period
+
+
+  # Message bundles
+  l10nXHR = window.requestMessages()
+
+
+  $.when(l10nXHR).done ->
+    # Remove the initial spinner
+    $('#coding-rules-page-loader').remove()
+
+    # Start the application
+    App.start()
index 433a1b68ed3148c211ca131b33cb5ca5c09c6d2d..08e8832fe6a59df539e2557992ba990bcb9a420d 100644 (file)
@@ -28,17 +28,17 @@ define [
       additionalChoices = []
 
       if !assignee || currentUser != assignee
-        additionalChoices.push id: currentUser, text: translate('assignedToMe')
+        additionalChoices.push id: currentUser, text: t('assigned_to_me')
 
       if !!assignee
-        additionalChoices.push id: '', text: translate('unassigned')
+        additionalChoices.push id: '', text: t('unassigned')
 
       select2Options =
         allowClear: false
         width: '250px'
-        formatNoMatches: -> translate('select2.noMatches')
-        formatSearching: -> translate('select2.searching')
-        formatInputTooShort: -> translate('select2.tooShort')
+        formatNoMatches: -> t('select2.noMatches')
+        formatSearching: -> t('select2.searching')
+        formatInputTooShort: -> t('select2.tooShort')
 
       if additionalChoices.length > 0
         select2Options.minimumInputLength = 0
index 2cdc3db10bd2f3b7bfff652ccac680df543199c9..76e07d429e8c32a731b8a196694b721ed88fc2ba 100644 (file)
   <ul class="code-issue-actions code-issue-list">
     {{#inArray actions "comment"}}
       <li>
-        <a id="issue-comment" class="link-action">{{translate "actions.comment" }}</a>
+        <a id="issue-comment" class="link-action">{{t 'issue.comment.formlink' }}</a>
       </li>
     {{/inArray}}
 
 
     <li>
-      {{statusIcon status}}{{translate "statuses" status}}
-      {{#if resolution}}({{translate "resolutions" resolution}}){{/if}}
+      {{statusIcon status}}{{t 'issue.status' status}}
+      {{#if resolution}}({{t 'issue.resolution' resolution}}){{/if}}
 
       {{#ifNotEmpty transitions}}
         {{#each transitions}}
-          <a class="link-action issue-transition spacer-left" data-transition="{{this}}">{{translate "transitions" this}}</a>
+          <a class="link-action issue-transition spacer-left" data-transition="{{this}}">{{t 'issue.transition' this}}</a>
         {{/each}}
       {{/ifNotEmpty}}
     </li>
@@ -37,9 +37,9 @@
       {{#if assigneeName}}
         <a id="issue-assign" class="link-action">{{t 'assigned_to'}}</a> {{assigneeName}}</li>
       {{else}}
-        <a id="issue-assign" class="link-action">{{translate "actions.assign" }}</a>
+        <a id="issue-assign" class="link-action">{{t 'issue.assign.formlink' }}</a>
         {{#inArray actions "assign_to_me"}}
-          [<a id="issue-assign-to-me" class="link-action">{{translate "actions.assign_to_me" }}</a>]
+          [<a id="issue-assign-to-me" class="link-action">{{t 'issue.assign.to_me' }}</a>]
         {{/inArray}}
       {{/if}}
       </li>
           <ul style="display: none" class="dropdown-menu">
             {{#inArray actions "set_severity"}}
               <li>
-                <a id="issue-set-severity" class="link-action spacer-right">{{translate "actions.set_severity"}}</a>
+                <a id="issue-set-severity" class="link-action spacer-right">{{t "issue.set_severity"}}</a>
               </li>
             {{/inArray}}
             {{#pluginActions actions}}
               <li>
-                <a class="link-action spacer-right issue-action" data-action="{{this}}">{{translate "actions" this}}</a>
+                <a class="link-action spacer-right issue-action" data-action="{{this}}">{{t "actions" this}}</a>
               </li>
             {{/pluginActions}}
           </ul>
@@ -86,7 +86,7 @@
     {{else}}
       {{#inArray actions "set_severity"}}
         <li>
-          <a id="issue-set-severity" class="link-action">{{translate "actions.set_severity"}}</a>
+          <a id="issue-set-severity" class="link-action">{{t "issue.set_severity"}}</a>
         </li>
       {{/inArray}}
     {{/ifHasExtraActions}}
index b67f5e2eb0ac2e7a574fd6263f04d4e56ed7b733..bb4e6027502dd5a9227f2134a235c9fd21c6c29f 100644 (file)
@@ -81,7 +81,7 @@ define(['handlebars', 'moment'], function (Handlebars, moment) {
         ret = arg;
       }
     });
-    return ret;
+    return ret || '';
   });
 
   Handlebars.registerHelper('percent', function(value, total) {
index dbeb4d518190a82daa17a49e7d1ec8f17c90e45f..205bffa30f47b9d79d94b1b887e5357567b872c1 100644 (file)
@@ -1,3 +1,7 @@
+<% content_for :script do %>
+  <script data-main="<%= ApplicationController.root_context -%>/js/drilldown/app" src="<%= ApplicationController.root_context -%>/js/require.js"></script>
+<% end %>
+
 <%= render :partial => 'header' -%>
 
 <div class="line-block">
               <% end %>
               <%= qualifier_icon(resource) -%>&nbsp;
               <% if resource.source_code? %>
-                <a href="#" onclick="$j('#col_<%= index -%> tr').removeClass('selected'); $j('#row_<%= index -%>_<%= row_index -%>').addClass('selected'); d(<%= resource.id -%>);"
-                   alt="<%= h resource.name(true) -%>" title="<%= h resource.name(true) -%>" class="chevron-link highlighted-link"><%= h resource.name(false) %></a>
+                <a href="#" alt="<%= h resource.name(true) -%>" title="<%= h resource.name(true) -%>" data-key="<%= resource.key -%>"
+                   class="js-drilldown-link chevron-link highlighted-link"><%= h resource.name(false) %></a>
               <% else %>
                 <%= link_to(h(resource.name), {:only_path => true, :overwrite_params => {:rids => (selected ? rids-[resource.id] : rids+[resource.id])}}, :class => 'chevron-link highlighted-link') -%>
               <% end %>
   $j(document).ready(function() {
 //    displayIssues();
   });
+
+  window.drilldown = {
+    metric: <% if @metric %>'<%= @metric.id -%>'<% else %>null<% end %>,
+    rule: <% if @rule %>'<%= @rule.key -%>'<% else %>null<% end %>,
+    severity: <% if @severity %>'<%= @severity -%>'<% else %>null<% end %>,
+    period: <% if @period %><%= @period -%><% else %>null<% end %>
+  };
 </script>
 
 <div id="accordion-panel"/>