aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-08 00:09:54 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-08 00:09:54 +0000
commit2c41b392b19680ff60b3096863e6283a9a58cad1 (patch)
tree2b6cd3cb4c4bd27575194fd75f42e5300a649c42
parent21c5edb2ea807bc3ea575d4ec22981e32d879e20 (diff)
downloadsonarqube-2c41b392b19680ff60b3096863e6283a9a58cad1.tar.gz
sonarqube-2c41b392b19680ff60b3096863e6283a9a58cad1.zip
SONAR-1404 Allow to rename quality profile
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb29
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb13
2 files changed, 38 insertions, 4 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
index 21800f05caf..273b5887698 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
@@ -20,7 +20,7 @@
class ProfilesController < ApplicationController
SECTION=Navigation::SECTION_CONFIGURATION
- verify :method => :post, :only => ['create', 'delete', 'copy', 'set_as_default', 'restore', 'backup', 'set_projects'], :redirect_to => { :action => 'index' }
+ verify :method => :post, :only => ['create', 'delete', 'copy', 'set_as_default', 'restore', 'backup', 'set_projects', 'rename'], :redirect_to => { :action => 'index' }
before_filter :admin_required, :except => [ 'index', 'show', 'projects' ]
#
@@ -213,7 +213,7 @@ class ProfilesController < ApplicationController
def set_projects
@profile = Profile.find(params[:id])
@profile.projects.clear
-
+
projects=Project.find(params[:projects] || [])
@profile.projects=projects
flash[:notice]="Profile '#{@profile.name}' associated to #{projects.size} projects."
@@ -221,6 +221,31 @@ class ProfilesController < ApplicationController
end
+
+ #
+ #
+ # POST /profiles/rename/<id>?name=<new name>
+ #
+ #
+ def rename
+ profile = Profile.find(params[:id])
+ name = params['rename_' + profile.id.to_s]
+
+ if name.blank?
+ flash[:warning]='Profile name can not be blank.'
+ else
+ existing=Profile.find(:first, :conditions => {:name => name, :language => profile.language})
+ if existing
+ flash[:warning]='This profile name already exists.'
+ elsif !profile.provided?
+ profile.name=name
+ profile.save
+ end
+ end
+ redirect_to :action => 'index'
+ end
+
+
private
def read_file_param(configuration_file)
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 373495c35d6..4ff3533e482 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
@@ -13,13 +13,13 @@
<th class="right">Export</th>
<th class="right">Default</th>
<th class="right">Projects</th>
- <th width="1%" class="right" colspan="3">Operations</th>
+ <th width="1%" class="right" colspan="4">Operations</th>
</tr>
</thead>
<% if administrator? %>
<tfoot id="footer-<%= language.getKey() -%>">
<tr>
- <td colspan="9">
+ <td colspan="10">
<a href="#" onClick="$('footer-<%= language.getKey() -%>').hide();$('create-form-<%= language.getKey() -%>').show();return false;">Create <%= language.getName() -%> profile</a>
|
<a href="#" onclick="$('footer-<%= language.getKey() -%>').hide();$('restore-form-<%= language.getKey() -%>').show();return false;">Restore <%= language.getName() -%> profile</a>
@@ -78,6 +78,15 @@
</td>
<td align="right">
+ <% if !profile.provided? && administrator? %>
+ <% form_tag(:action => 'rename', :id => profile.id) do -%>
+ <%= hidden_field_tag 'rename_' + profile.id.to_s %>
+ <input type="button" name="button_rename" id="rename_<%= u profile.key %>" value="Rename" onClick='var name=prompt("New name"); if (name!=null) {$("rename_<%= profile.id %>").value=name; submit();} else {return false;}'>
+ <% end
+ end %>
+ </td>
+
+ <td align="right">
<% if administrator? %>
<% form_tag(:action => 'copy', :id => profile.id) do -%>
<%= hidden_field_tag 'copy_' + profile.id.to_s %>