diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2012-03-29 19:19:08 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2012-03-29 19:19:08 +0200 |
commit | ca69df1a7c175703dbac9d321e93d2fc13847f83 (patch) | |
tree | 9431bd56eeb7adcd4572c541255e798bf098753d | |
parent | 2dab91a6c29fe829b1413a6ec469ff82a20ee1a7 (diff) | |
download | sonarqube-ca69df1a7c175703dbac9d321e93d2fc13847f83.tar.gz sonarqube-ca69df1a7c175703dbac9d321e93d2fc13847f83.zip |
SONAR-3287 Update UI to adapt labels to deletable resource
=> Make it possible to delete a View or a Developer (resources and
snapshots) through the Sonar UI
10 files changed, 38 insertions, 20 deletions
diff --git a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java index afee357487a..7df47385763 100644 --- a/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java +++ b/plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DefaultPurgeTask.java @@ -58,7 +58,7 @@ public class DefaultPurgeTask implements PurgeTask { } public PurgeTask delete(long resourceId) { - purgeDao.deleteProject(resourceId); + purgeDao.deleteResourceTree(resourceId); return this; } 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 9f9c773f0db..28ea72edd23 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 @@ -312,7 +312,6 @@ project_settings.page=Settings project_links.page=Links project_exclusions.page=Exclusions project_history.page=History -project_deletion.page=Project Deletion quality_profiles.page=Quality Profiles reviews.page=Reviews settings.page=General Settings @@ -326,6 +325,7 @@ violations_drilldown.page=Violations Drilldown update_center.page=Update Center lcom4_viewer.page=LCOM4 dependencies.page=Dependencies +resource_deletion.page={0} Deletion # GWT pages @@ -918,6 +918,17 @@ project_history.event_already_exists=Event "{0}" already exists. #------------------------------------------------------------------------------ # +# PROJECT (RESOURCE) DELETION PAGE +# +#------------------------------------------------------------------------------ + +project_deletion.delete_resource=Delete {0} +project_deletion.operation_cannot_be_undone=This operation can not be undone. +project_deletion.delete_resource_confirmation=Are you sure you want to delete this {0}? + + +#------------------------------------------------------------------------------ +# # TIME MACHINE # #------------------------------------------------------------------------------ diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java index a93661f87a0..d4caa191ce3 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java @@ -137,7 +137,7 @@ public class PurgeDao { } } - public PurgeDao deleteProject(long rootProjectId) { + public PurgeDao deleteResourceTree(long rootProjectId) { final SqlSession session = mybatis.openBatchSession(); final PurgeMapper mapper = session.getMapper(PurgeMapper.class); final PurgeVendorMapper vendorMapper = session.getMapper(PurgeVendorMapper.class); diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java index 9269f7c4daf..9e7db168941 100644 --- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java @@ -111,7 +111,7 @@ public class PurgeDaoTest extends DaoTestCase { @Test public void shouldDeleteProject() { setupData("shouldDeleteProject"); - dao.deleteProject(1L); + dao.deleteResourceTree(1L); assertEmptyTables("projects", "snapshots", "action_plans", "action_plans_reviews", "reviews", "review_comments"); } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index d244203eabb..8f2bcb7cd97 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -399,8 +399,8 @@ public final class JRubyFacade { getContainer().getComponentByType(ResourceIndexerDao.class).indexProjects(); } - public void deleteProject(long rootProjectId) { - getContainer().getComponentByType(PurgeDao.class).deleteProject(rootProjectId); + public void deleteResourceTree(long rootProjectId) { + getContainer().getComponentByType(PurgeDao.class).deleteResourceTree(rootProjectId); } public void logError(String message) { diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb index 946e94ce3b0..a6082845899 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb @@ -61,9 +61,8 @@ class Api::ProjectsController < Api::ApiController project = Project.by_key(params[:id]) bad_request("Not valid project") unless project access_denied unless is_admin?(project) - bad_request("Not valid project") unless project.project? - Project.delete_project(project) + Project.delete_resource_tree(project) render_success("Project deleted") end 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 88ebe73790d..b6f6d7917ff 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 @@ -32,17 +32,18 @@ class ProjectController < ApplicationController not_found("Project not found") unless @project access_denied unless is_admin?(@project) - @snapshot=@project.last_snapshot - if !@project.project? + unless java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'deletable') redirect_to :action => 'index', :id => params[:id] end + + @snapshot=@project.last_snapshot end def delete if params[:id] @project = Project.by_key(params[:id]) - if @project && @project.project? && is_admin?(@project) - Project.delete_project(@project) + if @project && is_admin?(@project) + Project.delete_resource_tree(@project) end end redirect_to_default diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb index 016fe99c9ca..844b4fb0070 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/project.rb @@ -43,9 +43,10 @@ class Project < ActiveRecord::Base end end - def self.delete_project(project) - if project && project.project? - Java::OrgSonarServerUi::JRubyFacade.getInstance().deleteProject(project.id) + def self.delete_resource_tree(project) + java_facade = Java::OrgSonarServerUi::JRubyFacade.getInstance() + if project && java_facade.getResourceTypeBooleanProperty(project.qualifier, 'deletable') + java_facade.deleteResourceTree(project.id) end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index 36b16f328fb..3b4c053dd14 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -90,7 +90,7 @@ <% end %> <% if controller.java_facade.getResourceTypeBooleanProperty(@project.qualifier, 'deletable') %> <li class="<%= 'selected' if request.request_uri.include?('/project/deletion') -%>"> - <a href="<%= ApplicationController.root_context -%>/project/deletion/<%= @project.id -%>"><%= message('project_deletion.page') -%></a></li> + <a href="<%= ApplicationController.root_context -%>/project/deletion/<%= @project.id -%>"><%= message('resource_deletion.page', :params => message('qualifier.' + @project.qualifier)) -%></a></li> <% end %> <% end %> 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 a145f9eb4db..ea5493f8a4b 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,10 +1,16 @@ -<% if @snapshot.root? %> -<h1>Delete project</h1> +<% + if @snapshot.root? + resource_name = message('qualifier.' + @project.qualifier) + delete_resource_message = message('project_deletion.delete_resource', :params => resource_name) +%> +<h1><%= delete_resource_message -%></h1> <br/> <div class="yui-g widget" id="widget_delete_project"> <div class="warning"> - This operation can not be undone. - <%= button_to( "Delete project", { :action => "delete", :id => @project.id }, :class => 'action red-button', :confirm => "Are you sure you want to delete this project?", :method => :delete) %> + <%= message('project_deletion.operation_cannot_be_undone') -%> + <%= button_to( delete_resource_message, { :action => "delete", :id => @project.id }, + :class => 'action red-button', :method => :delete, + :confirm => message('project_deletion.delete_resource_confirmation', :params => resource_name)) %> </div> </div> <% end %>
\ No newline at end of file |