diff --git a/horizon/static/framework/widgets/modal/simple-modal.html b/horizon/static/framework/widgets/modal/simple-modal.html index e35b74590e..3e9eed2895 100644 --- a/horizon/static/framework/widgets/modal/simple-modal.html +++ b/horizon/static/framework/widgets/modal/simple-modal.html @@ -14,8 +14,8 @@ type="button" ng-click="modalCtrl.cancel()"> - - \ No newline at end of file + diff --git a/horizon/static/framework/widgets/modal/simple-modal.service.js b/horizon/static/framework/widgets/modal/simple-modal.service.js index c158f017fb..b38de94007 100644 --- a/horizon/static/framework/widgets/modal/simple-modal.service.js +++ b/horizon/static/framework/widgets/modal/simple-modal.service.js @@ -79,7 +79,8 @@ title: params.title, body: params.body, submit: params.submit || gettext('Submit'), - cancel: params.cancel || gettext('Cancel') + cancel: params.cancel || gettext('Cancel'), + confirmCssClass: params.confirmCssClass || "btn-primary" }; } } diff --git a/horizon/static/horizon/js/horizon.modals.js b/horizon/static/horizon/js/horizon.modals.js index 385080f197..0cb2b34cea 100644 --- a/horizon/static/horizon/js/horizon.modals.js +++ b/horizon/static/horizon/js/horizon.modals.js @@ -43,13 +43,17 @@ horizon.modals.initModal = function (modal) { }; /* Creates a modal dialog from the client-side template. */ -horizon.modals.create = function (title, body, confirm, cancel) { +horizon.modals.create = function (title, body, confirm, cancel, confirmCssClass) { if (!cancel) { cancel = gettext("Cancel"); } var template = horizon.templates.compiled_templates["#modal_template"], params = { - title: title, body: body, confirm: confirm, cancel: cancel, + title: title, + body: body, + confirm: confirm, + cancel: cancel, + confirmCssClass: confirmCssClass || "btn-primary", modal_backdrop: horizon.modals.MODAL_BACKDROP }; return $(template.render(params)).appendTo("#modal_wrapper"); diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js index d86b3970a0..6796072f20 100644 --- a/horizon/static/horizon/js/horizon.tables.js +++ b/horizon/static/horizon/js/horizon.tables.js @@ -318,8 +318,9 @@ horizon.datatables.confirm = function(action) { } catch (e) { body = name_string + gettext("Please confirm your selection. ") + help_text; } - - var modal = horizon.modals.create(title, body, action_string); + var actionNode = action.nodeType ? action: action[0]; + var confirmCssClass = actionNode.className.indexOf("btn-danger") >= 0 ? "btn-danger" : "btn-primary"; + var modal = horizon.modals.create(title, body, action_string, "", confirmCssClass); modal.modal(); if ($uibModal_parent.length) { @@ -329,7 +330,7 @@ horizon.datatables.confirm = function(action) { modal.css('z-index', child_backdrop.css('z-index')+10); } - modal.find('.btn-primary').click(function () { + modal.find('.' + confirmCssClass).click(function () { var $form = $action.closest('form'); var el = document.createElement("input"); el.type = 'hidden'; diff --git a/horizon/templates/horizon/client_side/_modal.html b/horizon/templates/horizon/client_side/_modal.html index 28e58f5e07..8560e076eb 100644 --- a/horizon/templates/horizon/client_side/_modal.html +++ b/horizon/templates/horizon/client_side/_modal.html @@ -18,7 +18,7 @@ diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers.controller.js b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers.controller.js index 2863800c10..6feab36a0c 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers.controller.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/containers.controller.js @@ -137,8 +137,9 @@ body: interpolate( gettext('Are you sure you want to delete container %(name)s?'), container, true ), - submit: gettext('Yes'), - cancel: gettext('No') + submit: gettext('Delete'), + cancel: gettext('Cancel'), + confirmCssClass: "btn-danger" }; simpleModalService.modal(options).result.then(function confirmed() { diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/delete-objects-modal.html b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/delete-objects-modal.html index 5c217ba282..25bb0dc2ee 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/containers/delete-objects-modal.html +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/containers/delete-objects-modal.html @@ -32,7 +32,7 @@ Cancel - diff --git a/openstack_dashboard/test/integration_tests/regions/forms.py b/openstack_dashboard/test/integration_tests/regions/forms.py index b7afbbf576..dad1b41550 100644 --- a/openstack_dashboard/test/integration_tests/regions/forms.py +++ b/openstack_dashboard/test/integration_tests/regions/forms.py @@ -283,6 +283,7 @@ class BaseFormRegion(baseregion.BaseRegion): """Base class for forms.""" _submit_locator = (by.By.CSS_SELECTOR, '*.btn.btn-primary') + _submit_danger_locator = (by.By.CSS_SELECTOR, '*.btn.btn-danger') _cancel_locator = (by.By.CSS_SELECTOR, '*.btn.cancel') _default_form_locator = (by.By.CSS_SELECTOR, 'div.modal-dialog') @@ -298,7 +299,11 @@ class BaseFormRegion(baseregion.BaseRegion): @property def _submit_element(self): - return self._get_element(*self._submit_locator) + try: + submit_element = self._get_element(*self._submit_locator) + except exceptions.NoSuchElementException: + submit_element = self._get_element(*self._submit_danger_locator) + return submit_element def submit(self): self._submit_element.click()