Merge "Image panel: check instance create policy for 'Launch' button"

This commit is contained in:
Zuul 2018-06-04 10:06:48 +00:00 committed by Gerrit Code Review
commit e8af344c1b
2 changed files with 18 additions and 1 deletions

View File

@ -23,6 +23,7 @@
launchInstanceService.$inject = [
'$q',
'horizon.app.core.images.non_bootable_image_types',
'horizon.app.core.openstack-service-api.policy',
'horizon.dashboard.project.workflow.launch-instance.modal.service',
'horizon.framework.util.q.extensions'
];
@ -44,6 +45,7 @@
function launchInstanceService(
$q,
nonBootableImageTypes,
policy,
launchInstanceModal,
$qExtensions
) {
@ -66,7 +68,11 @@
}
function allowed(image) {
return $q.all([isBootable(image), isActive(image)]);
return $q.all([
isBootable(image),
isActive(image),
policy.ifAllowed({ rules: [['compute', 'compute:create']] })
]);
}
function isActive(image) {

View File

@ -22,6 +22,16 @@
open: function () {}
};
var policyAPI = {
ifAllowed: function() {
return {
success: function(callback) {
callback({allowed: true});
}
};
}
};
var service, $scope;
///////////////////////
@ -31,6 +41,7 @@
$provide.value(
'horizon.dashboard.project.workflow.launch-instance.modal.service', launchInstanceModalMock
);
$provide.value('horizon.app.core.openstack-service-api.policy', policyAPI);
}));
beforeEach(inject(function($injector, _$rootScope_) {