1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

feat(registries): Registry browser for non-admins [EE-2459] (#6549)

* feat(registries): allow non-admin users to see environment registries

* remove unused function

* fix error message

* fix test

* fix imports order

* feat(registry): check access first, add parameters name

* use registryID

* fix(sidebar): allow standard users to see endpoint registries view

Co-authored-by: LP B <xAt0mZ@users.noreply.github.com>
This commit is contained in:
Marcelo Rydel 2022-04-07 10:22:31 -03:00 committed by GitHub
parent 77e48bfb74
commit f9f937f844
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 226 additions and 202 deletions

View file

@ -71,25 +71,24 @@
children-paths="['kubernetes.cluster', 'portainer.k8sendpoint.kubernetesConfig', 'kubernetes.registries', 'kubernetes.registries.access']"
data-cy="k8sSidebar-cluster"
>
<div ng-if="$ctrl.adminAccess">
<sidebar-menu-item
authorization="K8sClusterSetupRW"
path="portainer.k8sendpoint.kubernetesConfig"
path-params="{ id: $ctrl.endpointId }"
class-name="sidebar-sublist"
data-cy="k8sSidebar-setup"
>
Setup
</sidebar-menu-item>
<sidebar-menu-item
ng-if="$ctrl.adminAccess"
authorization="K8sClusterSetupRW"
path="portainer.k8sendpoint.kubernetesConfig"
path-params="{ id: $ctrl.endpointId }"
class-name="sidebar-sublist"
data-cy="k8sSidebar-setup"
>
Setup
</sidebar-menu-item>
<sidebar-menu-item
authorization="PortainerRegistryList"
path="kubernetes.registries"
path-params="{ endpointId: $ctrl.endpointId }"
class-name="sidebar-sublist"
data-cy="k8sSidebar-registries"
>
Registries
</sidebar-menu-item>
</div>
<sidebar-menu-item
authorization="PortainerRegistryList"
path="kubernetes.registries"
path-params="{ endpointId: $ctrl.endpointId }"
class-name="sidebar-sublist"
data-cy="k8sSidebar-registries"
>
Registries
</sidebar-menu-item>
</sidebar-menu>

View file

@ -2,12 +2,13 @@ import KubernetesNamespaceHelper from 'Kubernetes/helpers/namespaceHelper';
export default class KubernetesRegistryAccessController {
/* @ngInject */
constructor($async, $state, ModalService, EndpointService, Notifications, KubernetesResourcePoolService) {
constructor($async, $state, ModalService, EndpointService, Notifications, RegistryService, KubernetesResourcePoolService) {
this.$async = $async;
this.$state = $state;
this.ModalService = ModalService;
this.Notifications = Notifications;
this.KubernetesResourcePoolService = KubernetesResourcePoolService;
this.RegistryService = RegistryService;
this.EndpointService = EndpointService;
this.state = {
@ -57,7 +58,7 @@ export default class KubernetesRegistryAccessController {
this.state = {
registryId: this.$state.params.id,
};
this.registry = await this.EndpointService.registry(this.endpoint.Id, this.state.registryId);
this.registry = await this.RegistryService.registry(this.state.registryId, this.endpoint.Id);
if (this.registry.RegistryAccesses && this.registry.RegistryAccesses[this.endpoint.Id]) {
this.savedResourcePools = this.registry.RegistryAccesses[this.endpoint.Id].Namespaces.map((value) => ({ value }));
}