]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4301 Display project on issues search page
authorJulien Lancelot <julien.lancelot@gmail.com>
Wed, 22 May 2013 13:45:11 +0000 (15:45 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Wed, 22 May 2013 13:45:21 +0000 (15:45 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/issues/_list.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb

index ff855c03b5cae22b6ea2fc08d591d93b3f6a3434..be7e09a7489433f5f40d98b7b929301140067678 100644 (file)
@@ -32,7 +32,7 @@ class IssuesController < ApplicationController
     @filter.criteria=criteria_params
     @filter.execute
 
-    @project = Project.by_key(@filter.criteria('componentRoots')).root_project if @filter.criteria('componentRoots')
+    @selected_project = @filter.issues_result.projects.first if !@filter.issues.isEmpty() && @filter.criteria('componentRoots')
   end
 
 
index 032f8759df683d6d9a335c523b3b769d503319dc..25e3cf9e8d90f2b6a4d99a1f803cbd23c6e52608 100644 (file)
@@ -658,7 +658,6 @@ module ApplicationHelper
   # * <tt>:placeholder</tt> - the label to display when nothing is selected
   # * <tt>:allow_clear</tt> - true if resource can be de-selected. Default is false.
   # * <tt>:open</tt> - true if the select-box must be open. Default is false.
-  # * <tt>:display_key</tt> - true if the resource key should be used instead of the resource id. Default is false.
   # * <tt>:select2_options</tt> - hash of select2 options
   #
   def resource_select_tag(name, options={})
@@ -672,14 +671,47 @@ module ApplicationHelper
       ws_url+="qp=#{options[:resource_type_property]}"
     end
 
-    if options[:display_key]
-      ws_url+='&display_key=true'
+    selected_resource = options[:selected_resource]
+    if selected_resource
+      options[:selected_id] = selected_resource.id
+      options[:selected_text] = selected_resource.name(true)
     end
 
+    select2_tag(name, ws_url, options)
+  end
+
+  #
+  # Creates an enhanced dropdown selection box of components. Values are loaded on the fly via Ajax requests.
+  # ==== Options
+  # * <tt>:width</tt> - The width suffixed with unit, for example '300px' or '100%'. Default is '250px'
+  # * <tt>:html_id</tt> - The id of the HTML element. Default is the name.
+  # * <tt>:html_class</tt> - The class of the HTML element. Default is empty.
+  # * <tt>:qualifiers</tt> - Array of resource qualifiers to filter.
+  # * <tt>:resource_type_property</tt> -Filter on resource types on which the property is enabled, for example 'supportsGlobalDashboards'.
+  # * <tt>:selected_resource</tt> - the resource that is selected by default.
+  # * <tt>:placeholder</tt> - the label to display when nothing is selected
+  # * <tt>:allow_clear</tt> - true if resource can be de-selected. Default is false.
+  # * <tt>:open</tt> - true if the select-box must be open. Default is false.
+  # * <tt>:select2_options</tt> - hash of select2 options
+  #
+  def component_select_tag(name, options={})
+    # see limitation in /api/resources/search
+    options[:min_length]=3
+
+    ws_url="#{ApplicationController::root_context}/api/resources/search?f=s2&"
+    if options[:qualifiers]
+      ws_url+="q=#{options[:qualifiers].join(',')}"
+    elsif options[:resource_type_property]
+      ws_url+="qp=#{options[:resource_type_property]}"
+    end
+
+    # The WS should return component key instead of component id
+    ws_url+='&display_key=true'
+
     selected_resource = options[:selected_resource]
     if selected_resource
-      options[:selected_id]= options[:display_key] ? "'" + selected_resource.key + "'" : selected_resource.id
-      options[:selected_text]=selected_resource.name(true)
+      options[:selected_id]= "'" + selected_resource.key + "'"
+      options[:selected_text] = selected_resource.name
     end
 
     select2_tag(name, ws_url, options)
index f4e75cd8afe4f294b5fe7b1f1da22c2626d19ca3..6cbf06e15718e706021df086d12d3b60d2116376 100644 (file)
           <th>
             <%= message('description') -%>
           </th>
-          <th width="1%" nowrap>
+          <th nowrap>
+            <%= message('project') -%>
+          </th>
+          <th nowrap>
             <%= message('component') -%>
           </th>
           <th>
             <img src="<%= ApplicationController.root_context -%>/images/status/<%= issue.status -%>.png" title="<%= message(issue.status.downcase).capitalize -%>"/>
           </td>
           <td>
-            <%= link_to h(truncate(issue.message, :length => 100)), :controller => 'issue', :action => 'view', :id => issue.key -%>
+            <%= link_to h(truncate(issue.message, :length => 200)), :controller => 'issue', :action => 'view', :id => issue.key -%>
+          </td>
+          <td>
+            <%= h h(truncate(@filter.issues_result.project(issue).name, :length => 100)) -%>
           </td>
           <td>
             <%= h @filter.issues_result.component(issue).name -%>
index 102b50aab1ff916e3fafbd21a3e879ef52e2fe7e..7abcd58515bfea723e41bd6749d0b195f1a9c4e9 100644 (file)
@@ -8,10 +8,9 @@
       <%= message('issue_filter.new_search') -%>
     </li>
     <li id="criteria-project" class="marginbottom5">
-      <% selected_project = @project if @filter.criteria('componentRoots') %>
       <%= message 'issue_filter.criteria.project' -%>:
-      <%= resource_select_tag 'componentRoots', :resource_type_property => 'supportsGlobalDashboards', :width => '100%',
-                              :selected_resource => selected_project,
+      <%= component_select_tag 'componentRoots', :resource_type_property => 'supportsGlobalDashboards', :width => '100%',
+                              :selected_resource => @selected_project,
                               :display_key => true,
                               :placeholder => message('issue_filter.criteria.project'),
                               :html_id => 'select-project',