aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2012-03-29 19:19:08 +0200
committerFabrice Bellingard <bellingard@gmail.com>2012-03-29 19:19:08 +0200
commitca69df1a7c175703dbac9d321e93d2fc13847f83 (patch)
tree9431bd56eeb7adcd4572c541255e798bf098753d /sonar-server
parent2dab91a6c29fe829b1413a6ec469ff82a20ee1a7 (diff)
downloadsonarqube-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
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/project.rb7
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/project/deletion.html.erb14
6 files changed, 23 insertions, 16 deletions
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