From 38958c1a36a57491d7298f917c3fb32899032947 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Tue, 2 Nov 2010 06:57:26 +0000 Subject: [PATCH] improve UI of update center + do not delete the last single dashboard --- .../admin_dashboards_controller.rb | 12 +++++++---- .../app/controllers/dashboards_controller.rb | 21 +++++++++++++------ .../app/views/updatecenter/available.html.erb | 10 ++++----- .../app/views/updatecenter/index.html.erb | 4 ++-- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb index bd97167f741..41f3f2c2e69 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb @@ -85,10 +85,14 @@ class AdminDashboardsController < ApplicationController end def remove - active=@actives.to_a.find{|af| af.id==params[:id].to_i} - if active - active.destroy - flash[:notice]='Dashboard removed from default dashboards.' + if @actives.size<=1 + flash[:error]='At least one dashboard must be defined.' + else + active=@actives.to_a.find{|af| af.id==params[:id].to_i} + if active + active.destroy + flash[:notice]='Dashboard removed from default dashboards.' + end end redirect_to :action => 'index' end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb index ae5ad686711..69b6296a12b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb @@ -58,9 +58,12 @@ class DashboardsController < ApplicationController end def edit - # TODO check ownership @dashboard=Dashboard.find(params[:id]) - render :partial => "edit" + if @dashboard.owner?(current_user) + render :partial => "edit" + else + redirect_to :controller => 'dashboards', :action => 'index', :resource => params[:resource] + end end def update @@ -83,7 +86,11 @@ class DashboardsController < ApplicationController def delete dashboard=Dashboard.find(params[:id]) - if dashboard.owner?(current_user) + if current_user.active_dashboards.size<=1 + flash[:error]='At least one dashboard must be defined' + redirect_to :action => 'index', :resource => params[:resource] + + elsif dashboard.owner?(current_user) dashboard.destroy flash[:notice]='Dashboard deleted' redirect_to :action => 'index', :resource => params[:resource] @@ -142,9 +149,11 @@ class DashboardsController < ApplicationController end def unfollow - active_dashboard=ActiveDashboard.find(:first, :conditions => ['user_id=? AND dashboard_id=?', current_user.id, params[:id].to_i]) - if active_dashboard - active_dashboard.destroy + if current_user.active_dashboards.size<=1 + flash[:error]='At least one dashboard must be defined' + else + active_dashboard=ActiveDashboard.find(:first, :conditions => ['user_id=? AND dashboard_id=?', current_user.id, params[:id].to_i]) + active_dashboard.destroy if active_dashboard end redirect_to :action => :index, :resource => params[:resource] end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb index 297999c8940..5e2e82e9e2c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb @@ -52,17 +52,17 @@ function installPlugin(key) { <% if plugin.getLicense() %> - + <% end %> <% if plugin.getOrganization() %> - + <% end %> <% if plugin.getHomepageUrl() || plugin.getIssueTrackerUrl() %> - + <% date=release_date(update.getRelease().getDate()) %> - + @@ -90,7 +90,7 @@ function installPlugin(key) { <% elsif update.requiresSonarUpgrade %> - + <% diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb index 1ac4beeff5f..020891709de 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb @@ -36,9 +36,9 @@
License: <%= h(plugin.getLicense()) %>License: <%= h(plugin.getLicense()) %>
Author: <%= link_to_if plugin.getOrganizationUrl(), plugin.getOrganization(), plugin.getOrganizationUrl(), :class=>'external' %>Author: <%= link_to_if plugin.getOrganizationUrl(), plugin.getOrganization(), plugin.getOrganizationUrl(), :class=>'external' %>
Links: Links: <%= link_to 'Homepage', plugin.getHomepageUrl(), :class=>'external' if plugin.getHomepageUrl() -%> <%= link_to "Issue Tracker", plugin.getIssueTrackerUrl(), :class=>'external' if plugin.getIssueTrackerUrl() -%> @@ -74,7 +74,7 @@ function installPlugin(key) { %>
Version: Version: <%= update.getRelease().getVersion() -%> <%= "(#{date})" if date -%>
Last version: Last version: <%= update.getRelease().getVersion() -%> (<%= image_tag 'warning.png' -%> Not compatible, requires Sonar upgrade)
- + <% if plugin.organization %> - + <% end %> -- 2.39.5
License: <%= plugin.license -%>
License: <%= plugin.license -%>
Author:
Author: <%= link_to_if plugin.organization_url, plugin.organization, plugin.organization_url, :class=>'external' -%>