aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-05-24 09:42:18 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-05-24 09:42:18 +0200
commitd969077cf266597edd11d0b36714a03081873816 (patch)
tree3f4d659554f313ba3415aec68d759eb4075e3596 /sonar-server
parent28c139001df446e5a30e850c8c7efe01d2103436 (diff)
downloadsonarqube-d969077cf266597edd11d0b36714a03081873816.tar.gz
sonarqube-d969077cf266597edd11d0b36714a03081873816.zip
SONAR-4303 Refactor the issue detail in the issues code viewer
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/IssueService.java25
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb83
-rw-r--r--sonar-server/src/main/webapp/javascripts/application.js22
3 files changed, 70 insertions, 60 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java b/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
index 14ea05ed66a..042396d81f1 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
@@ -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) {
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb
index ea1f85f8ad7..a5fbf7c85f2 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb
@@ -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>
@@ -30,23 +18,21 @@
<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? %>
@@ -76,24 +62,61 @@
<% 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>
diff --git a/sonar-server/src/main/webapp/javascripts/application.js b/sonar-server/src/main/webapp/javascripts/application.js
index cb408cd7c4d..c9598890583 100644
--- a/sonar-server/src/main/webapp/javascripts/application.js
+++ b/sonar-server/src/main/webapp/javascripts/application.js
@@ -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();
}
}