Only show the image visibility option if it's allowed
The visibility field on create image modal and edit image
modal should be shown if it's allowed based on the
glance policy.
Change-Id: I36f1b1c6e93c5ce06873f6a5f6106d8759fac6d0
Closes-bug: #1698490
(cherry picked from commit 932511031f
)
This commit is contained in:
parent
784f080a59
commit
21ce07a9ed
|
@ -27,7 +27,8 @@
|
||||||
'horizon.app.core.images.events',
|
'horizon.app.core.images.events',
|
||||||
'horizon.app.core.images.imageFormats',
|
'horizon.app.core.images.imageFormats',
|
||||||
'horizon.app.core.images.validationRules',
|
'horizon.app.core.images.validationRules',
|
||||||
'horizon.app.core.openstack-service-api.settings'
|
'horizon.app.core.openstack-service-api.settings',
|
||||||
|
'horizon.app.core.openstack-service-api.policy'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +43,8 @@
|
||||||
events,
|
events,
|
||||||
imageFormats,
|
imageFormats,
|
||||||
validationRules,
|
validationRules,
|
||||||
settings
|
settings,
|
||||||
|
policyAPI
|
||||||
) {
|
) {
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
|
@ -52,6 +54,7 @@
|
||||||
ctrl.diskFormats = [];
|
ctrl.diskFormats = [];
|
||||||
ctrl.prepareUpload = prepareUpload;
|
ctrl.prepareUpload = prepareUpload;
|
||||||
ctrl.apiVersion = 0;
|
ctrl.apiVersion = 0;
|
||||||
|
ctrl.allowPublicizeImage = true;
|
||||||
|
|
||||||
ctrl.image = {
|
ctrl.image = {
|
||||||
source_type: '',
|
source_type: '',
|
||||||
|
@ -149,6 +152,13 @@
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
glance.getImages({paginate: false}).success(onGetImages);
|
glance.getImages({paginate: false}).success(onGetImages);
|
||||||
|
policyAPI.ifAllowed({rules: [['image', 'publicize_image']]}).then(
|
||||||
|
angular.noop,
|
||||||
|
function () {
|
||||||
|
ctrl.image.visibility = "private";
|
||||||
|
ctrl.allowPublicizeImage = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onGetImages(response) {
|
function onGetImages(response) {
|
||||||
|
|
|
@ -32,7 +32,15 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var controller, glanceAPI, $scope, events, $q, settingsCall, $timeout;
|
function policyIfAllowed() {
|
||||||
|
return {
|
||||||
|
then: function(callback) {
|
||||||
|
callback({allowed: true});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var controller, glanceAPI, $scope, events, $q, settingsCall, $timeout, policyAPI;
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
|
|
||||||
|
@ -50,6 +58,9 @@
|
||||||
controller = $injector.get('$controller');
|
controller = $injector.get('$controller');
|
||||||
|
|
||||||
spyOn(glanceAPI, 'getImages').and.callFake(fakeGlance);
|
spyOn(glanceAPI, 'getImages').and.callFake(fakeGlance);
|
||||||
|
|
||||||
|
policyAPI = $injector.get('horizon.app.core.openstack-service-api.policy');
|
||||||
|
spyOn(policyAPI, 'ifAllowed').and.callFake(policyIfAllowed);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function createController() {
|
function createController() {
|
||||||
|
|
|
@ -221,7 +221,7 @@
|
||||||
|
|
||||||
<div class="selected-source">
|
<div class="selected-source">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6 col-sm-6">
|
<div class="col-xs-6 col-sm-6" ng-show='ctrl.allowPublicizeImage'>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label required">
|
<label class="control-label required">
|
||||||
<translate>Visibility</translate>
|
<translate>Visibility</translate>
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
ctrl.setFormats = setFormats;
|
ctrl.setFormats = setFormats;
|
||||||
|
ctrl.allowPublicizeImage = { rules: [['image', 'image:publicize_image']]};
|
||||||
|
|
||||||
$scope.imagePromise.then(init);
|
$scope.imagePromise.then(init);
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
|
|
||||||
<div class="selected-source clearfix">
|
<div class="selected-source clearfix">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-6 col-sm-6">
|
<div class="col-xs-6 col-sm-6" hz-if-policies="ctrl.allowPublicizeImage">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label required" translate>Visibility</label>
|
<label class="control-label required" translate>Visibility</label>
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
|
|
Loading…
Reference in New Issue