From 3359245890064b72f2e23712383e34d206ac5280 Mon Sep 17 00:00:00 2001 From: Sergio Betanzos Date: Mon, 26 Apr 2021 17:31:31 +0200 Subject: [PATCH] M #~: Fix sunstone dialogs (#1148) (cherry picked from commit 5ed1b8e3769ebe6d97ece2ea4231fe634cf76fe3) --- src/sunstone/models/sunstone_guac.rb | 6 +- src/sunstone/public/app/sunstone.js | 26 ++++++-- .../public/app/tabs/vms-tab/actions.js | 65 ++++++++++--------- 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/src/sunstone/models/sunstone_guac.rb b/src/sunstone/models/sunstone_guac.rb index 63e4895a9e..34d1a568bc 100644 --- a/src/sunstone/models/sunstone_guac.rb +++ b/src/sunstone/models/sunstone_guac.rb @@ -206,7 +206,7 @@ class SunstoneGuac 'hostname' => hostname, 'port' => vm_resource['TEMPLATE/GRAPHICS/PORT'], 'password' => vm_resource['TEMPLATE/GRAPHICS/PASSWD'] - }.compact + } ) end @@ -232,7 +232,7 @@ class SunstoneGuac 'port' => vm_resource['TEMPLATE/CONTEXT/RDP_PORT'], 'username' => vm_resource['TEMPLATE/CONTEXT/USERNAME'], 'password' => vm_resource['TEMPLATE/CONTEXT/PASSWORD'] - }.compact + } ) end @@ -258,7 +258,7 @@ class SunstoneGuac 'port' => vm_resource['TEMPLATE/CONTEXT/SSH_PORT'], 'username' => vm_resource['TEMPLATE/CONTEXT/USERNAME'], 'password' => vm_resource['TEMPLATE/CONTEXT/PASSWORD'] - }.compact + } ) end diff --git a/src/sunstone/public/app/sunstone.js b/src/sunstone/public/app/sunstone.js index b2f9204bc3..ad80a11b7d 100644 --- a/src/sunstone/public/app/sunstone.js +++ b/src/sunstone/public/app/sunstone.js @@ -550,7 +550,10 @@ define(function(require) { //Listen for .action_buttons //An action buttons runs a predefined action. If it has type //"multiple" it runs that action on the elements of a datatable. - $(document).on("click", ".action_button", function() { + $(document).on("click", ".action_button", function(event) { + event.preventDefault(); + event.stopPropagation(); + var error = 0; var value = $(this).val(); var data = ($(this).attr("data") == "")? undefined: $(this).attr("data"); @@ -580,7 +583,10 @@ define(function(require) { //Listen .confirm_buttons. These buttons show a confirmation dialog //before running the action. - $(document).on("click", ".confirm_button", function() { + $(document).on("click", ".confirm_button", function(event) { + event.preventDefault(); + event.stopPropagation(); + var dialogInstance = _getDialogInstance(CONFIRM_DIALOG_ID); dialogInstance.reset(); $("#" + CONFIRM_DIALOG_ID).data("buttonAction", $(this).attr("href")); @@ -591,7 +597,10 @@ define(function(require) { //Listen .confirm_buttons. These buttons show a confirmation dialog //with a select box before running the action. - $(document).on("click", ".confirm_with_select_button", function() { + $(document).on("click", ".confirm_with_select_button", function(event) { + event.preventDefault(); + event.stopPropagation(); + var dialogInstance = _getDialogInstance(CONFIRM_WITH_SELECT_DIALOG_ID); dialogInstance.setParams({ @@ -608,16 +617,21 @@ define(function(require) { //$(document).foundation('dropdown', 'reflow'); // Button to return to the list view from the detailed view - $(document).on("click", "button[href='back']", function(e) { + $(document).on("click", "button[href='back']", function(event) { + event.preventDefault(); + event.stopPropagation(); + if(window.sunstoneNoMultipleRedirects){ window.history.back(); window.sunstoneNoMultipleRedirects = false; } - e.preventDefault(); }); // Reload foundation ips dropdown when change page on datatables - $(document).on("click", ".paginate_button", function() { + $(document).on("click", ".paginate_button", function(event) { + event.preventDefault(); + event.stopPropagation(); + UtilsFoundation.update(null); }); }; diff --git a/src/sunstone/public/app/tabs/vms-tab/actions.js b/src/sunstone/public/app/tabs/vms-tab/actions.js index e50362e9c6..9aeca3e12b 100644 --- a/src/sunstone/public/app/tabs/vms-tab/actions.js +++ b/src/sunstone/public/app/tabs/vms-tab/actions.js @@ -142,9 +142,9 @@ define(function(require) { "VM.deploy" : { type: "custom", call: function() { - Sunstone.getDialog(DEPLOY_DIALOG_ID) - .reset() - .show(); + var dialog = Sunstone.getDialog(DEPLOY_DIALOG_ID); + dialog.reset(); + dialog.show(); } }, "VM.silent_deploy_action" : { @@ -155,42 +155,42 @@ define(function(require) { "VM.migrate" : { type: "custom", call: function() { - Sunstone.getDialog(MIGRATE_DIALOG_ID) - .reset() - .setLive(false) - .setType(0) - .show(); - } + var dialog = Sunstone.getDialog(MIGRATE_DIALOG_ID); + dialog.reset(); + dialog.setLive(false); + dialog.setType(0); + dialog.show(); + } }, "VM.migrate_poff" : { type: "custom", call: function() { - Sunstone.getDialog(MIGRATE_DIALOG_ID) - .reset() - .setLive(false) - .setType(1) - .show(); - } + var dialog = Sunstone.getDialog(MIGRATE_DIALOG_ID); + dialog.reset(); + dialog.setLive(false); + dialog.setType(1); + dialog.show(); + } }, "VM.migrate_poff_hard" : { type: "custom", call: function() { - Sunstone.getDialog(MIGRATE_DIALOG_ID) - .reset() - .setLive(false) - .setType(2) - .show(); - } + var dialog = Sunstone.getDialog(MIGRATE_DIALOG_ID); + dialog.reset(); + dialog.setLive(false); + dialog.setType(2); + dialog.show(); + } }, "VM.migrate_live" : { type: "custom", call: function() { - Sunstone.getDialog(MIGRATE_DIALOG_ID) - .reset() - .setLive(true) - .setType(0) - .show(); - } + var dialog = Sunstone.getDialog(MIGRATE_DIALOG_ID); + dialog.reset(); + dialog.setLive(true); + dialog.setType(0); + dialog.show(); + } }, "VM.save_rdp" : { type: "custom", @@ -434,11 +434,12 @@ define(function(require) { id: resourceId }, success: function(_, vmTemplate){ - if (vmTemplate && - vmTemplate.VM && - vmTemplate.VM.USER_TEMPLATE && - vmTemplate.VM.USER_TEMPLATE.HYPERVISOR && - vmTemplate.VM.USER_TEMPLATE.HYPERVISOR !== "vcenter"){ + if ( + vmTemplate && + vmTemplate.VM && + vmTemplate.VM.USER_TEMPLATE && + vmTemplate.VM.USER_TEMPLATE.HYPERVISOR !== "vcenter" + ){ Sunstone.showTab(MARKETPLACEAPPS_TAB_ID); Sunstone.showFormPanel( MARKETPLACEAPPS_TAB_ID,