From: Fabrice Bellingard Date: Wed, 31 Aug 2011 16:18:14 +0000 (+0200) Subject: SONAR-893 Improve the "History" service for projects X-Git-Tag: 2.11^2~110 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8ce8f2a2ff596cb6185b111cf7eda2368bfc3026;p=sonarqube.git SONAR-893 Improve the "History" service for projects - Display snapshot that are currently being built without the possibility to modify their status - Remove the popup and the bulk change, as there's the recovery mechanism - Invert Event and Time columns - Set the table to minimum width --- 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 02cec994c05..fa208995a46 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 @@ -600,6 +600,8 @@ manual_measures.pending_message=Pending measures are marked with orange box. The #------------------------------------------------------------------------------ project_history.page_title=Delete quality snapshots from project history +project_history.note=Note on snapshot deletion +project_history.note_detail=A snapshot may be deleted from the database only if it was created more that 6 hours ago. project_history.col.year=Year project_history.col.month=Month project_history.col.time=Time @@ -607,11 +609,12 @@ project_history.col.events=Events project_history.col.action=Action project_history.delete=Delete project_history.recover=Recover +project_history.currently_analysing=Currently analysing... +project_history.last_snapshot=Last snapshot project_history.delete_snapshot=Delete snapshot project_history.recover_snapshot=Recover snapshot -project_history.sure_to_delete_snapshot=Are you sure you want to delete this snapshot? -project_history.x_snapshots_deleted={0} snapshot(s) will be deleted during next analysis. -project_history.x_snapshots_recovered={0} snapshot(s) will not be deleted during next analysis. +project_history.snapshot_deleted=The snapshot will be deleted. +project_history.snapshot_recovered=Snapshot recovered. project_history.snapshot_will_be_deleted_next_analysis=This snapshot will be deleted during next analysis. 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 ce250b2011a..cfd8080f773 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 @@ -64,12 +64,12 @@ class ProjectController < ApplicationController project=Project.by_key(params[:id]) return access_denied unless is_admin?(@project) - sids = params[:snapshot_ids] + sid = params[:snapshot_id] delete_operation = params[:operation] == "delete" - unless sids.empty? + if sid status = delete_operation ? 'U' : 'P' - Snapshot.update_all("status='"+status+"'", ["id IN (?) or root_snapshot_id IN (?)", sids, sids]) - flash[:notice] = message(delete_operation ? 'project_history.x_snapshots_deleted' : 'project_history.x_snapshots_recovered', :params => sids.size) + 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') 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 a7adeb68616..a4126970bd7 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,41 +2,30 @@

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


- +
+

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

+

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

+
+
-
- - +
- - - + + + - <% current_year = nil - current_month = nil + current_month = nil + last_snapshot_found = false @snapshots.each do |snapshot| number_of_events = snapshot.events.size time = snapshot.created_at @@ -44,38 +33,41 @@ - + - - - + - <% @@ -85,6 +77,5 @@ %>
<%= message('project_history.col.year') -%> <%= message('project_history.col.month') -%><%= message('project_history.col.time') -%><%= message('project_history.col.events') -%><%= message('project_history.col.events') -%> <%= message('project_history.col.time') -%> <%= message('project_history.col.action') -%> - -
<%= time.year unless time.year == current_year -%> <%= l(time, :format => '%B').capitalize unless time.month == current_month -%> - <% if snapshot.status == 'U' %> + + <%= snapshot.events.map{|e| e.name}.join(', ') -%> + + <% if last_snapshot_found && snapshot.status == 'U' %> <% end %> <%= l time, :format => :long -%> - <%= snapshot.events.map{|e| e.name}.join(', ') -%> - - <% - unless snapshot.islast - button_value, operation, class_style, confirm_message = nil + <%= 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' - button_value = message('project_history.delete_snapshot') - operation = 'delete' - class_style = 'action red-button' - confirm_message = message('project_history.sure_to_delete_snapshot') + cell_content = button_to( message('project_history.delete_snapshot'), + { :action => "snapshot_history", :id => @project.id, :snapshot_id => [snapshot.id], :operation => "delete" }, + :class => 'action red-button', + :method => :delete) else - button_value = message('project_history.recover_snapshot') - operation = 'recover' - class_style = 'action' + 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 + end %> - ) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = '<%= url_for :action => "snapshot_history", :id => @project.id, :snapshot_ids => [snapshot.id], :operation => operation -%>';f.submit(); };return false;"> - <% end %> - - <% unless snapshot.islast %> - - <% end %> + <%= cell_content -%>
-
<% end %> \ No newline at end of file