From: Fabrice Bellingard
Date: Wed, 4 Jul 2012 13:57:22 +0000 (+0200)
Subject: SONAR-1608 Improve error messages
X-Git-Tag: 3.2~256
X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d0a93912bd4095543e46ed698750934e63e6b67b;p=sonarqube.git
SONAR-1608 Improve error messages
---
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
index e06725d0d83..fdec6a9f57f 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -981,6 +981,8 @@ update_key.cant_update_because_duplicate_keys=The replacement of "{0}" by "{1}"
update_key.keys_will_be_updated_as_follows=The resources will be updated as follows (updated keys in bold):
update_key.duplicate_key=Duplicate key
update_key.bulk_update_confirmation_page=Do you really want to perform the bulk update on project keys?
+update_key.bulk_update_impossible=Bulk update can not be performed
+update_key.no_key_to_update=No key contains the string to replace ("{0}").
#------------------------------------------------------------------------------
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 ba9e1eb1059..3e4643915f7 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
@@ -106,10 +106,16 @@ class ProjectController < ApplicationController
redirect_to :action => 'key', :id => @project.id
else
@key_check_results = java_facade.checkModuleKeysBeforeRenaming(@project.id, @old_prefix, @new_prefix)
- @can_update = true
+ @can_update = false
+ @duplicate_key_found = false
@key_check_results.each do |key, value|
- @can_update = false if value=="#duplicate_key#"
+ if value=="#duplicate_key#"
+ @duplicate_key_found = true
+ else
+ @can_update = true
+ end
end
+ @can_update = false if @duplicate_key_found
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/key.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/key.html.erb
index 1dd74cc78c3..fdc99f36876 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/key.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/key.html.erb
@@ -25,7 +25,7 @@
<%= message('update_key.current_key_for_project_x_is_x', :params => [@project.name, @project.key]) -%>
- <% form_tag( {:action => 'prepare_key_bulk_update', :id => @project.id }) do -%>
+ <% form_tag( {:action => 'prepare_key_bulk_update', :id => @project.id }, :onsubmit => "update_launched();$('loading_bulk_update').show();") do -%>
<%= message('update_key.replace') -%>: |
@@ -40,8 +40,7 @@
|
- <%= submit_tag message('update_key.rename'), :id => 'bulk_update_button', :class => 'action',
- :onclick => "update_launched();$('loading_bulk_update').show();" %>
+ <%= submit_tag message('update_key.rename'), :id => 'bulk_update_button', :class => 'action' -%>
|
|
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/prepare_key_bulk_update.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/prepare_key_bulk_update.html.erb
index bbdb6d43631..cd7d6d45e84 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/prepare_key_bulk_update.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/prepare_key_bulk_update.html.erb
@@ -12,10 +12,18 @@
}
- <%= message('update_key.bulk_update_confirmation_page') -%>
+ <%= @can_update ? message('update_key.bulk_update_confirmation_page') : message('update_key.bulk_update_impossible') -%>
- <%= @can_update ? message('update_key.keys_will_be_updated_as_follows') : message('update_key.cant_update_because_duplicate_keys', :params => [@old_prefix, @new_prefix]) -%>
+ <% if @can_update %>
+ <%= message('update_key.keys_will_be_updated_as_follows') -%>
+ <% else %>
+ <% if @duplicate_key_found %>
+ <%= message('update_key.cant_update_because_duplicate_keys', :params => [@old_prefix, @new_prefix]) -%>
+ <% else %>
+ <%= message('update_key.no_key_to_update', :params => @old_prefix) -%>
+ <% end %>
+ <% end %>
<% if @can_update %>
- <% form_tag( {:action => 'perform_key_bulk_update', :id => @project.id }) do -%>
+ <% form_tag( {:action => 'perform_key_bulk_update', :id => @project.id }, :onsubmit => "update_launched();$('loading_bulk_update').show();") do -%>
- <%= submit_tag message('update_key.rename'), :id => 'bulk_update_button', :class => 'action',
- :onclick => "update_launched();$('loading_bulk_update').show();" %>
+ <%= submit_tag message('update_key.rename'), :id => 'bulk_update_button', :class => 'action' -%>
<%= message('cancel') -%>
<% end %>