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

Fix for dialog loading issue and wrong redirect #3298

Merged
merged 2 commits into from Jan 22, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/vm_common.rb
Expand Up @@ -27,7 +27,8 @@ def button

case params[:pressed]
when 'custom_button'
custom_buttons
cancel_endpoint = "/#{params[:controller]}/explorer"
custom_buttons(nil, :cancel_endpoint => cancel_endpoint)
return
when 'perf_reload'
perf_chart_chooser
Expand Down
2 changes: 1 addition & 1 deletion app/services/dialog_local_service.rb
Expand Up @@ -91,7 +91,7 @@ def determine_api_endpoints(obj, display_options = {})
cancel_endpoint = "/storage/explorer"
when /Vm/
api_collection_name = "vms"
cancel_endpoint = "/vm_infra/explorer"
cancel_endpoint = display_options[:cancel_endpoint] || "/vm_infra/explorer"
end

submit_endpoint = "/api/#{api_collection_name}/#{obj.id}"
Expand Down
2 changes: 2 additions & 0 deletions app/views/shared/dialogs/_dialog_user.html.haml
@@ -1,4 +1,6 @@
.row.wrapper{"ng-controller" => "dialogUserController as vm"}
.spinner{'ng-show' => "!vm.dialogLoaded"}

.col-md-12.col-lg-12{'ng-if' => 'vm.dialog'}
%dialog-user{"dialog" =>"vm.dialog", "refresh-field" => "vm.refreshField(field)", "on-update" => "vm.setDialogData(data)"}

Expand Down
47 changes: 34 additions & 13 deletions spec/services/dialog_local_service_spec.rb
Expand Up @@ -222,20 +222,41 @@
end

context "when the object is a Vm" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::InfraManager::Vm, :id => 123) }
context "when there is a cancel endpoint in the display options" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::InfraManager::Vm, :id => 123) }
let(:display_options) { {:cancel_endpoint => "/vm_cloud/explorer"} }

it "returns a hash" do
expect(service.determine_dialog_locals_for_custom_button(obj, button_name, resource_action)).to eq(
:resource_action_id => 321,
:target_id => 123,
:target_type => 'vm',
:dialog_id => 654,
:force_old_dialog_use => false,
:api_submit_endpoint => "/api/vms/123",
:api_action => "custom-button-name",
:finish_submit_endpoint => "/vm_infra/explorer",
:cancel_endpoint => "/vm_infra/explorer"
)
it "returns a hash" do
expect(service.determine_dialog_locals_for_custom_button(obj, button_name, resource_action, display_options)).to eq(
:resource_action_id => 321,
:target_id => 123,
:target_type => 'vm',
:dialog_id => 654,
:force_old_dialog_use => false,
:api_submit_endpoint => "/api/vms/123",
:api_action => "custom-button-name",
:finish_submit_endpoint => "/vm_cloud/explorer",
:cancel_endpoint => "/vm_cloud/explorer"
)
end
end

context "when there is not a cancel endpoint in the display options" do
let(:obj) { double(:class => ManageIQ::Providers::Vmware::InfraManager::Vm, :id => 123) }

it "returns a hash" do
expect(service.determine_dialog_locals_for_custom_button(obj, button_name, resource_action)).to eq(
:resource_action_id => 321,
:target_id => 123,
:target_type => 'vm',
:dialog_id => 654,
:force_old_dialog_use => false,
:api_submit_endpoint => "/api/vms/123",
:api_action => "custom-button-name",
:finish_submit_endpoint => "/vm_infra/explorer",
:cancel_endpoint => "/vm_infra/explorer"
)
end
end
end

Expand Down