aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstephenbroyer <stephen.broyer@sonarsource.com>2013-10-16 11:53:41 +0200
committerstephenbroyer <stephen.broyer@sonarsource.com>2013-10-18 09:57:35 +0200
commit51174f7f3434fc5c422ebf84e20f7984762f3bdd (patch)
tree0e61b1f0af0dd7f2b7e67bc947f4877f707faee6
parentf5c07dede36832bfb401b4f805d4a38bb9221511 (diff)
downloadsonarqube-51174f7f3434fc5c422ebf84e20f7984762f3bdd.tar.gz
sonarqube-51174f7f3434fc5c422ebf84e20f7984762f3bdd.zip
SONAR-4758 Use modal windows in Users pages
(delete user)
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb24
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/users/_delete_form.html.erb29
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb3
3 files changed, 48 insertions, 8 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb
index 1d42a422405..b4a0f071e05 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb
@@ -163,21 +163,33 @@ class UsersController < ApplicationController
end
end
+ def delete_form
+ user = User.find(params[:id])
+ if user
+ @user=user
+ render :partial => 'users/delete_form'
+ else
+ redirect_to(:action => 'index', :id => nil)
+ end
+ end
+
def destroy
begin
user = User.find(params[:id])
+ @user =user
Api.users.deactivate(user.login)
flash[:notice] = 'User is deleted.'
+ render :text => 'ok', :status => 200
rescue NativeException => exception
+ @errors = []
if exception.cause.java_kind_of? Java::OrgSonarServerExceptions::HttpException
error = exception.cause
- flash[:error] = (error.getMessage ? error.getMessage : Api::Utils.message(error.l10nKey, :params => error.l10nParams.to_a))
- else
- flash[:error] = 'Error when deleting this user.'
- end
+ @errors = (error.getMessage ? error.getMessage : Api::Utils.message(error.l10nKey, :params => error.l10nParams.to_a))
+ else
+ @errors << 'Error when deleting this user.'
+ end
+ render :partial => 'users/delete_form',:status => 400
end
-
- redirect_to(:action => 'index', :id => nil)
end
def select_group
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/users/_delete_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/users/_delete_form.html.erb
new file mode 100644
index 00000000000..aafa4a3c538
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/users/_delete_form.html.erb
@@ -0,0 +1,29 @@
+<form action="<%= ApplicationController.root_context -%>/users/destroy/<%= @user.id -%>" method="POST" id="user_form">
+ <fieldset>
+ <div class="modal-head">
+ <h2>Delete user &nbsp;<%= @user.login %></h2>
+ </div>
+ <div class="modal-body">
+ <% if @errors
+ @errors.each do |error|
+ %>
+ <p class="error"><%= h error -%></p>
+ <% end
+ end
+ %>
+ <div class="modal-field">
+ <input type="hidden" name="id" value="<%= @user.id -%>"/>
+ </div>
+ <div class="modal-field">
+ Warning : are you sure to delete this user?
+ </div>
+ </div>
+ <div class="modal-foot">
+ <%= submit_tag 'Delete' %>
+ <%= link_to 'Cancel', { :controller => 'users', :action => 'index'}, { :class => 'action' } %><br/>
+ </div>
+ </fieldset>
+</form>
+<script>
+ $j("#user_form").modalForm();
+</script> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb
index dd6cee25cf0..ff2a1450ca7 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/users/index.html.erb
@@ -36,8 +36,7 @@
&nbsp;
<%= link_to "Change password", { :id => user.id, :action => 'change_password_form'}, {:id => "change-password-#{u user.login}", :class => 'open-modal link-action'} %>
&nbsp;
- <%= link_to "Delete", {:action => 'destroy', :id => user.id}, {:confirm => "Warning : are you sure to delete this user?", :method => 'delete',
- :id => "delete-#{u user.login}", :class => 'link-action link-red'} %>
+ <a id="delete-<%= user.name -%>" class="open-modal link-action link-red" href="<%=ApplicationController.root_context-%>/users/delete_form/<%= user.id -%>">Delete</a>
</td>
</tr>
<% end %>