From b65700a86584c14308c71ce778f698cc24ac1995 Mon Sep 17 00:00:00 2001 From: Tatiana Ovchinnikova Date: Mon, 14 Sep 2020 15:57:51 -0500 Subject: [PATCH] Show project name at launch instance dialog It is easy enough to create instances in the wrong project. This patch displays project name at launch instance dialog. Closes-Bug: #1895588 Change-Id: Ied681bc3d1b4213bd6bacb3042b377ec2ac10855 --- .../launch-instance/details/details.controller.js | 11 +++++++++-- .../details/details.controller.spec.js | 10 ++++++++++ .../workflow/launch-instance/details/details.html | 6 ++++++ .../static/dashboard/scss/components/_forms.scss | 7 ++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.controller.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.controller.js index 29d5fc3f26..640af48e67 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.controller.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.controller.js @@ -33,13 +33,15 @@ '$scope', 'horizon.framework.widgets.charts.donutChartSettings', 'horizon.framework.widgets.charts.quotaChartDefaults', - 'horizon.app.core.openstack-service-api.nova' + 'horizon.app.core.openstack-service-api.nova', + 'horizon.app.core.openstack-service-api.userSession' ]; function LaunchInstanceDetailsController($scope, donutChartSettings, quotaChartDefaults, - novaAPI + novaAPI, + userSession ) { var ctrl = this; @@ -106,6 +108,11 @@ //////////////////// + userSession.get().then(setProject); + function setProject(session) { + ctrl.projectName = session.project_name; + } + function isDescriptionSupported(data) { ctrl.isDescriptionSupported = data.data; } diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.controller.spec.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.controller.spec.js index d25ee721ef..11d918b38e 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.controller.spec.js +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.controller.spec.js @@ -24,6 +24,7 @@ describe('LaunchInstanceDetailsController', function() { var $q, scope, ctrl, deferred; + var sessionObj = {project_name: 'alt_demo'}; var novaAPI = { isFeatureSupported: function() { var deferred = $q.defer(); @@ -43,6 +44,10 @@ $q = _$q_; deferred = $q.defer(); scope.initPromise = deferred.promise; + var session = $injector.get('horizon.app.core.openstack-service-api.userSession'); + var sessionDeferred = $q.defer(); + sessionDeferred.resolve(sessionObj); + spyOn(session, 'get').and.returnValue(sessionDeferred.promise); scope.model = { newInstanceSpec: { source: [], source_type: '' }, @@ -62,6 +67,11 @@ scope.$apply(); })); + it('sets ctrl.projectName', inject(function($timeout) { + $timeout.flush(); + expect(ctrl.projectName).toBe(sessionObj.project_name); + })); + it('should have isDescriptionSupported defined', function() { spyOn(novaAPI, 'isFeatureSupported').and.callFake(function () { var deferred = $q.defer(); diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.html b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.html index 31f2b0684e..849e805c2b 100644 --- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.html +++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/details/details.html @@ -4,6 +4,12 @@
+
+ + +
+