Skip to content

Commit

Permalink
Display Submit,Cancel button for Evacuate Instances in a nested list
Browse files Browse the repository at this point in the history
Issue: ManageIQ#6480

Remove %div_for_paging, render angular 'custom_form_buttons_controller_as' partial for buttons
which works for both explorer and non-explorer screens, hide form_buttons_div and paging_div.
Redirect to proper screen after evacuating Instances in a nested list.
  • Loading branch information
Hilda Stastna committed Mar 27, 2020
1 parent 0938c2c commit 435800b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function vmCloudEvacuateFormController($http, $scope, miqService) {
vm.hosts = [];
vm.formId = vm.recordId;
vm.modelCopy = angular.copy(vm.vmCloudModel);
vm.newRecord = true;
vm.saveable = miqService.saveable;

ManageIQ.angular.scope = $scope;
$scope.saveable = miqService.saveable;
Expand Down
1 change: 1 addition & 0 deletions app/controllers/mixins/actions/vm_actions/evacuate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def evacuate_vm

@sb[:action] = nil
if @sb[:explorer]
@sb[:explorer] = nil
replace_right_cell
else
flash_to_session
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/vm_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ def replace_right_cell(options = {})
presenter.update(:form_buttons_div, '')
presenter.remove_paging.hide(:form_buttons_div)
end
elsif %w[attach detach live_migrate resize evacuate ownership add_security_group remove_security_group
elsif %w[attach detach live_migrate resize ownership add_security_group remove_security_group
associate_floating_ip disassociate_floating_ip].include?(@sb[:action])
presenter.update(:form_buttons_div, r[:partial => "layouts/angular/paging_div_buttons"])
elsif %w[reconfigure_update retire].exclude?(action) && !hide_x_edit_buttons(action)
Expand All @@ -1247,7 +1247,12 @@ def replace_right_cell(options = {})
# evm_relationship_update uses React form and buttons
presenter.hide(:form_buttons_div) if action == "evm_relationship_update"
end
presenter.show(:paging_div)

if %w[evacuate].include?(@sb[:action])
presenter.hide(:form_buttons_div, :paging_div)
else
presenter.show(:paging_div)
end
else
presenter.hide(:paging_div)
end
Expand Down
6 changes: 2 additions & 4 deletions app/views/static/evacuate-form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,5 @@
%select{:name => 'destination_host',
'ng-model' => 'vm.vmCloudModel.host',
'ng-options' => 'host.name as host.name for host in vm.hosts track by host.id'}
%div_for_paging{'ng-controller' => "pagingDivButtonGroupController",
'paging_div_buttons_state_enabled' => true,
'paging_div_buttons_id' => "angular_paging_div_buttons",
'paging_div_buttons_type' => "Submit"}
.clearfix
= render :partial => 'layouts/angular/custom_form_buttons_controller_as', :locals => {:button_label => 'Submit', :button_click => 'vm.submitClicked()'}
17 changes: 17 additions & 0 deletions spec/controllers/mixins/actions/vm_actions/evacuate_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
describe Mixins::Actions::VmActions::Evacuate do
describe '#evacuate_vm' do
let(:controller) { VmCloudController.new }

before do
allow(controller).to receive(:assert_privileges)
allow(controller).to receive(:replace_right_cell)
controller.instance_variable_set(:@sb, :explorer => true)
controller.params = {}
end

it 'sets @sb[:explorer] back to nil after canceling/submitting evacuating selected Instances' do
controller.send(:evacuate_vm)
expect(controller.instance_variable_get(:@sb)[:explorer]).to be_nil
end
end
end

0 comments on commit 435800b

Please sign in to comment.