ACK with one nit inline
On 06/30/2011 01:33 PM, tsedovic(a)redhat.com wrote:
From: Tomas Sedovic<tsedovic(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=698270
---
src/app/controllers/pools_controller.rb | 5 +++++
src/app/views/instances/_list.haml | 7 +++++++
src/features/pool.feature | 15 +++++++++++++++
3 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/app/controllers/pools_controller.rb
b/src/app/controllers/pools_controller.rb
index 200199f..e51aa8c 100644
--- a/src/app/controllers/pools_controller.rb
+++ b/src/app/controllers/pools_controller.rb
@@ -6,6 +6,7 @@ class PoolsController< ApplicationController
viewstate :index do |default|
default.merge!({
:view => 'pretty',
+ :hide_stopped => 'true',
})
end
@@ -32,6 +33,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'}
it's better to use Instance::STATE_STOPPED constant instead of '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 a80606f..085f977 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', :class => 'button'
= restful_submit_tag 'Remove failed', 'remove_failed',
remove_failed_instances_path, 'GET', :class => 'button'
+ - 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')
= render :partial => 'layouts/select_all_none'
diff --git a/src/features/pool.feature b/src/features/pool.feature
index 7a945a7..c5867ef 100644
--- a/src/features/pool.feature
+++ b/src/features/pool.feature
@@ -187,3 +187,18 @@ Feature: Manage Pools
When I am viewing the pool "mockpool"
And I follow link with ID "filter_view"
Then I should not see "0 Instances" within
".content.collapsible.toggle-view.pools"
+
+ Scenario: Hide/Show stopped instances
+ Given I am on the pools page
+ And there is a "mock1" running instance
+ And there is a "mock2" running instance
+ And there is a "mock3" stopped instance
+ When I follow link with ID "filter_view"
+ And I follow "Instances"
+ And I should see "mock1"
+ And I should see "mock2"
+ And I should not see "mock3"
+ When I follow "show all"
+ And I should see "mock1"
+ And I should see "mock2"
+ And I should see "mock3"