]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4301 Add status and assignee filters on issues search page
authorJulien Lancelot <julien.lancelot@gmail.com>
Thu, 16 May 2013 15:22:09 +0000 (17:22 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 16 May 2013 15:22:09 +0000 (17:22 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/action_plans.html.erb
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/unresolved_issues_per_assignee.html.erb
sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
sonar-server/src/main/java/org/sonar/server/issue/InternalRubyIssueService.java
sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
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/_sidebar.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issues_action_plans/_progress.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/issues/_issues_list.html.erb

index db2ec13171229481cf3b9cff4da330749811a200..4d896a83f76a4819b0f36d799f68bc60d8101936 100644 (file)
@@ -67,7 +67,7 @@
             <% if unresolved_issues_size == 0 %>
               <%= unresolved_issues_size -%>
             <% else %>
-              <a href="<%= url_for({:controller => 'issues', :action => 'index',
+              <a href="<%= url_for({:controller => 'issues', :action => 'search',
                                     :actionPlans => plan.key, :resolved => 'false'}) -%>"
                  title="<%= message('widget.issues_action_plans.x_unresolved_issues', :params => unresolved_issues_size.to_s) -%>"><%= unresolved_issues_size -%></a>
             <% end %>
index 2a39ea58e0c86be9c0a81aa77fc386f47809fe6e..a34ac48d079f22a197f1b415acf6bee65f2ffcc2 100644 (file)
@@ -54,7 +54,8 @@
       %>
         <tr class="<%= cycle 'even', 'odd', :name => (div_id) -%>">
           <td class="max-width">
-            <%= link_to results.user(assignee).name, {:controller => 'issues', :action => 'index', :assignees => assignee}.merge(options) -%>
+            <%= link_to results.user(assignee).name,
+                        {:controller => 'issues', :action => 'search', :assignees => assignee}.merge(options) -%>
           </td>
           <td class="nowrap">
             <%= '+' if @dashboard_configuration.selected_period? -%><%= count.to_s -%>
@@ -73,7 +74,7 @@
         <tr class="<%= cycle 'even', 'odd', :name => (div_id) -%>">
           <td class="max-width">
             <%= link_to message('widget.unresolved_issues_per_assignee.not_assigned'),
-                        {:controller => 'issues', :action => 'index', :assigned => 'false'}.merge(options) -%>
+                        {:controller => 'issues', :action => 'search', :assigned => 'false'}.merge(options) -%>
           </td>
           <td class="nowrap">
             <%= '+' if @dashboard_configuration.selected_period? -%><%= counter_no_assignee.to_s -%>
