aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-11-02 06:57:26 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-11-02 06:57:26 +0000
commit38958c1a36a57491d7298f917c3fb32899032947 (patch)
tree81230d8e04a1ed75bfd5a375bf631456be9fabed
parent674a23ae80dd162f79bc7777720c841b3bb34a55 (diff)
downloadsonarqube-38958c1a36a57491d7298f917c3fb32899032947.tar.gz
sonarqube-38958c1a36a57491d7298f917c3fb32899032947.zip
improve UI of update center + do not delete the last single dashboard
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb12
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb21
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb10
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb4
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) {
<table class="spaced width100">
<% if plugin.getLicense() %>
<tr>
- <td class="thin nowrap">License: </td><td><%= h(plugin.getLicense()) %></td>
+ <td class="thin nowrap"><b>License:</b> </td><td><%= h(plugin.getLicense()) %></td>
</tr>
<% end %>
<% if plugin.getOrganization() %>
<tr>
- <td class="thin nowrap">Author: </td><td><%= link_to_if plugin.getOrganizationUrl(), plugin.getOrganization(), plugin.getOrganizationUrl(), :class=>'external' %></td>
+ <td class="thin nowrap"><b>Author:</b> </td><td><%= link_to_if plugin.getOrganizationUrl(), plugin.getOrganization(), plugin.getOrganizationUrl(), :class=>'external' %></td>
</tr>
<% end %>
<% if plugin.getHomepageUrl() || plugin.getIssueTrackerUrl() %>
<tr>
- <td class="thin nowrap">Links: </td>
+ <td class="thin nowrap"><b>Links:</b> </td>
<td>
<%= 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) {
%>
<tr>
<% date=release_date(update.getRelease().getDate()) %>
- <td class="thin nowrap">Version: </td>
+ <td class="thin nowrap"><b>Version:</b> </td>
<td><%= update.getRelease().getVersion() -%> <%= "(#{date})" if date -%></td>
</tr>
<tr>
@@ -90,7 +90,7 @@ function installPlugin(key) {
<% elsif update.requiresSonarUpgrade
%>
<tr>
- <td class="thin nowrap">Last version: </td>
+ <td class="thin nowrap"><b>Last version:</b> </td>
<td><%= update.getRelease().getVersion() -%> (<%= image_tag 'warning.png' -%> Not compatible, requires Sonar upgrade)</td>
</tr>
<%
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 @@
<div id="detail-<%= plugin.plugin_key -%>" style="display:none">
<table class="spaced width100">
- <tr><td class="thin nowrap">License: </td><td><%= plugin.license -%></td></tr>
+ <tr><td class="thin nowrap"><b>License:</b> </td><td><%= plugin.license -%></td></tr>
<% if plugin.organization %>
- <tr><td class="thin nowrap">Author: </td>
+ <tr><td class="thin nowrap"><b>Author:</b> </td>
<td><%= link_to_if plugin.organization_url, plugin.organization, plugin.organization_url, :class=>'external' -%></td>
</tr>
<% end %>