Merge "Image panel: check instance create policy for 'Launch' button"
This commit is contained in:
commit
e8af344c1b
@ -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) {
|
||||
|
@ -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_) {
|
||||
|
Loading…
Reference in New Issue
Block a user