Merge "Show project name at launch instance dialog"

This commit is contained in:
Zuul 2021-01-20 20:39:43 +00:00 committed by Gerrit Code Review
commit 29260bbf13
4 changed files with 31 additions and 3 deletions

View File

@ -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;
}

View File

@ -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();

View File

@ -4,6 +4,12 @@
<div class="row">
<div class="col-xs-12 col-sm-8">
<div class="form-group">
<label class="control-label" translate for="project_name">Project Name</label>
<input id="project_name" name="project_name" type="text" class="form-control themable-disabled"
disabled="disabled" value="{$ ctrl.projectName $}">
</div>
<div class="form-group"
ng-class="{ 'has-error': launchInstanceDetailsForm.name.$invalid && launchInstanceDetailsForm.name.$dirty }">
<label for="name" class="control-label">

View File

@ -20,5 +20,10 @@
.themable-checkbox {
padding-top: $padding-base-vertical;
}
}
.form-control {
&.themable-disabled {
background-color: $input-bg;
}
}