From: Tomas Sedovic<tsedovic(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=698270
---
src/app/controllers/pools_controller.rb | 4 ++++
src/app/views/instances/_list.haml | 7 +++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/app/controllers/pools_controller.rb
b/src/app/controllers/pools_controller.rb
index 68c1b62..2ba382d 100644
--- a/src/app/controllers/pools_controller.rb
+++ b/src/app/controllers/pools_controller.rb
@@ -32,6 +32,10 @@ class PoolsController< ApplicationController
@pools = Pool.list_or_search(params[:q],
params[:order_field],params[:order_dir])
when 'instances'
@instances = Instance.list_or_search(params[:q],
params[:order_field],params[:order_dir])
+ @hide_stopped = @viewstate&& @viewstate.state['hide_stopped']
== 'true'
+ if @hide_stopped
+ @instances.delete_if {|i| i.state == 'stopped'}
+ end
when 'deployments'
@deployments = Deployment.list_or_search(params[:q],
params[:order_field],params[:order_dir])
end
diff --git a/src/app/views/instances/_list.haml b/src/app/views/instances/_list.haml
index 77c2a31..5b59f30 100644
--- a/src/app/views/instances/_list.haml
+++ b/src/app/views/instances/_list.haml
@@ -1,6 +1,13 @@
- form_tag do
= restful_submit_tag 'Stop', 'stop', multi_stop_instances_path,
'GET'
= restful_submit_tag 'Remove failed', 'remove_failed',
remove_failed_instances_path, 'GET'
+ - if @hide_stopped
+ %b Stopped
+ instances are hidden:
+ = link_to "show all", params.merge('hide_stopped' =>
'false')
+ - else
+ Showing all instances:
+ = link_to "hide stopped", params.merge('hide_stopped' =>
'true')
%p
Select:
Hi Tomas,
this works fine. Only two notes we talked about: I think it makes sense
to hide stopped instances by default. In future (= not related to this
patch, just idea) we could simplify viewstate code by adding 'viewstate'
method which returns hash of set/default values, so instead of:
@viewstate && @viewstate.state['hide_stopped'] == 'true'
we could call just:
viewstate['hide_stopped']
Could you please add a simple cuke test for this feature? I know this
solution is temporary, but you never know how long it stays and cuke
test takes just a few minutes.
Jan