mirror of
https://github.com/portainer/portainer.git
synced 2025-07-29 02:09:41 +02:00
feat(settings): introduce disable stack management setting (#4100)
* feat(stacks): add a setting to disable the creation of stacks for non-admin users * feat(settings): introduce a setting to prevent non-admin from stack creation * feat(settings): update stack creation setting * feat(settings): fail stack creation if user is non admin * fix(settings): save preventStackCreation setting to state * feat(stacks): disable add button when settings is enabled * format(stacks): remove line * feat(stacks): setting to hide stacks from users * feat(settings): rename disable stacks setting * refactor(settings): rename setting to disableStackManagementForRegularUsers * feat(settings): hide stacks for non admin when settings is set * refactor(settings): replace disableDeviceMapping with allow * feat(dashboard): hide stacks if settings disabled and non admin * refactor(sidebar): check if user is endpoint admin * feat(settings): set the default value for stack management * feat(settings): rename field label * fix(sidebar): refresh show stacks state * fix(docker): hide stacks when not admin
This commit is contained in:
parent
07efd4bdda
commit
fa9eeaf3b1
21 changed files with 264 additions and 147 deletions
|
@ -1,6 +1,7 @@
|
|||
angular.module('portainer.docker').controller('DashboardController', [
|
||||
'$scope',
|
||||
'$q',
|
||||
'Authentication',
|
||||
'ContainerService',
|
||||
'ImageService',
|
||||
'NetworkService',
|
||||
|
@ -11,10 +12,12 @@ angular.module('portainer.docker').controller('DashboardController', [
|
|||
'EndpointService',
|
||||
'Notifications',
|
||||
'EndpointProvider',
|
||||
'ExtensionService',
|
||||
'StateManager',
|
||||
function (
|
||||
$scope,
|
||||
$q,
|
||||
Authentication,
|
||||
ContainerService,
|
||||
ImageService,
|
||||
NetworkService,
|
||||
|
@ -25,6 +28,7 @@ angular.module('portainer.docker').controller('DashboardController', [
|
|||
EndpointService,
|
||||
Notifications,
|
||||
EndpointProvider,
|
||||
ExtensionService,
|
||||
StateManager
|
||||
) {
|
||||
$scope.dismissInformationPanel = function (id) {
|
||||
|
@ -32,12 +36,15 @@ angular.module('portainer.docker').controller('DashboardController', [
|
|||
};
|
||||
|
||||
$scope.offlineMode = false;
|
||||
$scope.showStacks = false;
|
||||
|
||||
function initView() {
|
||||
async function initView() {
|
||||
const endpointMode = $scope.applicationState.endpoint.mode;
|
||||
const endpointId = EndpointProvider.endpointID();
|
||||
$scope.endpointId = endpointId;
|
||||
|
||||
$scope.showStacks = await shouldShowStacks();
|
||||
|
||||
$q.all({
|
||||
containers: ContainerService.containers(1),
|
||||
images: ImageService.images(false),
|
||||
|
@ -64,6 +71,19 @@ angular.module('portainer.docker').controller('DashboardController', [
|
|||
});
|
||||
}
|
||||
|
||||
async function shouldShowStacks() {
|
||||
const isAdmin = Authentication.isAdmin();
|
||||
const { allowStackManagementForRegularUsers } = $scope.applicationState.application;
|
||||
|
||||
if (isAdmin || allowStackManagementForRegularUsers) {
|
||||
return true;
|
||||
}
|
||||
const rbacEnabled = await ExtensionService.extensionEnabled(ExtensionService.EXTENSIONS.RBAC);
|
||||
if (rbacEnabled) {
|
||||
return Authentication.hasAuthorizations(['EndpointResourcesAccess']);
|
||||
}
|
||||
}
|
||||
|
||||
initView();
|
||||
},
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue