diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-08-31 18:18:14 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-08-31 18:18:14 +0200 |
commit | 8ce8f2a2ff596cb6185b111cf7eda2368bfc3026 (patch) | |
tree | b81789b6e07da5023670ab5d92fa7fe4dbc6b7f6 /sonar-server/src/main | |
parent | fe54c6c721c33638855da5baed61dfc1a9c5cc09 (diff) | |
download | sonarqube-8ce8f2a2ff596cb6185b111cf7eda2368bfc3026.tar.gz sonarqube-8ce8f2a2ff596cb6185b111cf7eda2368bfc3026.zip |
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
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb | 8 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/views/project/history.html.erb | 91 |
2 files changed, 45 insertions, 54 deletions
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 @@ <h1><%= message('project_history.page_title') -%></h1> <br/> -<script> - function updateSelectBox() { - var inputs = document.getElementsByName("snapshot_ids[]"); - var selected = false; - for (i=0; i<inputs.length; i++) { - if (inputs[i].checked) { selected = true; break;} - } - $('operation-select-box').disabled = !selected; - } -</script> +<div class="help"> + <h3><%= message('project_history.note') -%></h3> + <p> + <%= message('project_history.note_detail') -%> + </p> +</div> +<br/> -<form action="<%= ApplicationController.root_context -%>/project/snapshot_history" method="POST" id="snapshots-form"> -<input type="hidden" name="id" value="<%= @project.id -%>"/> -<table class="width100 data"> +<table class="data" style="width:1%"> <thead> <tr> <th class="thin nowrap"><%= message('project_history.col.year') -%></th> <th class="thin nowrap"><%= message('project_history.col.month') -%></th> - <th style="width: 18px"></th> - <th class="nowrap"><%= message('project_history.col.time') -%></th> - <th class="nowrap"><%= message('project_history.col.events') -%></th> + <th class="thin nowrap" style="padding-left: 20px;"><%= message('project_history.col.events') -%></th> + <th style="min-width: 20px; padding-left: 30px;"> </th> + <th class="thin nowrap"><%= message('project_history.col.time') -%></th> <th class="thin nowrap center"><%= message('project_history.col.action') -%></th> - <th class="thin nowrap"> - <select id="operation-select-box" name="operation" onChange="$('snapshots-form').submit()" disabled> - <option value="" selected></option> - <option value="delete"><%= message('project_history.delete') -%></option> - <option value="recover"><%= message('project_history.recover') -%></option> - </select> - </th> </tr> </thead> <tbody> <% 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 @@ <tr class="<%= cycle 'even','odd' -%>"> <td class="thin nowrap"><%= time.year unless time.year == current_year -%></td> <td class="thin nowrap"><%= l(time, :format => '%B').capitalize unless time.month == current_month -%></td> - <td style="width: 18px"> - <% if snapshot.status == 'U' %> + <td class="thin nowrap" style="padding-left: 20px;"> + <%= snapshot.events.map{|e| e.name}.join(', ') -%> + </td> + <td class="right" style="padding-left: 30px;"> + <% if last_snapshot_found && snapshot.status == 'U' %> <img src="<%= image_path '/images/exclamation.png' -%>" title="<%= message('project_history.snapshot_will_be_deleted_next_analysis') -%>"> <% end %> </td> - <td class="nowrap"><%= l time, :format => :long -%></td> - <td> - <%= snapshot.events.map{|e| e.name}.join(', ') -%> - </td> - <td class="thin nowrap center"> - <% - unless snapshot.islast - button_value, operation, class_style, confirm_message = nil + <td class="thin nowrap"><%= l time, :format => :long -%></td> + <td class="thin nowrap center" style="padding-left:10px; padding-right:10px"> + <% + cell_content = nil; + if snapshot.islast? + last_snapshot_found = true + cell_content = "<b>" + message('project_history.last_snapshot') + "</b>" + 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 = "<i>" + message('project_history.currently_analysing') + "</i>" + 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 %> - <input type="submit" value="<%= button_value-%>" id="delete_exclusions" class="<%= class_style -%>" - onclick="if (<%= confirm_message ? "confirm('"+confirm_message+"')" : 'true'-%>) { 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 %> - </td> - <td class="center"> - <% unless snapshot.islast %> - <input id="snapshot_ids" name="snapshot_ids[]" type="checkbox" value="<%= snapshot.id -%>" onClick="updateSelectBox()" /> - <% end %> + <%= cell_content -%> </td> </tr> <% @@ -85,6 +77,5 @@ %> </tbody> </table> -</form> <% end %>
\ No newline at end of file |