From cd46e17bea493e095c4d11609351407387814825 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 30 May 2013 15:18:16 +0200 Subject: [PATCH] Permalinks on issue and rule details for Eclipse plugin --- .../WEB-INF/app/controllers/issue_controller.rb | 15 +++++++++++---- .../WEB-INF/app/controllers/rules_controller.rb | 15 ++++++++++++--- .../webapp/WEB-INF/app/views/issue/_view.html.erb | 2 +- .../webapp/WEB-INF/app/views/issue/view.html.erb | 2 +- .../{_show.html.erb => _show_modal.html.erb} | 0 5 files changed, 25 insertions(+), 9 deletions(-) rename sonar-server/src/main/webapp/WEB-INF/app/views/rules/{_show.html.erb => _show_modal.html.erb} (100%) 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 9ce1deeb8ac..4a0854f76aa 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 @@ -27,18 +27,25 @@ class IssueController < ApplicationController init_issue if request.xhr? - render :partial => 'issue/view', :locals => {:issue => @issue, :issue_results => @issue_results, :snapshot => @snapshot} + render :partial => 'issue/view', :locals => {:issue => @issue, :issue_results => @issue_results, :snapshot => @snapshot, :show_source => true} else render :action => 'view' end end - # Used in Eclipse Plugin + # GET /issue/show/ + # This URL is used by the Eclipse Plugin + # + # ==== Optional parameters + # 'layout' is false to remove sidebar and headers. Default value is true. + # 'source' is false to hide source code. Default value is true. + # + # ==== Example + # GET /issue/show/151f6853-58a1-4950-95e3-9866f8be3e35?layout=false&source=false + # def show require_parameters :id init_issue - - params[:layout] = 'false' render :action => 'view' end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb index cd7cd9d521f..8959be52f6d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_controller.rb @@ -20,8 +20,18 @@ class RulesController < ApplicationController SECTION=Navigation::SECTION_CONFIGURATION - + + # GET /rules/show/ + # This URL is used by the Eclipse plugin + # + # ==== Optional parameters + # 'layout' is false to remove sidebar and headers + # + # Example: GET /rules/show/squid:AvoidCycles + # def show + require_parameters :id + @key=params[:id] if @key.to_i==0 parts=@key.split(':') @@ -32,8 +42,7 @@ class RulesController < ApplicationController @page_title=@rule.name if @rule if params[:modal] == 'true' - render :partial => 'show' + render :partial => 'show_modal' end end - end 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 909b99be16a..27a6ec1f630 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 @@ -10,7 +10,7 @@ <%= render :partial => 'issue/issue', :locals => {:issue => issue_results.issues.get(0)} -%> - <% if snapshot && issue.line%> + <% if snapshot && issue.line && show_source %>
<%= snapshot_html_source(snapshot, {:line_range => (issue.line-5)..(issue.line+5), :highlighted_lines => [issue.line]}) -%>
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 f1b5c7f9bdf..12044218f4a 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 @@ -1,3 +1,3 @@
- <%= render :partial => 'issue/view', :locals => {:issue => @issue, :issue_results => @issue_results, :snapshot => @snapshot} -%> + <%= render :partial => 'issue/view', :locals => {:issue => @issue, :issue_results => @issue_results, :snapshot => @snapshot, :show_source => params[:source]!='false'} -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show_modal.html.erb similarity index 100% rename from sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show.html.erb rename to sonar-server/src/main/webapp/WEB-INF/app/views/rules/_show_modal.html.erb -- 2.39.5