Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show breadcrumbs when redirected from another controller #5148

Merged
merged 3 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/ems_cloud_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def self.table_name
@table_name ||= "ems_cloud"
end

def show
@breadcrumbs = [{:name => _('Cloud Providers'), :url => '/ems_cloud/show_list'}]
super
end

def ems_path(*args)
ems_cloud_path(*args)
end
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/ems_container_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def show_list
process_show_list(:gtl_dbname => 'emscontainer')
end

def show
@breadcrumbs = [{:name => _('Containers Providers'), :url => '/ems_container/show_list'}]
super
end

def ems_path(*args)
ems_container_path(*args)
end
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/ems_infra_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def self.table_name
@table_name ||= "ems_infra"
end

def show
@breadcrumbs = [{:name => _('Infrastructure Providers'), :url => '/ems_infra/show_list'}]
super
end

def ems_path(*args)
ems_infra_path(*args)
end
Expand Down
9 changes: 6 additions & 3 deletions spec/controllers/ems_infra_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@
get :show, :params => {:id => @ems.id, :display => 'storages'}
expect(response.status).to eq(200)
expect(response).to render_template('shared/views/ems_common/show')
expect(assigns(:breadcrumbs)).to eq([{:name => "#{@ems.name} (All Datastores)", :url => "/ems_infra/#{@ems.id}?display=storages"}])
expect(assigns(:breadcrumbs)).to eq([{:name => "Infrastructure Providers", :url => "/ems_infra/show_list"},
{:name => "#{@ems.name} (All Datastores)", :url => "/ems_infra/#{@ems.id}?display=storages"}])

# display needs to be saved to session for GTL pagination and such
expect(session[:ems_infra_display]).to eq('storages')
Expand All @@ -357,7 +358,8 @@
post :button, :params => {:id => @ems.id, :display => 'storages', :miq_grid_checks => datastore.id, :pressed => "storage_tag", :format => :js}
expect(response.status).to eq(200)
_breadcrumbs = controller.instance_variable_get(:@breadcrumbs)
expect(assigns(:breadcrumbs)).to eq([{:name => "#{@ems.name} (All Datastores)",
expect(assigns(:breadcrumbs)).to eq([{:name => "Infrastructure Providers", :url => "/ems_infra/show_list"},
{:name => "#{@ems.name} (All Datastores)",
:url => "/ems_infra/#{@ems.id}?display=storages"},
{:name => "Tag Assignment", :url => "//tagging_edit"}])
end
Expand Down Expand Up @@ -400,7 +402,8 @@
ems = FactoryBot.create(:ems_vmware)
get :show, :params => { :id => ems.id }
breadcrumbs = controller.instance_variable_get(:@breadcrumbs)
expect(breadcrumbs).to eq([{:name => "#{ems.name} (Dashboard)", :url => "/ems_infra/#{ems.id}"}])
expect(breadcrumbs).to eq([{:name => "Infrastructure Providers", :url => "/ems_infra/show_list"},
{:name => "#{ems.name} (Dashboard)", :url => "/ems_infra/#{ems.id}"}])
end
end
end
Expand Down