feat(registry): disable browse for quay.io registry (#2971)

* feat(registry): disable browse for quay.io registry

* refactor(registry): browsable urls check done with function
pull/2981/head
xAt0mZ 2019-07-03 00:33:46 +02:00 committed by GitHub
parent 1138fd5ab1
commit 3d4af7c54f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 3 deletions

View File

@ -62,10 +62,10 @@
<a ui-sref="portainer.registries.registry.access({id: item.Id})" ng-if="$ctrl.accessManagement">
<i class="fa fa-users" aria-hidden="true"></i> Manage access
</a>
<a ui-sref="portainer.registries.registry.repositories({id: item.Id})" ng-if="$ctrl.registryManagement" class="space-left">
<a ui-sref="portainer.registries.registry.repositories({id: item.Id})" ng-if="$ctrl.registryManagement && $ctrl.canBrowse(item)" class="space-left">
<i class="fa fa-search" aria-hidden="true"></i> Browse
</a>
<a ui-sref="portainer.extensions.extension({id: 1})" ng-if="!$ctrl.registryManagement" class="space-left" style="color: #767676" tooltip-append-to-body="true" tooltip-placement="bottom" tooltip-class="portainer-tooltip" uib-tooltip="Feature available via an extension">
<a ui-sref="portainer.extensions.extension({id: 1})" ng-if="!$ctrl.registryManagement && $ctrl.canBrowse(item)" class="space-left" style="color: #767676" tooltip-append-to-body="true" tooltip-placement="bottom" tooltip-class="portainer-tooltip" uib-tooltip="Feature available via an extension">
<i class="fa fa-search" aria-hidden="true"></i> Browse (extension)
</a>
</td>

View File

@ -10,6 +10,7 @@ angular.module('portainer.app').component('registriesDatatable', {
reverseOrder: '<',
accessManagement: '<',
removeAction: '<',
registryManagement: '<'
registryManagement: '<',
canBrowse: '<'
}
});

View File

@ -77,6 +77,7 @@
access-management="applicationState.application.authentication && isAdmin"
remove-action="removeAction"
registry-management="registryManagementAvailable"
can-browse="canBrowse"
></registries-datatable>
</div>
</div>

View File

@ -1,3 +1,5 @@
import _ from 'lodash-es';
angular.module('portainer.app')
.controller('RegistriesController', ['$q', '$scope', '$state', 'RegistryService', 'DockerHubService', 'ModalService', 'Notifications', 'ExtensionService', 'Authentication',
function ($q, $scope, $state, RegistryService, DockerHubService, ModalService, Notifications, ExtensionService, Authentication) {
@ -10,6 +12,12 @@ function ($q, $scope, $state, RegistryService, DockerHubService, ModalService, N
dockerHubPassword: ''
};
const nonBrowsableUrls = ['quay.io'];
$scope.canBrowse = function(item) {
return ! _.includes(nonBrowsableUrls, item.URL);
}
$scope.updateDockerHub = function() {
var dockerhub = $scope.dockerhub;
dockerhub.Password = $scope.formValues.dockerHubPassword;