diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-03 18:13:01 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-03 18:13:46 +0200 |
commit | 5c5f3c6ead9a6ed2c1d51df31f653674196f1ffe (patch) | |
tree | 43697abedd166fe9a03727d52312bc9a44335852 /sonar-server/src/main/webapp | |
parent | 1ad2570e7a3712f002f445822967e8cc58812301 (diff) | |
download | sonarqube-5c5f3c6ead9a6ed2c1d51df31f653674196f1ffe.tar.gz sonarqube-5c5f3c6ead9a6ed2c1d51df31f653674196f1ffe.zip |
Fix loading of project DSM in drilldown page
Diffstat (limited to 'sonar-server/src/main/webapp')
10 files changed, 126 insertions, 18 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index c67ee3048ad..5f595b8daac 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -41,6 +41,20 @@ class ResourceController < ApplicationController redirect_to :controller => 'component', :action => 'index', :anchor => anchor end + # deprecated stuff for drilldown + def view + require_parameters 'id' + @resource = Project.by_key(params[:id]) + access_denied unless has_role?(:user, @resource) + @snapshot = @resource.last_snapshot + load_extensions() if @snapshot + if @extension + render :partial => 'view' + else + not_found('Extension not found') + end + end + # # Call by new component viewer to display plugin extension # diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_footer.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_footer.html.erb index 1f871e66399..17986d4857f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_footer.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_footer.html.erb @@ -1,7 +1,14 @@ <div id="resource_container"> </div> -<% if @display_viewers && @drilldown.highlighted_resource %> -<script> - d(<%= @drilldown.highlighted_resource.id -%>, true); -</script> -<% end %> +<% + if @display_viewers + resource = @drilldown.highlighted_resource || @drilldown.resource + if resource +%> + <script> + d(<%= resource.id -%>, <%= resource.source_code? -%>); + </script> +<% + end + end +%> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_header.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_header.html.erb index 0b3a70e75bf..7049f5f5469 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_header.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/_header.html.erb @@ -1,12 +1,13 @@ +<%= render :partial => 'gwt/base', :locals => {:resource => nil, :popup => false, :metric => (@metric ? @metric.key : nil)} -%> +<%= render :partial => 'gwt/resource_viewers' -%> + <script type="text/javascript"> /* display resource */ - function d(resourceId, display_title) { - if (display_title == undefined) { - display_title = true; - } - var url = '<%= ApplicationController.root_context -%>/resource/index/' + resourceId + '?metric=<%= @metric.id if @metric -%>' + - '&rule=<%= @rule ? @rule.id : @severity -%>&period=<%= @period -%>&project=<%= @resource.id -%>&display_title=' + display_title; - openAccordionItem(url, this); + function d(resourceId, is_file) { + var action = is_file ? 'index' : 'view'; + var url = '<%= ApplicationController.root_context -%>/resource/' + action + '/' + resourceId + '?metric=<%= @metric.id if @metric -%>' + + '&rule=<%= @rule ? @rule.id : @severity -%>&period=<%= @period -%>&project=<%= @resource.id -%>'; + openAccordionItem(url); return false; } @@ -19,4 +20,13 @@ window.location.reload(); } } + + function loadGWT(gwtId, resourceId, resourceKey, resourceName, resourceScope, resourceQualifier, resourceLanguage) { + config["resource"] = [ + {"id":resourceId, "key":resourceKey, "name":resourceName, "scope":resourceScope, "qualifier":resourceQualifier, + "lang":resourceLanguage} + ]; + config["resource_key"] = resourceId; + modules[gwtId](); + } </script> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb index 206cc9ee36e..8aef0011a5e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/issues.html.erb @@ -213,7 +213,7 @@ }; var url = '<%= ApplicationController.root_context -%>/issues/search?' + jQuery.param(params); - openAccordionItem(url, this, false); + openAccordionItem(url); return false; } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb index 8d42abe34ab..0bea2a00709 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb @@ -87,7 +87,7 @@ <a href="#" title="<%= h resource.name(true) -%>" data-key="<%= resource.key -%>" class="js-drilldown-link underlined-link"><%= h resource.name(false) %></a> <% else %> - <%= link_to(h(resource.name), {:only_path => true, :overwrite_params => {:rids => (selected ? rids-[resource.id] : rids+[resource.id])}}, :class => 'underlined-link') -%> + <%= link_to(h(resource.name), params.merge({:only_path => true, :rids => (selected ? rids-[resource.id] : rids+[resource.id])}), :class => 'underlined-link') -%> <% end %> </td> <td class="right"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_resource_viewers.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_resource_viewers.html.erb new file mode 100644 index 00000000000..f382653f6b3 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/gwt/_resource_viewers.html.erb @@ -0,0 +1,9 @@ +<% + controller.java_facade.getResourceTabs().each do |tab| + if tab.isGwt() +%> + <script src="<%= ApplicationController.root_context -%>/deploy/gwt/<%= tab.getId() -%>/<%= tab.getId() -%>.nocache.js"></script> + <% + end + end + %> 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 817ee0c470e..e3dcb357702 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 @@ -79,9 +79,7 @@ <li> <%= qualifier_icon(resource) -%> - <%= link_to(h(resource.name), - {:overwrite_params => {:id => resource.key}.merge(resource_link)} - ) -%> + <%= link_to(h(resource.name), params.merge({:id => resource.key}.merge(resource_link))) -%> </li> <% end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_tabs.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_tabs.html.erb new file mode 100644 index 00000000000..6d896b6dfbb --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_tabs.html.erb @@ -0,0 +1,54 @@ +<% + if @extensions.empty? +%> + <span class="note"><%= message('code_viewer.no_info_displayed_due_to_security') -%></span> +<% + else + display_title=(params[:display_title]=='true') +%> + + <% if display_title %> + <div class="source_title"> + <% if @resource.project %> + <div class="subtitle"> + <%= h @resource.ancestor_projects.reverse.map{|p| p.name(true)}.join(' / ') -%> + </div> + <% end %> + <% if logged_in? %><%= link_to_favourite(@resource) -%><% end %> + <span class="h1"><%= qualifier_icon(@resource) -%> <%= h @resource.name(true) -%></span> + </div> + <% end %> + + <div class="source_tabs"> + <ul class="tablinks"> + <% first=true %> + <% if @snapshot.has_source && has_role?(:codeviewer, @snapshot) %> + <li class="<%= 'first' if first -%>"> + <a href="<%= ApplicationController.root_context -%>/api/sources?resource=<%= @resource.key -%>&format=txt"><%= message('raw') -%></a> + </li> + <% first=false + end %> + <% unless @popup_mode %> + <li class="<%= 'first' if first -%>"> + <a href="<%= url_for :controller => 'resource', :action => 'index', :id => @resource.key, :period => params[:period], :metric => params[:metric], + :rule => params[:rule] ? params[:rule] : params[:rule_sev], :display_title => 'true' -%>" + onclick="window.open(this.href,'resource','height=800,width=900,scrollbars=1,resizable=1');return false;" + id="new-window-<%= @resource.key.parameterize -%>"><%= image_tag 'new-window-16.gif', :alt => message('new_window') -%></a> + </li> + <% end %> + </ul> + <ul class="tabs"> + <% @extensions.each do |extension| %> + <li> + <a href="#" onclick="return loadResourceViewer('<%= @resource.id -%>','<%= extension.getId() -%>',<%= display_title -%>,'<%= params[:period] -%>', this)" + class="<%= 'selected' if @extension && @extension.getId()==extension.getId() -%>"><%= message(extension.getId() + '.page', :default => extension.getTitle()) %></a> + </li> + <% end %> + <li> + <img src="<%= ApplicationController.root_context -%>/images/loading.gif" id="resource_loading" class="accordion-loading" style="display:none"/> + </li> + </ul> + </div> + + +<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_view.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_view.html.erb new file mode 100644 index 00000000000..1e6e4762245 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_view.html.erb @@ -0,0 +1,16 @@ +<div> + <div class="accordion-item-header"> + <%= render :partial => 'tabs' -%> + </div> + <div class="accordion-item-body"> + <% if @extension.isGwt() %> + <div id="gwtpage"> </div> + <script> + loadGWT('<%= @extension.getId() -%>', <%= @resource.id -%>,'<%= escape_javascript(@resource.key) -%>', '<%= escape_javascript(@resource.name) -%>', + '<%= @resource.scope -%>', '<%= @resource.qualifier -%>', '<%= escape_javascript(@resource.language) -%>'); + </script> + <% elsif @extension.getTarget() # ruby on rails page %> + <%= render :inline => @extension.getTarget().getTemplate() -%> + <% end %> + </div> +</div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_coverage.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_coverage.html.erb index d0ffca59fb2..8ba427b716e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_coverage.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/shared/_source_coverage.html.erb @@ -2,7 +2,7 @@ <td class="ind <%= statuses[:hits] -%>" title="<%= message('coverage_viewer.line_covered_by_x_tests', {:params => line.covered_lines.to_s}) if line.covered_lines > 0 -%>"> <% if line.covered_lines > 0 %> <a href="<%= ApplicationController.root_context -%>/test/testable/<%= h resource_key -%>?line=<%= index+1 -%>" - class="sources-testable-link-<%= index+1 -%>" onclick="openAccordionItem(this.href, this); return false;"><%= line.covered_lines -%></a> + class="sources-testable-link-<%= index+1 -%>" onclick="openAccordionItem(this.href); return false;"><%= line.covered_lines -%></a> <% end %> </td> <td class="ind <%= statuses[:conditions] -%>"> |