From dda0546d300cbf0bb14d9abd24613e9ccd77f755 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 10 Apr 2014 15:03:35 +0200 Subject: [PATCH] SONAR-4971 Use modal window instead of browser popup in the project deletion page --- .../app/controllers/project_controller.rb | 31 +++++++++------ .../app/views/project/_delete_form.html.erb | 37 ++++++++++++++++++ .../app/views/project/deletion.html.erb | 38 ++++++------------- 3 files changed, 67 insertions(+), 39 deletions(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/project/_delete_form.html.erb 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 8da6b853e67..689d3cc57ce 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 @@ -28,13 +28,31 @@ class ProjectController < ApplicationController redirect_to :overwrite_params => {:controller => :dashboard, :action => 'index'} end + def delete_form + access_denied unless (is_admin?(@project)) + @project = get_current_project(params[:id]) + render :partial => 'delete_form' + end + + def delete + access_denied unless (is_admin?(@project)) + @project = get_current_project(params[:id]) + + # Ask the resource deletion manager to start the migration + # => this is an asynchronous AJAX call + ResourceDeletionManager.instance.delete_resources([@project.id]) + + # and return some text that will actually never be displayed + render :text => ResourceDeletionManager.instance.message + end + def deletion @project = get_current_project(params[:id]) if java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'deletable') deletion_manager = ResourceDeletionManager.instance if deletion_manager.currently_deleting_resources? || - (!deletion_manager.currently_deleting_resources? && deletion_manager.deletion_failures_occured?) + (!deletion_manager.currently_deleting_resources? && deletion_manager.deletion_failures_occured?) # a deletion is happening or it has just finished with errors => display the message from the Resource Deletion Manager render :template => 'project/pending_deletion' else @@ -45,17 +63,6 @@ class ProjectController < ApplicationController end end - def delete - @project = get_current_project(params[:id]) - - # Ask the resource deletion manager to start the migration - # => this is an asynchronous AJAX call - ResourceDeletionManager.instance.delete_resources([@project.id]) - - # and return some text that will actually never be displayed - render :text => ResourceDeletionManager.instance.message - end - def pending_deletion deletion_manager = ResourceDeletionManager.instance diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/_delete_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/_delete_form.html.erb new file mode 100644 index 00000000000..6bde15752dc --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/_delete_form.html.erb @@ -0,0 +1,37 @@ +<% resource_qualifier = message('qualifier.' + @project.qualifier) %> +
+
+ + + +
+
+ diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb index fb694f6e376..a5c399ebbf9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb @@ -1,31 +1,15 @@ <% - if !@snapshot || @snapshot.root? - resource_qualifier = message('qualifier.' + @project.qualifier) - delete_resource_message = message('project_deletion.page', :params => resource_qualifier) + if !@snapshot || @snapshot.root? + resource_qualifier = message('qualifier.' + @project.qualifier) + delete_resource_message = message('project_deletion.page', :params => resource_qualifier) %> -

<%= delete_resource_message -%>

-

<%= message('project_deletion.page.description') -%>

-
-
-
-
- - <%= message('project_deletion.operation_cannot_be_undone') -%> -
- <%= submit_tag delete_resource_message, :id => 'delete_resource', :class => 'action red-button', - :confirm => message('project_deletion.delete_resource_confirmation', :params => resource_qualifier) %> -
+

<%= delete_resource_message -%>

+

<%= message('project_deletion.page.description') -%>

+
+
+ <%= message('project_deletion.operation_cannot_be_undone') -%>
+ <%= delete_resource_message -%> +
-
<% end %> -- 2.39.5