From dee90c9cf4cece22fc8744d2d275d047eeb0bcda Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Fri, 27 Sep 2013 16:01:54 +0200 Subject: SONAR-4712 Ensure most pages work without snapshot Add message for pages available to empty (provisioned) projects Modify layouts that don't depend explicitly on last snapshot Hide 'Tools' section from the navigation sidebar on empty projects Ensure 'Tools' section is available when last snapshot exists --- .../main/resources/org/sonar/l10n/core.properties | 1 + .../app/controllers/action_plans_controller.rb | 3 +- .../app/controllers/application_controller.rb | 1 - .../app/controllers/dashboard_controller.rb | 10 ++- .../WEB-INF/app/controllers/project_controller.rb | 2 + .../app/controllers/project_roles_controller.rb | 1 + .../WEB-INF/app/views/layouts/_layout.html.erb | 16 ++-- .../WEB-INF/app/views/project/deletion.html.erb | 8 +- .../WEB-INF/app/views/project/history.html.erb | 92 +++++++++++----------- .../WEB-INF/app/views/settings/_settings.html.erb | 3 + 10 files changed, 77 insertions(+), 60 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 e1f4a99751d..5dc68304c8b 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 @@ -1716,6 +1716,7 @@ bulk_deletion.delete_all_ghosts=Delete all ghosts #------------------------------------------------------------------------------ provisioning.missing.key=Key is missing provisioning.missing.name=Name is missing +provisioning.no_analysis=No analysis has been performed since creation. The only available section is configuration. #------------------------------------------------------------------------------ diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb index 579e250b930..bb4392c3db0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/action_plans_controller.rb @@ -77,8 +77,9 @@ class ActionPlansController < ApplicationController def load_resource @resource=Project.by_key(params[:id]) - return redirect_to home_path unless @resource + return redirect_to(home_path) unless @resource access_denied unless has_role?(:admin, @resource) + @snapshot=@resource.last_snapshot end def load_action_plans diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb index 0c13f71d1e2..f24b4314c37 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb @@ -234,7 +234,6 @@ class ApplicationController < ActionController::Base @resource=@resource.permanent_resource @snapshot=@resource.last_snapshot - not_found("Snapshot not found") unless @snapshot access_denied unless has_role?(role, @resource) end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb index 6ec1fe7f223..92819c4ce0b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb @@ -187,7 +187,7 @@ class DashboardController < ApplicationController @resource=@resource.permanent_resource @snapshot=@resource.last_snapshot - return project_not_found unless @snapshot + return project_not_analyzed unless @snapshot access_denied unless has_role?(:user, @resource) @@ -200,6 +200,10 @@ class DashboardController < ApplicationController redirect_to :action => :index end + def project_not_analyzed + redirect_to :controller => :project, :action => :settings, :id => @resource + end + def load_authorized_widget_definitions @authorized_widget_definitions=java_facade.getWidgets().select do |widget| roles = widget.getUserRoles() @@ -209,13 +213,13 @@ class DashboardController < ApplicationController def load_widget_definitions(filter_on_category) @widget_definitions=java_facade.getWidgets().sort {|w1,w2| widgetL10nName(w1) <=> widgetL10nName(w2)} - + @widget_categories=@widget_definitions.map(&:getWidgetCategories).flatten.uniq.sort unless filter_on_category.blank? @widget_definitions=@widget_definitions.select { |definition| definition.getWidgetCategories().to_a.include?(filter_on_category) } end end - + def widgetL10nName(widget) Api::Utils.message('widget.' + widget.id + '.name') end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index cc4d9901857..5fc629a33e4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -79,6 +79,7 @@ class ProjectController < ApplicationController def profile require_parameters :id @project=get_current_project_for_profile(params[:id]) + @snapshot=@project.last_snapshot end # POST /project/set_profile?id=&language=[&profile_id=] @@ -109,6 +110,7 @@ class ProjectController < ApplicationController def key @project = get_current_project(params[:id]) + @snapshot = @project.last_snapshot end def update_key diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb index 3ada58fecef..d0787d925e3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_roles_controller.rb @@ -26,6 +26,7 @@ class ProjectRolesController < ApplicationController def index @project=Project.by_key(params[:id]) access_denied unless is_admin?(@project) + @snapshot=@project.last_snapshot end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index 4846e47b609..2ef018270a4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -77,6 +77,8 @@ "><%= h active_dashboard.dashboard.name(true) -%> <% end %> + + <% if @snapshot %>
  • @@ -85,24 +87,24 @@
  • "><%= message('issues_drilldown.page') -%>
  • - <% project_metrics = @project.last_snapshot.metric_keys.to_java(:string) if @project.last_snapshot - controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language, project_metrics).each do |page| - page_url = (page.isController() ? "#{page.getId()}?id=#{@project.id}" : "/plugins/resource/#{@project.id}?page=#{page.getId()}") - %> + <% project_metrics = @project.last_snapshot.metric_keys.to_java(:string) if @project.last_snapshot + controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language, project_metrics).each do |page| + page_url = (page.isController() ? "#{page.getId()}?id=#{@project.id}" : "/plugins/resource/#{@project.id}?page=#{page.getId()}") + %>
  • <%= h message(page.getId() + '.page', :default => page.getTitle()) -%>
  • - <% end %> + <% end %>
  • <%= message('clouds.page') -%>
  • - <% if controller.java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'comparable') %> + <% if controller.java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'comparable') %>
  • <%= message('comparison.page') -%>
  • + <% end %> <% end %> - <% elsif selected_section==Navigation::SECTION_CONFIGURATION %> <% if is_admin? %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb index c0023528bf9..8644fb5769e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb @@ -1,5 +1,5 @@ -<% - if @snapshot.root? +<% + if !@snapshot || @snapshot.root? resource_name = message('qualifier.' + @project.qualifier) delete_resource_message = message('project_deletion.delete_resource', :params => resource_name) %> @@ -22,9 +22,9 @@ <%= message('project_deletion.operation_cannot_be_undone') -%>
    - <%= submit_tag delete_resource_message, :id => 'delete_resource', :class => 'action red-button', + <%= submit_tag delete_resource_message, :id => 'delete_resource', :class => 'action red-button', :confirm => message('project_deletion.delete_resource_confirmation', :params => resource_name) %> -<% end %> \ No newline at end of file +<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb index 09317d0a1e1..005c2ba322d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb @@ -1,4 +1,10 @@ -<% if @snapshot.root? %> +

    <%= message('project_history.page') -%>

    + +<% if !@snapshot %> + +

    <%= message('provisioning.no_analysis') -%>

    + +<% elsif @snapshot.root? %> -

    <%= message('project_history.page') -%>

    -

    <%= message('project_history.description') -%>

    @@ -37,7 +41,7 @@ - <% + <% current_year = nil current_month = nil @snapshots.each_with_index do |snapshot, index| @@ -48,15 +52,15 @@ other_events = snapshot.events.select{|e| e.category!=EventCategory::KEY_VERSION && e.category!=EventCategory::KEY_ALERT && e.category!=EventCategory::KEY_PROFILE} %> - + <%= time.year unless time.year == current_year -%> - + <%= l(time, :format => '%B').capitalize unless time.month == current_month -%> <%= l(time, :format => '%d') -%> - + <%= l(time, :format => '%H:%M') -%> - + @@ -65,9 +69,9 @@ <% else %> @@ -79,7 +83,7 @@
    <%= message('project_history.rename_version') -%> <% if version_event && !snapshot.islast? %> - <%= link_to( message('project_history.remove_version'), - { :action => 'delete_version', :sid => snapshot.id}, - :confirm => message('project_history.do_you_want_to_remove_version', :params => version_event.name) ) -%> + <%= link_to( message('project_history.remove_version'), + { :action => 'delete_version', :sid => snapshot.id}, + :confirm => message('project_history.do_you_want_to_remove_version', :params => version_event.name) ) -%> <% end %>
    - + - <% + <% other_events.each_with_index do |event, index2| - event_index = index.to_s + '-' + index2.to_s + event_index = index.to_s + '-' + index2.to_s %> - - - + + - - + <%= link_to( message('project_history.remove_version'), + { :action => 'delete_event', :id => event.id}, + :confirm => message('project_history.do_you_want_to_remove_version', :params => event.name) ) -%> + + + - - <% end %> - - + <% end %> + + - - - + + + - + +
    <%= event.name -%> +
    <%= event.name -%> <%= message('project_history.rename_event') -%> - <%= link_to( message('project_history.remove_version'), - { :action => 'delete_event', :id => event.id}, - :confirm => message('project_history.do_you_want_to_remove_version', :params => event.name) ) -%> -
    - +
    + <%= message('project_history.create_event') -%> -
    @@ -149,10 +153,10 @@ if snapshot.islast? cell_content = "" + message('project_history.last_snapshot') + "" else - cell_content = button_to( message('project_history.delete_snapshot'), - { :action => "delete_snapshot_history", :id => @project.id, :snapshot_id => snapshot.id }, - :class => 'action red-button', - :confirm => message('project_history.are_you_sure_delete_snapshot_x', :params => l(time, :format => :long)) ) + cell_content = button_to( message('project_history.delete_snapshot'), + { :action => "delete_snapshot_history", :id => @project.id, :snapshot_id => snapshot.id }, + :class => 'action red-button', + :confirm => message('project_history.are_you_sure_delete_snapshot_x', :params => l(time, :format => :long)) ) end %> <%= cell_content -%> @@ -160,10 +164,10 @@ <% current_year = time.year - current_month = time.month - end + current_month = time.month + end %> -<% end %> \ No newline at end of file +<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb index 323ea8e0e05..5809c89db54 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_settings.html.erb @@ -1,5 +1,8 @@

    <%= message(@resource ? 'project_settings.page' : 'settings.page') -%>

    + <% if @resource and !@snapshot %> +

    <%= message('provisioning.no_analysis') -%>

    + <% end %> -- cgit v1.2.3