Merge "Only show the image visibility option if it's allowed"

This commit is contained in:
Jenkins 2017-07-06 07:34:38 +00:00 committed by Gerrit Code Review
commit 72d1bcdd0f
5 changed files with 27 additions and 5 deletions

View File

@ -27,7 +27,8 @@
'horizon.app.core.images.events',
'horizon.app.core.images.imageFormats',
'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,
imageFormats,
validationRules,
settings
settings,
policyAPI
) {
var ctrl = this;
@ -52,6 +54,7 @@
ctrl.diskFormats = [];
ctrl.prepareUpload = prepareUpload;
ctrl.apiVersion = 0;
ctrl.allowPublicizeImage = true;
ctrl.image = {
source_type: '',
@ -149,6 +152,13 @@
function init() {
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) {

View File

@ -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');
spyOn(glanceAPI, 'getImages').and.callFake(fakeGlance);
policyAPI = $injector.get('horizon.app.core.openstack-service-api.policy');
spyOn(policyAPI, 'ifAllowed').and.callFake(policyIfAllowed);
}));
function createController() {

View File

@ -221,7 +221,7 @@
<div class="selected-source">
<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">
<label class="control-label required">
<translate>Visibility</translate>

View File

@ -57,6 +57,7 @@
];
ctrl.setFormats = setFormats;
ctrl.allowPublicizeImage = { rules: [['image', 'image:publicize_image']]};
$scope.imagePromise.then(init);

View File

@ -113,7 +113,7 @@
<div class="selected-source clearfix">
<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">
<label class="control-label required" translate>Visibility</label>
<div class="form-field">