]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4303 Refactor the issue detail in the issues code viewer
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 24 May 2013 07:42:18 +0000 (09:42 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 24 May 2013 07:42:18 +0000 (09:42 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb
sonar-server/src/main/webapp/javascripts/application.js

index cbe300e096ca1a1246eb0cac64ed235ed380583c..94704fff45fdf21c7b0a3acd578716c278fd9268 100644 (file)
@@ -557,8 +557,11 @@ issue.resolution.OPEN=Open
 issue.resolution.FALSE-POSITIVE=False-positive
 issue.resolution.FIXED=Fixed
 issue.planned_for_x=Planned for {0}
+issue.planned_for=Planned for
 issue.manual.missing_rule=Missing rule
 issue.manual.no_rules=No rules.
+issue.reported_by=Reported by
+
 
 #------------------------------------------------------------------------------
 #
index 14ea05ed66a9322b3499449a471e10fd462b2c80..042396d81f11ecfbd47475e0aaa71ed8f10f05f0 100644 (file)
@@ -36,7 +36,6 @@ import org.sonar.server.platform.UserSession;
 import javax.annotation.Nullable;
 
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
 
@@ -67,23 +66,12 @@ public class IssueService implements ServerComponent {
   }
 
   /**
-   * List of available transitions, ordered by key.
+   * List of available transitions.
    * <p/>
    * Never return null, but return an empty list if the issue does not exist.
    */
   public List<Transition> listTransitions(String issueKey) {
-    DefaultIssue issue = loadIssue(issueKey);
-    if (issue == null) {
-      return Collections.emptyList();
-    }
-    List<Transition> transitions = workflow.outTransitions(issue);
-    Collections.sort(transitions, new Comparator<Transition>() {
-      @Override
-      public int compare(Transition transition, Transition transition2) {
-        return transition.key().compareTo(transition2.key());
-      }
-    });
-    return transitions;
+    return listTransitions(loadIssue(issueKey));
   }
 
   /**
@@ -93,14 +81,7 @@ public class IssueService implements ServerComponent {
     if (issue == null) {
       return Collections.emptyList();
     }
-    List<Transition> transitions = workflow.outTransitions(issue);
-    Collections.sort(transitions, new Comparator<Transition>() {
-      @Override
-      public int compare(Transition transition, Transition transition2) {
-        return transition.key().compareTo(transition2.key());
-      }
-    });
-    return transitions;
+    return workflow.outTransitions(issue);
   }
 
   public Issue doTransition(String issueKey, String transition, UserSession userSession) {
index ea1f85f8ad736c0202437f2218e978d2bf9dde51..a5fbf7c85f2264d43e18acd3da0015452b3ff63b 100644 (file)
@@ -7,19 +7,7 @@
         <a class="open-modal" modal-width="800" href="<%= url_for :controller => 'rules', :action => 'show', :id => issue.rule_key.to_s, :modal => 'true', :layout => 'false' -%>"><%= h rule_name -%></a>
       </span>
     &nbsp;
-    <%= image_tag 'sep12.png' -%>
-    &nbsp;
-
-    <%
-       created_at = Api::Utils.java_to_ruby_datetime(issue.creationDate())
-       updated_at = Api::Utils.java_to_ruby_datetime(issue.updateDate())
-       dates_title = "Created at #{format_datetime(created_at)} and updated at #{format_datetime(updated_at)}"
-    %>
-    <span title="<%= h dates_title -%>"><%= distance_of_time_in_words_to_now(created_at) -%></span>
-    &nbsp;
-    <%
-       if issue.resolution
-    %>
+    <% if issue.resolution %>
       <%= image_tag 'sep12.png' -%>
       &nbsp;
       <span><%= message("issue.resolution.#{issue.resolution}") -%></span>
       <span><%= message("issue.status.#{issue.status}") -%></span>
       &nbsp;
     <% end %>
+    <%= image_tag 'sep12.png' -%>
+    &nbsp;
     <%
-       if issue.assignee
-    %>
-      <%= image_tag 'sep12.png' -%>
-      &nbsp;
-      <%= message('assigned_to') -%> <%= h(@issue_results.user(issue.assignee).name) -%>
-      &nbsp;
-    <% end %>
-    <%
-       if issue.actionPlanKey()
+       created_at = Api::Utils.java_to_ruby_datetime(issue.creationDate())
+       updated_at = Api::Utils.java_to_ruby_datetime(issue.updateDate())
+       dates_title = "Created at #{format_datetime(created_at)} and updated at #{format_datetime(updated_at)}"
     %>
+    <span title="<%= h dates_title -%>"><%= distance_of_time_in_words_to_now(created_at) -%></span>
+    &nbsp;
+    <% if issue.reporter %>
       <%= image_tag 'sep12.png' -%>
       &nbsp;
-      <%= message('issue.planned_for_x', :params => h(@issue_results.actionPlan(issue).name())) if @issue_results.actionPlan(issue) -%>
+      <span><%= message('issue.reported_by') -%> <%= @issue_results.user(issue.reporter).name -%></span>
       &nbsp;
     <% end %>
-
   </div>
 
   <% unless issue.message.blank? %>
   <% end %>
 
   <% if current_user %>
+    <% transitions = Internal.issues.listTransitions(issue) %>
+
     <div class="code-issue-actions">
       <a href='#' onclick="return issueForm('comment', this)" class="link-action spacer-right"><%= message('issue.comment.formlink') -%></a>
       <% unless issue.resolution %>
+        <%= image_tag 'sep12.png' -%>
+        &nbsp;
         <span class="spacer-right">
-        <a href='#' onclick="return issueForm('assign', this)" class="link-action"><%= message('issue.assign.formlink') -%></a>
+        <% if !issue.assignee %>
+          <a href='#' onclick="return issueForm('assign', this)" class="link-action"><%= message('issue.assign.formlink') -%></a>
           <% if issue.assignee!=current_user.login %>
-          [<a href="#" onclick="return assignIssueToMe(this)" class="link-action"><%= message('issue.assign.to_me') -%></a>]
+            [<a href="#" onclick="return assignIssueToMe(this)" class="link-action"><%= message('issue.assign.to_me') -%></a>]
+          <% end %>
+        <% else %>
+          <a href='#' onclick="return issueForm('assign', this)" class="link-action"><%= message('assigned_to') -%></a> <%= @issue_results.user(issue.assignee).name -%>
         <% end %>
         </span>
       <% end %>
 
-      <% Internal.issues.listTransitions(issue).each do |transition| %>
+      <% unless issue.resolution %>
+        <%= image_tag 'sep12.png' -%>
+        &nbsp;
+        <span class="spacer-right">
+          <% if !@issue_results.actionPlan(issue) %>
+            <a href="#" onclick="return issueForm('plan', this)" class="link-action"><%= message('issue.do_plan') -%></a>
+          <% else %>
+            <a href="#" onclick="return issueForm('plan', this)" class="link-action"><%= message('issue.planned_for') -%></a> <%= h(@issue_results.actionPlan(issue).name()) -%>
+          <% end %>
+        </span>
+      <% end %>
+
+      <%
+         if transitions.size > 0 && transitions.first
+         transition = transitions.first
+      %>
+        <%= image_tag 'sep12.png' -%>
+        &nbsp;
         <a href="#" onclick="return doIssueTransition(this, '<%= transition.key -%>')" class="link-action spacer-right"><%= message("issue.transition.#{transition.key}") -%></a>
       <% end %>
 
-      <% unless issue.resolution %>
-        <a href="#" onclick="return issueForm('severity', this)" class="link-action spacer-right"><%= message("issue.set_severity") -%></a>
-        <a href="#" onclick="return issueForm('plan', this)" class="link-action spacer-right"><%= message("issue.do_plan") -%></a>
+      <%
+         if transitions.size > 1 || !issue.resolution
+           transitions.remove(0)
+      %>
+        <div class="dropdown">
+          <a href="#" class="link-action link-more" onclick="showDropdownMenuOnElement($j(this).next('.dropdown-menu')); return false;"><%= message('more_actions') -%></a>
+          <ul style="display: none" class="dropdown-menu">
+            <% unless issue.resolution %>
+              <li><a href="#" onclick="return issueForm('severity', this)" class="link-action spacer-right"><%= message("issue.set_severity") -%></a></li>
+            <% end %>
+            <% transitions.each do |transition| %>
+              <li><a href="#" onclick="return doIssueTransition(this, '<%= transition.key -%>')" class="link-action spacer-right"><%= message("issue.transition.#{transition.key}") -%></a></li>
+            <% end %>
+          </ul>
+        </div>
       <% end %>
     </div>
     <div class="code-issue-form hidden"></div>
index cb408cd7c4db1a44f74f5b96b9cb8bea86e8256d..c95988905837ae8d21441a91b7d3cd47ccfba458 100644 (file)
@@ -425,9 +425,8 @@ function expandAccordionItem(elt) {
 var currentlyDisplayedDropdownMenu;
 
 var hideCurrentDropdownMenu = function () {
-  menu = $j('#' + currentlyDisplayedDropdownMenu);
-  if (menu) {
-    menu.hide();
+  if (currentlyDisplayedDropdownMenu) {
+    currentlyDisplayedDropdownMenu.hide();
   }
   $j(document).unbind('mouseup', hideCurrentDropdownMenu);
 }
@@ -447,14 +446,21 @@ var clickOnDropdownMenuLink = function (event) {
 }
 
 function showDropdownMenu(menuId) {
-  if (menuId == currentlyDisplayedDropdownMenu) {
+  showDropdownMenuOnElement($j('#' + menuId));
+}
+
+function showDropdownMenuOnElement(elt) {
+  var dropdownElt = $j(elt);
+  var dropdownChildren = dropdownElt.children('li');
+
+  if (dropdownElt == currentlyDisplayedDropdownMenu) {
     currentlyDisplayedDropdownMenu = "";
   } else {
-    currentlyDisplayedDropdownMenu = menuId;
+    currentlyDisplayedDropdownMenu = dropdownElt;
     $j(document).mouseup(hideCurrentDropdownMenu);
-    $j('#' + currentlyDisplayedDropdownMenu + ' li').unbind('click');
-    $j('#' + currentlyDisplayedDropdownMenu + ' li').click(clickOnDropdownMenuLink);
-    $j('#' + currentlyDisplayedDropdownMenu).show();
+    dropdownChildren.unbind('click');
+    dropdownChildren.click(clickOnDropdownMenuLink);
+    dropdownElt.show();
   }
 }