Skip to content

Commit

Permalink
Merge pull request #3322 from lgalis/cb_system_change_tab_switch
Browse files Browse the repository at this point in the history
Custom Button Add/Edit - stay on the Advanced tab when changing the System/Process field
(cherry picked from commit 2c375fd)

https://bugzilla.redhat.com/show_bug.cgi?id=1552743
  • Loading branch information
mzazrivec authored and simaishi committed Mar 7, 2018
1 parent 01dca18 commit 142847d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/application_controller/buttons.rb
Expand Up @@ -121,7 +121,7 @@ def automate_button_field_changed
render :update do |page|
page << javascript_prologue
if [:instance_name, :other_name, :target_class, :button_type].any? { |k| params.key?(k) }
@sb[:active_tab] = "ab_options_tab"
@sb[:active_tab] = params[:instance_name] ? "ab_advanced_tab" : "ab_options_tab"
page.replace("ab_form", :partial => "shared/buttons/ab_form")
end
if params[:visibility_typ]
Expand Down
Expand Up @@ -74,5 +74,28 @@
expect(response.status).to eq(200)
expect(response.body).to include('name=\"disabled_text\" id=\"disabled_text\" value=\"a_new_disabled_text\"')
end

it "the active tab is Advanced when the System/process field is updated" do
@sb = {:active_tree => :ab_tree,
:trees => {:ab_tree => {:tree => :ab_tree}},
:params => {:instance_name => 'MiqEvent'}}
controller.instance_variable_set(:@sb, @sb)
controller.instance_variable_set(:@breadcrumbs, [])

edit = {:new => {:button_images => %w(01 02 03), :available_dialogs => {:id => '01', :name => '02'},
:instance_name => 'MiqEvent',
:attrs => [%w(Attr1 01), %w(Attr2 02), %w(Attr3 03), %w(Attr4 04), %w(Attr5 05)],
:disabled_text => 'a_disabled_text',
:visibility_typ => 'Type1'},
:instance_names => %w(CustomButton_1 CustomButton_2),
:visibility_types => %w(Type1 Type2),
:ansible_playbooks => [],
:current => {}}
controller.instance_variable_set(:@edit, edit)
session[:edit] = edit
session[:resolve] = {}
post :automate_button_field_changed, :params => {:id => 'new', :instance_name => "Request"}
expect(assigns(:sb)[:active_tab]).to eq("ab_advanced_tab")
end
end
end

0 comments on commit 142847d

Please sign in to comment.