From 2df65c46509bf106b3a41fef9bf9ca909bae5e24 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 29 Apr 2013 18:12:54 +0200 Subject: [PATCH] SONAR-3755 Fix breadcrumb on issue detail and add source code --- .../resources/org/sonar/l10n/core.properties | 2 ++ .../WEB-INF/app/controllers/issue_controller.rb | 16 ++++++++++++---- .../WEB-INF/app/views/issue/_issue.html.erb | 16 ++++++++++++++-- .../WEB-INF/app/views/issue/_view.html.erb | 2 +- .../app/views/layouts/_breadcrumb.html.erb | 16 +++++++++++++--- 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index a6936626049..17863a5ea12 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -64,6 +64,8 @@ hide=Hide identifier_abbreviated=Id inactive=Inactive info=Info +issue=Issue +issues=Issues inheritance=Inheritance key=Key language=Language diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb index 58a1959683e..fb5f77b2291 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb @@ -22,14 +22,22 @@ class IssueController < ApplicationController SECTION=Navigation::SECTION_RESOURCE + helper SourceHelper, UsersHelper + # Used for the permalink, e.g. http://localhost:9000/issue/view/1 def view issue_result = find_issues({'issueKeys' => params[:id]}) if issue_result.issues.length == 1 - @issue = issue_result.issues[0] - @rule = issue_result.rule(@issue) - @resource = Project.by_key(@issue.component_key) - render 'issue/_view', :locals => {:issue => @issue, :rule => @rule, :resource => @resource} + issue = issue_result.issues[0] + rule = issue_result.rule(issue) + + resource = Project.by_key(issue.component_key) + project = resource.root_project + + # Only used for breadcrumb + @resource = project + + render 'issue/_view', :locals => {:issue => issue, :rule => rule, :resource => resource, :project => project} else render :text => "Cannot access this issue : not found." end 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 fb18dabbf95..907b43d69f5 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 @@ -75,8 +75,8 @@ <%= qualifier_icon(resource) -%> - <% if resource.root_project.id != resource.id %> - <%= resource.root_project.long_name -%> <%= image_tag 'sep12.png' -%> + <% if project.id != resource.id %> + <%= project.long_name -%> <%= image_tag 'sep12.png' -%> <% end %> <% if resource.last_snapshot %> <%= link_to_resource(resource, resource.long_name, {:tab => :violations, :rule => issue.resolution == "FALSE-POSITIVE" ? "false_positive_issues" : ""}) %> @@ -87,4 +87,16 @@ + <% if issue.line && has_role?(:codeviewer, project) %> +
+ <%= snapshot_html_source(resource.last_snapshot, {:line_range => (issue.line-5)..(issue.line+5), :highlighted_lines => [issue.line]}) -%> +
+ <% end %> + +
+
+ <%= h(issue.description) -%> +
+
+ \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_view.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_view.html.erb index d1448cf5aa3..1476be4d3f9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_view.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_view.html.erb @@ -3,5 +3,5 @@ # hack in case 'error_message' is nil (this should disappear when refactoring the '_view' and '_issue' partials) error_message = error_message %> - <%= render :partial => 'issue/issue', :locals => {:issue => @issue, :rule => @rule, :resource => @resource, :workflow => @issue, :error_message => error_message} -%> + <%= render :partial => 'issue/issue', :locals => {:issue => issue, :rule => rule, :resource => resource, :workflow => issue, :project => project, :error_message => error_message} -%> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb index 6801f1df449..27702b255cb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb @@ -1,12 +1,13 @@ <% displayed_resource = @resource || @project + display_only_root = @review || @issue %> <% if @breadcrumbs %>