From c420194e347f8a70189638ed3e1ee4b0f3b46fa2 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Mon, 5 Sep 2011 18:13:31 +0200 Subject: SONAR-893 Remove the possibility to recover snapshots once deleted This can lead to problems. This functionality will be added back once we have a clean way to handle snapshot statuses. --- .../WEB-INF/app/controllers/project_controller.rb | 10 +++--- .../WEB-INF/app/views/project/history.html.erb | 38 +++------------------- 2 files changed, 9 insertions(+), 39 deletions(-) (limited to 'sonar-server/src/main') 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 cfd8080f773..29fc5cab8f7 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 @@ -56,20 +56,18 @@ class ProjectController < ApplicationController end @snapshot=@project.last_snapshot - @snapshots = Snapshot.find(:all, :conditions => ["project_id=?", @project.id], + @snapshots = Snapshot.find(:all, :conditions => ["status='P' AND project_id=?", @project.id], :include => 'events', :order => 'snapshots.created_at DESC') end - def snapshot_history + def delete_snapshot_history project=Project.by_key(params[:id]) return access_denied unless is_admin?(@project) sid = params[:snapshot_id] - delete_operation = params[:operation] == "delete" if sid - status = delete_operation ? 'U' : 'P' - Snapshot.update_all("status='"+status+"'", ["id=? or root_snapshot_id=(?)", sid, sid]) - flash[:notice] = message(delete_operation ? 'project_history.snapshot_deleted' : 'project_history.snapshot_recovered') + Snapshot.update_all("status='U'", ["id=? or root_snapshot_id=(?)", sid, sid]) + flash[:notice] = message('project_history.snapshot_deleted') end redirect_to :action => 'history', :id => project.id diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb index e411332d50a..4c8dc6235b1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb @@ -2,22 +2,13 @@

<%= message('project_history.page_title') -%>


-
-

<%= message('project_history.note') -%>

-

- <%= message('project_history.note_detail') -%> -

-
-
- - - + @@ -25,7 +16,6 @@ <% current_year = nil current_month = nil - last_snapshot_found = false @snapshots.each do |snapshot| number_of_events = snapshot.events.size time = snapshot.created_at @@ -36,35 +26,17 @@ - - +
<%= message('project_history.col.year') -%> <%= message('project_history.col.month') -%> <%= message('project_history.col.events') -%> <%= message('project_history.col.time') -%><%= message('project_history.col.time') -%> <%= message('project_history.col.action') -%>
<%= snapshot.events.map{|e| e.name}.join(', ') -%> - <% if last_snapshot_found && snapshot.status == 'U' %> - - <% end %> - <%= l time, :format => :long -%><%= l time, :format => :long -%> <% cell_content = nil; if snapshot.islast? - last_snapshot_found = true cell_content = "" + message('project_history.last_snapshot') + "" - elsif !last_snapshot_found - # the current snapshot is older than the last snapshot (the one that #islast == true), so this means that it represents - # an analysis that is currently running => no action should be taken - cell_content = "" + message('project_history.currently_analysing') + "" else - # this is a past snapshot, let's see if it could be deleted or recovered - if snapshot.status == 'P' - cell_content = button_to( message('project_history.delete_snapshot'), - { :action => "snapshot_history", :id => @project.id, :snapshot_id => [snapshot.id], :operation => "delete" }, + cell_content = button_to( message('project_history.delete_snapshot'), + { :action => "delete_snapshot_history", :id => @project.id, :snapshot_id => [snapshot.id] }, :class => 'action red-button', - :method => :delete) - else - cell_content = button_to( message('project_history.recover_snapshot'), - { :action => "snapshot_history", :id => @project.id, :snapshot_id => [snapshot.id], :operation => "recover" }, - :class => 'action', - :method => :delete) - end + :confirm => message('project_history.are_you_sure_delete_snapshot_x', :params => l(time, :format => :long)) ) end %> <%= cell_content -%> -- cgit v1.2.3