mirror of
https://github.com/portainer/portainer.git
synced 2025-08-09 07:45:22 +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:
parent
77e48bfb74
commit
f9f937f844
15 changed files with 226 additions and 202 deletions
|
@ -33,11 +33,6 @@ angular.module('portainer.app').factory('Endpoints', [
|
|||
params: { id: '@id', namespace: '@namespace' },
|
||||
isArray: true,
|
||||
},
|
||||
registry: {
|
||||
url: `${API_ENDPOINT_ENDPOINTS}/:id/registries/:registryId`,
|
||||
method: 'GET',
|
||||
params: { id: '@id', namespace: '@namespace', registryId: '@registryId' },
|
||||
},
|
||||
updateRegistryAccess: {
|
||||
method: 'PUT',
|
||||
url: `${API_ENDPOINT_ENDPOINTS}/:id/registries/:registryId`,
|
||||
|
|
|
@ -9,7 +9,6 @@ angular.module('portainer.app').factory('EndpointService', [
|
|||
var service = {
|
||||
updateSecuritySettings,
|
||||
registries,
|
||||
registry,
|
||||
updateRegistryAccess,
|
||||
};
|
||||
|
||||
|
@ -184,9 +183,5 @@ angular.module('portainer.app').factory('EndpointService', [
|
|||
function updateSecuritySettings(id, securitySettings) {
|
||||
return Endpoints.updateSecuritySettings({ id }, securitySettings).$promise;
|
||||
}
|
||||
|
||||
function registry(endpointId, registryId) {
|
||||
return Endpoints.registry({ registryId, id: endpointId }).$promise;
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
|
|
@ -50,10 +50,11 @@ angular.module('portainer.app').factory('RegistryGitlabService', [
|
|||
return repositories;
|
||||
}
|
||||
|
||||
async function repositoriesAsync(registry) {
|
||||
async function repositoriesAsync(registry, endpointId) {
|
||||
try {
|
||||
const params = {
|
||||
id: registry.Id,
|
||||
endpointId: endpointId,
|
||||
projectId: registry.Gitlab.ProjectId,
|
||||
page: 1,
|
||||
};
|
||||
|
@ -76,8 +77,8 @@ angular.module('portainer.app').factory('RegistryGitlabService', [
|
|||
return $async(projectsAsync, url, token);
|
||||
}
|
||||
|
||||
function repositories(registry) {
|
||||
return $async(repositoriesAsync, registry);
|
||||
function repositories(registry, endpointId) {
|
||||
return $async(repositoriesAsync, registry, endpointId);
|
||||
}
|
||||
|
||||
service.projects = projects;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<i class="fa fa-sync" aria-hidden="true"></i>
|
||||
</a>
|
||||
</rd-header-title>
|
||||
<rd-header-content>Manage registry access inside this environment</rd-header-content>
|
||||
<rd-header-content>Registry management</rd-header-content>
|
||||
</rd-header>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
|
@ -16,6 +16,7 @@
|
|||
order-by="Name"
|
||||
endpoint-type="$ctrl.endpointType"
|
||||
can-manage-access="$ctrl.canManageAccess"
|
||||
can-browse="$ctrl.canBrowse"
|
||||
></registries-datatable>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,24 +1,30 @@
|
|||
import _ from 'lodash-es';
|
||||
import { RegistryTypes } from 'Portainer/models/registryTypes';
|
||||
|
||||
class EndpointRegistriesController {
|
||||
/* @ngInject */
|
||||
constructor($async, Notifications, EndpointService) {
|
||||
constructor($async, Notifications, EndpointService, Authentication) {
|
||||
this.$async = $async;
|
||||
this.Notifications = Notifications;
|
||||
this.EndpointService = EndpointService;
|
||||
this.Authentication = Authentication;
|
||||
|
||||
this.canManageAccess = this.canManageAccess.bind(this);
|
||||
this.canBrowse = this.canBrowse.bind(this);
|
||||
}
|
||||
|
||||
canManageAccess(item) {
|
||||
return item.Type !== RegistryTypes.ANONYMOUS;
|
||||
return item.Type !== RegistryTypes.ANONYMOUS && this.Authentication.isAdmin();
|
||||
}
|
||||
|
||||
canBrowse(item) {
|
||||
return !_.includes([RegistryTypes.ANONYMOUS, RegistryTypes.DOCKERHUB, RegistryTypes.QUAY], item.Type);
|
||||
}
|
||||
|
||||
getRegistries() {
|
||||
return this.$async(async () => {
|
||||
try {
|
||||
const registries = await this.EndpointService.registries(this.endpointId);
|
||||
this.registries = registries;
|
||||
this.registries = await this.EndpointService.registries(this.endpointId);
|
||||
} catch (err) {
|
||||
this.Notifications.error('Failure', err, 'Unable to retrieve registries');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue