diff --git a/app/controllers/application_controller/automate.rb b/app/controllers/application_controller/automate.rb index e2fbf551043..ec8d1d38c00 100644 --- a/app/controllers/application_controller/automate.rb +++ b/app/controllers/application_controller/automate.rb @@ -33,36 +33,6 @@ def resolve_button_throw end private :resolve_button_throw - # Copy current URI as an automate button - def resolve_button_copy - session[:resolve_object] = copy_hash(@resolve) - head :ok - end - private :resolve_button_copy - - # Copy current URI as an automate button - def resolve_button_paste - @resolve = copy_hash(session[:resolve_object]) - @edit = session[:edit] - @custom_button = @edit[:custom_button] - @edit[:instance_names] = @resolve[:instance_names] - @edit[:new][:instance_name] = @resolve[:new][:instance_name] - @edit[:new][:object_message] = @resolve[:new][:object_message] - @edit[:new][:object_request] = @resolve[:new][:object_request] - @edit[:new][:attrs] = @resolve[:new][:attrs] - @edit[:new][:target_class] = @resolve[:target_class] = @resolve[:new][:target_class] - @edit[:uri] = @resolve[:uri] - (ApplicationController::AE_MAX_RESOLUTION_FIELDS - @resolve[:new][:attrs].length).times { @edit[:new][:attrs].push([]) } - @changed = (@edit[:new] != @edit[:current]) - render :update do |page| - page << javascript_prologue - page.replace_html("main_div", :partial => "shared/buttons/ab_list") - page << javascript_for_miq_button_visibility_changed(@changed) - page << "miqSparkle(false);" - end - end - private :resolve_button_paste - # Copy current URI as an automate button def resolve_button_simulate @edit = copy_hash(session[:resolve]) @@ -126,8 +96,6 @@ def resolve case params[:button] when "throw", "retry" then resolve_button_throw - when "copy" then resolve_button_copy - when "paste" then resolve_button_paste when "simulate" then resolve_button_simulate else resolve_button_reset_or_none end diff --git a/app/helpers/application_helper/button/ae_copy_simulate.rb b/app/helpers/application_helper/button/ae_copy_simulate.rb deleted file mode 100644 index 5737bb7d8e6..00000000000 --- a/app/helpers/application_helper/button/ae_copy_simulate.rb +++ /dev/null @@ -1,8 +0,0 @@ -class ApplicationHelper::Button::AeCopySimulate < ApplicationHelper::Button::ButtonWithoutRbacCheck - def disabled? - if @resolve[:button_class].blank? - @error_message = _('Object attribute must be specified to copy object details for use in a Button') - @error_message.present? - end - end -end diff --git a/app/helpers/application_helper/toolbar/miq_ae_tools_simulate_center.rb b/app/helpers/application_helper/toolbar/miq_ae_tools_simulate_center.rb index d3c6a8c4a9b..74df5aec9bf 100644 --- a/app/helpers/application_helper/toolbar/miq_ae_tools_simulate_center.rb +++ b/app/helpers/application_helper/toolbar/miq_ae_tools_simulate_center.rb @@ -1,12 +1,2 @@ class ApplicationHelper::Toolbar::MiqAeToolsSimulateCenter < ApplicationHelper::Toolbar::Basic - button_group('miq_ae_tools_vmdb', [ - button( - :ae_copy_simulate, - 'fa fa-files-o fa-lg', - N_('Copy object details for use in a Button'), - N_('Copy'), - :url => "resolve", - :url_parms => "?button=copy", - :klass => ApplicationHelper::Button::AeCopySimulate), - ]) end diff --git a/app/views/shared/buttons/_ab_form.html.haml b/app/views/shared/buttons/_ab_form.html.haml index 3ee6365428b..00d1d918132 100644 --- a/app/views/shared/buttons/_ab_form.html.haml +++ b/app/views/shared/buttons/_ab_form.html.haml @@ -1,25 +1,4 @@ #ab_form - #policy_bar - - if session[:resolve_object].present? - - copied_target_class = session[:resolve_object][:new][:target_class] - - current_target_class = @edit[:new][:target_class] - - if copied_target_class == current_target_class - = link_to({:action => "resolve", :button => "paste"}, - "data-miq_sparkle_on" => true, - "data-miq_sparkle_off" => true, - :remote => true, - "data-method" => :post, - :class => 'btn btn-default', - :title => _("Paste object details for use in a Button.")) do - %i.fa.fa-clipboard - - else - %button.btn.btn-default.disabled{:title => _("Paste is not available, target class differs from the target class of the object copied from the Simulation screen")} - %i.fa.fa-clipboard - - else - %button.btn.btn-default.disabled{:title => _("Paste is not available, no object information has been copied from the Simulation screen")} - %i.fa.fa-clipboard - = render :partial => "layouts/flash_msg" - #custom_button_tabs %ul.nav.nav-tabs{'role' => 'tablist'} = miq_tab_header('ab_options_tab', @sb[:active_tab]) do diff --git a/spec/helpers/application_helper/buttons/ae_copy_simulate_spec.rb b/spec/helpers/application_helper/buttons/ae_copy_simulate_spec.rb deleted file mode 100644 index ffb21e42e0e..00000000000 --- a/spec/helpers/application_helper/buttons/ae_copy_simulate_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -describe ApplicationHelper::Button::AeCopySimulate do - let(:view_context) { setup_view_context_with_sandbox({}) } - let(:resolve) { {:button_class => button_class} } - let(:button) { described_class.new(view_context, {}, {'resolve' => resolve}, {}) } - - describe '#disabled?' do - context 'when object attribute is specified' do - let(:button_class) { 'some_button_class' } - it_behaves_like 'an enabled button' - end - context 'when object attribute is not specified' do - let(:button_class) { nil } - it_behaves_like 'a disabled button', - 'Object attribute must be specified to copy object details for use in a Button' - end - end -end diff --git a/spec/views/shared/buttons/_ab_form.html.haml_spec.rb b/spec/views/shared/buttons/_ab_form.html.haml_spec.rb deleted file mode 100644 index 663090c9f85..00000000000 --- a/spec/views/shared/buttons/_ab_form.html.haml_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -describe "shared/buttons/_ab_form.html.haml" do - before do - set_controller_for_view("miq_ae_customization") - assign(:sb, :active_tab => "ab_options_tab") - assign(:edit, :new => {:target_class => "CloudNetwork"}) - assign(:resolve, :target_classes => [ - ["Availability Zone", "AvailabilityZone"], - ["Cloud Network", "CloudNetwork"], - ["VM Template and Image", "MiqTemplate"], - ["VM and Instance", "Vm"]]) - stub_template "shared/buttons/_ab_options_form.html.haml" => "" - stub_template "shared/buttons/_ab_advanced_form.html.haml" => "" - end - - describe "Paste button" do - it "is enabled if the copied target class is the same as the current target class" do - allow(view).to receive(:session) - .and_return(:resolve_object => {:new => {:target_class => "CloudNetwork"}}) - render :template => "shared/buttons/_ab_form" - expect(rendered).to include("Paste object details for use in a Button.") - end - - it "is disabled if the copied target class differs from the current target class" do - allow(view).to receive(:session) - .and_return(:resolve_object => {:new => {:target_class => "AvailabilityZone"}}) - render :template => "shared/buttons/_ab_form" - expect(rendered).to include("Paste is not available, target class differs from the target class of the object copied from the Simulation screen") - end - end -end