summaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-09-30 18:03:00 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-09-30 18:03:00 +0200
commit8a4202ca07b467cf99aa0065308aa98a898021f4 (patch)
tree31034d7d264c02dbcaa0f1098be271b10c46cbd7 /sonar-server
parent8e738b461b77b9f72e29ca1f028709ca0c2e7742 (diff)
downloadsonarqube-8a4202ca07b467cf99aa0065308aa98a898021f4.tar.gz
sonarqube-8a4202ca07b467cf99aa0065308aa98a898021f4.zip
SONAR-2602 complete messages + refactor the ruby helper link_to_action
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb28
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/confirm/_confirm.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb14
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb18
4 files changed, 36 insertions, 26 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
index 8720d718e20..465d2ada0b4 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
@@ -725,29 +725,29 @@ module ApplicationHelper
# ==== Options
# * <tt>:id</tt> - HTML ID of the button
# * <tt>:class</tt> - Additional CSS class, generally 'red-button' for deletions
- # * <tt>:button_key</tt> - Default is 'confirm'
- # * <tt>:title_key</tt> -
- # * <tt>:message_key</tt> -
- # * <tt>:message_params</tt> -
- # * <tt>:width</tt> - width in pixels
+ # * <tt>:confirm_button</tt> - L10n key of the confirmation button
+ # * <tt>:confirm_title</tt> - L10n key of the confirmation title
+ # * <tt>:confirm_msg</tt> - L10n key of the confirmation message
+ # * <tt>:confirm_msg_params</tt> - Array of parameters used for building the confirmation message
+ # * <tt>:confirm_width</tt> - width in pixels of the confirmation pop-up
#
def link_to_action(label, post_url, options={})
clazz = options[:class]
id = "id='#{options[:id]}'" if options[:id]
- title_key = options[:title_key]
- button_key = options[:button_key]
- message_key = options[:message_key]
- message_params = options[:message_params]
- width = options[:width]||500
+ title_key = options[:confirm_title]
+ button_key = options[:confirm_button]
+ message_key = options[:confirm_msg]
+ message_params = options[:confirm_msg_params]
+ width = options[:confirm_width]||500
url = "#{ApplicationController.root_context}/confirm?url=#{u post_url}"
- url += "&tk=#{title_key}" if title_key
+ url += "&tk=#{u title_key}" if title_key
if message_key
- url += "&mk=#{message_key}&"
- url += message_params.map{|p| "mp=#{u p}"}.join('&') if message_params
+ url += "&mk=#{u message_key}&"
+ url += message_params.map{|p| "mp[]=#{u p}"}.join('&') if message_params
end
if button_key
- url += "&bk=#{button_key}"
+ url += "&bk=#{u button_key}"
end
"<a href='#{url}' modal-width='#{width}' class='open-modal #{clazz}' #{id}>#{h label}</a>"
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/confirm/_confirm.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/confirm/_confirm.html.erb
index 63c5e59835a..5a13c773ed8 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/confirm/_confirm.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/confirm/_confirm.html.erb
@@ -1,7 +1,7 @@
<%
title_key = params[:tk] || 'confirm'
message_key = params[:mk] || 'are_you_sure'
- message_params = params[:mp] || []
+ message_params = params['mp'] || []
button_key = params[:bk] || title_key
%>
<form id="confirm-form" method="post" action="<%= params[:url] -%>">
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
index 50efc517ad0..8a308747afa 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb
@@ -65,9 +65,9 @@
<%= link_to_action message('set_as_default'), "profiles/set_as_default?id=#{profile.id}",
:id => "activate_#{profile.key.parameterize}",
:class => 'button',
- :title_key => 'set_as_default',
- :message_key => 'quality_profiles.are_you_sure_want_x_profile_as_default',
- :message_params => [profile.name] -%>
+ :confirm_title => 'set_as_default',
+ :confirm_msg => 'quality_profiles.are_you_sure_want_x_profile_as_default',
+ :confirm_msg_params => [profile.name] -%>
<% end %>
<% if profile.default_profile? %>
<%= image_tag 'tick.png', :id => "is_active_#{u profile.key}" %>
@@ -100,10 +100,10 @@
<%= link_to_action message('delete'), "profiles/delete/#{profile.id}",
:class => 'button red-button',
:id => "delete_#{profile.key.parameterize}",
- :button_key => 'delete',
- :title_key => 'quality_profiles.delete_confirm_title',
- :message_key => 'quality_profiles.are_you_sure_want_delete_profile_x',
- :message_params => [profile.name]
+ :confirm_button => 'delete',
+ :confirm_title => 'quality_profiles.delete_confirm_title',
+ :confirm_msg => 'quality_profiles.are_you_sure_want_delete_profile_x',
+ :confirm_msg_params => [profile.name]
-%>
<% end %>
</td>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb
index fc19e5201a8..3aa33d6a880 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/projects.html.erb
@@ -1,4 +1,5 @@
-<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%> / <%= h @profile.language -%>
+<h1 class="marginbottom10"><%= link_to message('quality_profiles.quality_profiles'), :controller => 'profiles', :action => 'index' -%>
+ / <%= h @profile.language -%>
/ <%= h @profile.name %></h1>
<%= render :partial => 'profiles/tabs', :locals => {:selected_tab => 'Projects'} %>
@@ -30,10 +31,15 @@
<% @profile.sorted_projects.each do |project| %>
<tr class="<%= cycle('even', 'odd') -%>">
<td class="thin">
- <%= link_to_action message('remove'),
+ <%= link_to_action message('quality_profiles.remove_project_action'),
"#{ApplicationController.root_context}/profiles/remove_project?id=#{@profile.id}&project_id=#{project.id}",
:class => 'link-action',
- :id => "link-remove-#{project.key.parameterize}" -%>
+ :id => "link-remove-#{project.key.parameterize}",
+ :confirm_title => 'quality_profiles.remove_project_confirm_title',
+ :confirm_button => 'quality_profiles.remove_project_confirm_button',
+ :confirm_msg => 'quality_profiles.remove_project_confirm_message',
+ :confirm_msg_params => [project.name]
+ -%>
</td>
<td><%= h project.name -%> <span class="small gray"><%= h project.key -%></span></td>
</tr>
@@ -45,7 +51,11 @@
<%= link_to_action message('quality_profiles.remove_projects_action'),
"#{ApplicationController.root_context}/profiles/remove_projects?id=#{@profile.id}",
:class => 'link-action',
- :id => "link-remove-projects" -%>
+ :id => "link-remove-projects",
+ :confirm_title => 'quality_profiles.remove_projects_confirm_title',
+ :confirm_button => 'quality_profiles.remove_projects_confirm_button',
+ :confirm_msg => 'quality_profiles.remove_projects_confirm_message'
+ -%>
</td>
</tr>
</tfoot>