index 6937e5756860cc21da79e6157492c5131c5780c9..89d7704c19db6383db47807cd08074e843bf81ff 100644 (file)
@@ -332,6 +332,11 @@ public final class CoreMetrics {
       .create();
 
   public static final String FUNCTION_COMPLEXITY_KEY = "function_complexity";
+
+  /**
+   * Information about the cyclomatic complexity per function, calculated by divided the complexity in functions by the number of functions.
+   * If the complexity in functions is not available, the complexity of the file is used.
+   */
   public static final Metric FUNCTION_COMPLEXITY = new Metric.Builder(FUNCTION_COMPLEXITY_KEY, "Complexity /method", Metric.ValueType.FLOAT)
       .setDescription("Complexity average by method")
       .setDirection(Metric.DIRECTION_WORST)
index d40ae9a6a374ed99ebf70f7b147ecbc1f2e19647..7c67a7467d5b1ff69a7eac08008c6a1448bc69da 100644 (file)
@@ -73,6 +73,10 @@ public class InternalRubyIssueService implements ServerComponent {
     return issueService.listTransitions(issue);
   }
 
+  public List<String> listStatus() {
+    return issueService.listStatus();
+  }
+
   public Issue doTransition(String issueKey, String transitionKey) {
     return issueService.doTransition(issueKey, transitionKey, UserSession.get());
   }
index dd4340c6d7bb1d1a47ebcf53e1b30a25dc34cc15..8bb17347e1aa8ce6a34ed508d7345fe03865e099 100644 (file)
@@ -32,6 +32,7 @@ import org.sonar.core.issue.workflow.Transition;
 import org.sonar.server.platform.UserSession;
 
 import javax.annotation.Nullable;
+
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
@@ -142,6 +143,10 @@ public class IssueService implements ServerComponent {
     return finder.findByKey(issueKey, UserRole.USER);
   }
 
+  public List<String> listStatus(){
+    return workflow.statusKeys();
+  }
+
   private void verifyLoggedIn(UserSession userSession) {
     if (!userSession.isLoggedIn()) {
       // must be logged
index 0146b498fef5198200f097871a945e2c45b8c2f1..5cd8168322e017f2d1b81f8ecd37f0e673ef35be 100644 (file)
@@ -20,6 +20,8 @@
 
 class IssuesController < ApplicationController
 
+  before_filter :init
+
   def index
     @filter = IssueFilter.new
     render :action => 'search'
@@ -34,6 +36,11 @@ class IssuesController < ApplicationController
 
   private
 
+  def init
+    status = Internal.issues.listStatus()
+    @options_for_status = status.map {|s| [message('issue.status.' + s), s]}
+  end
+
   def criteria_params
     params.merge({:controller => nil, :action => nil, :search => nil, :widget_id => nil, :edit => nil})
   end
index 1d77704fd0f553ec5f1f6576a46ef2ab40f6a592..28cec85c0a113d6583132e039de6a581cc10270e 100644 (file)
@@ -650,7 +650,8 @@ module ApplicationHelper
 
     user = options[:selected_user]
     if user
-      options[:selected_id]=user.login
+      # the login is a string so it have to be surrounded by quote to be taken in account by select2
+      options[:selected_id]="'" + user.login + "'"
       options[:selected_text]=user.name
     end
 
index 984fa2c58562e515a6483bd33d72a77f3d313fd5..61824824979d6d0d85873e70becda0ec17e7b4d1 100644 (file)
@@ -9,6 +9,18 @@
                        {:width => '100%', :placeholder => message('issue_filter.criteria.severities')},
                        {:id => 'select-severities', :multiple => true}-%>
     </li>
+    <li id="criteria-status" class="marginbottom5">
+      <%= message 'issue_filter.criteria.status' -%>:
+      <%= dropdown_tag 'statuses[]', options_for_select(@options_for_status, @filter.criteria('statuses')),
+                       {:width => '100%', :placeholder => message('issue_filter.criteria.status')},
+                       {:id => 'select-status', :multiple => true}-%>
+    </li>
+    <li>
+      <%= message 'issue_filter.criteria.assignee' -%>:
+      <% selected_user = @filter.issues_result.user(@filter.criteria('assignees')) if @filter.issues_result %>
+      <%= user_select_tag('assignees', {:selected_user => selected_user, :width => '100%', :placeholder => message('issue_filter.criteria.assignee'),
+                        :html_id => 'select-assignee', :open => false, :allow_clear => true}) -%>
+    </li>
     <li>
       <input type="submit" name="search" value="<%= message('search_verb') -%>" id="search-button" />
       <a href="<%= ApplicationController.root_context -%>/issues" class="link-action"><%= message 'issue_filter.new_search' -%></a>
index 0ca29968950be1e5730fc870a3b6e92b8b2358f8..0d666b0c3afd5ff83082506a9026e5595342ddf1 100644 (file)
@@ -1,7 +1,6 @@
 <%
   unless action_plan.totalIssues()==0
-    # TODO add links to issues page
-    options = {:controller => 'issues', :action => 'index', :actionPlans => action_plan.key}
+    options = {:controller => 'issues', :action => 'search', :actionPlans => action_plan.key}
 
     resolved_issues_link = action_plan.resolvedIssues().to_s
     resolved_issues_link = link_to action_plan.resolvedIssues().to_s, options.merge({:resolved => 'true'}) unless action_plan.resolvedIssues()==0
index 9529e92824800792088e94bb4c5d38928aa3893a..32a95978c2517fba49ecdba05c87b4cfe8178e56 100644 (file)
@@ -47,7 +47,7 @@
     <tfoot>
     <tr>
       <td colspan="3">
-        <%= link_to(total_number, {:controller => "issues", :action => "index" }.merge(search_options))  %> <%= message('results').downcase -%>
+        <%= link_to(total_number, {:controller => 'issues', :action => 'search' }.merge(search_options)) -%> <%= message('results').downcase -%>
         <%
            if page_count
              page_count = 20 if page_count>20