From 2c7ae7efc959020dbcc952ef38c09c38f5c60b75 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Mon, 30 Nov 2015 18:11:31 +0100 Subject: [PATCH] Show a toast with success on instance creation toast message was missing from new instance launch modal Change-Id: I956255a98e1f6e027181efe55da5f7366316249b Closes-Bug: #1512428 --- .../launch-instance-model.service.js | 14 +++++++++++--- .../launch-instance-model.service.spec.js | 10 +++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js index 521551a15f..3cdffb3bc6 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js @@ -26,7 +26,8 @@ 'horizon.app.core.openstack-service-api.nova', 'horizon.app.core.openstack-service-api.novaExtensions', 'horizon.app.core.openstack-service-api.security-group', - 'horizon.app.core.openstack-service-api.serviceCatalog' + 'horizon.app.core.openstack-service-api.serviceCatalog', + 'horizon.framework.widgets.toast.service' ]; /** @@ -51,7 +52,8 @@ novaAPI, novaExtensions, securityGroup, - serviceCatalog + serviceCatalog, + toast ) { var initPromise; @@ -245,7 +247,13 @@ setFinalSpecKeyPairs(finalSpec); setFinalSpecSecurityGroups(finalSpec); - return novaAPI.createServer(finalSpec); + return novaAPI.createServer(finalSpec).then(successMessage); + } + + function successMessage() { + var numberInstances = model.newInstanceSpec.instance_count; + var message = ngettext('Instance launched.', '%s instances launched.', numberInstances); + toast.add('success', interpolate(message, [numberInstances])); } function cleanNullProperties(finalSpec) { diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js index b90b7c7793..79d00a8f2e 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js @@ -55,7 +55,11 @@ $provide.value('horizon.app.core.openstack-service-api.nova', { createServer: function(finalSpec) { - return finalSpec; + return { + then: function () { + return finalSpec; + } + }; }, getAvailabilityZones: function() { var zones = [ @@ -172,6 +176,10 @@ }); $provide.value('horizon.app.core.openstack-service-api.keystone', {}); + + $provide.value('horizon.framework.widgets.toast.service', { + add: function() {} + }); })); beforeEach(inject(function(launchInstanceModel, $rootScope, _$q_) {