2015-03-16 18:17:27 +00:00
|
|
|
/**
|
|
|
|
* An element which displays the settings panel for a repository view.
|
|
|
|
*/
|
|
|
|
angular.module('quay').directive('repoPanelSettings', function () {
|
|
|
|
var directiveDefinitionObject = {
|
|
|
|
priority: 0,
|
|
|
|
templateUrl: '/static/directives/repo-view/repo-panel-settings.html',
|
|
|
|
replace: false,
|
|
|
|
transclude: false,
|
|
|
|
restrict: 'C',
|
|
|
|
scope: {
|
2015-05-06 22:16:03 +00:00
|
|
|
'repository': '=repository',
|
|
|
|
'isEnabled': '=isEnabled'
|
2015-03-16 18:17:27 +00:00
|
|
|
},
|
2015-03-16 21:03:26 +00:00
|
|
|
controller: function($scope, $element, ApiService, Config) {
|
2015-07-22 20:42:33 +00:00
|
|
|
$scope.deleteDialogCounter = 0;
|
|
|
|
|
2017-03-23 21:16:19 +00:00
|
|
|
var getTitle = function(repo) {
|
|
|
|
return repo.kind == 'application' ? 'application' : 'image';
|
|
|
|
};
|
|
|
|
|
2015-03-16 21:03:26 +00:00
|
|
|
$scope.getBadgeFormat = function(format, repository) {
|
|
|
|
if (!repository) { return ''; }
|
|
|
|
|
|
|
|
var imageUrl = Config.getUrl('/repository/' + repository.namespace + '/' + repository.name + '/status');
|
|
|
|
if (!$scope.repository.is_public) {
|
|
|
|
imageUrl += '?token=' + repository.status_token;
|
|
|
|
}
|
|
|
|
|
|
|
|
var linkUrl = Config.getUrl('/repository/' + repository.namespace + '/' + repository.name);
|
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case 'svg':
|
|
|
|
return imageUrl;
|
|
|
|
|
|
|
|
case 'md':
|
|
|
|
return '[![Docker Repository on ' + Config.REGISTRY_TITLE_SHORT + '](' + imageUrl +
|
|
|
|
' "Docker Repository on ' + Config.REGISTRY_TITLE_SHORT + '")](' + linkUrl + ')';
|
|
|
|
|
|
|
|
case 'asciidoc':
|
|
|
|
return 'image:' + imageUrl + '["Docker Repository on ' + Config.REGISTRY_TITLE_SHORT + '", link="' + linkUrl + '"]';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.askDelete = function() {
|
2015-07-22 20:42:33 +00:00
|
|
|
$scope.deleteDialogCounter++;
|
|
|
|
$scope.deleteRepoInfo = {
|
|
|
|
'counter': $scope.deleteDialogCounter
|
|
|
|
};
|
2015-03-16 21:03:26 +00:00
|
|
|
};
|
|
|
|
|
2015-07-22 20:42:33 +00:00
|
|
|
$scope.deleteRepo = function(info, callback) {
|
2015-03-16 21:03:26 +00:00
|
|
|
var params = {
|
|
|
|
'repository': $scope.repository.namespace + '/' + $scope.repository.name
|
|
|
|
};
|
|
|
|
|
2017-03-23 21:16:19 +00:00
|
|
|
var errorHandler = ApiService.errorDisplay(
|
|
|
|
'Could not delete ' + getTitle($scope.repository), callback);
|
2015-07-22 20:42:33 +00:00
|
|
|
|
2015-03-16 21:03:26 +00:00
|
|
|
ApiService.deleteRepository(null, params).then(function() {
|
2015-07-22 20:42:33 +00:00
|
|
|
callback(true);
|
2015-03-16 21:03:26 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
document.location = '/repository/';
|
|
|
|
}, 100);
|
2015-07-22 20:42:33 +00:00
|
|
|
}, errorHandler);
|
2015-03-16 21:03:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$scope.askChangeAccess = function(newAccess) {
|
2017-03-23 21:16:19 +00:00
|
|
|
var msg = 'Are you sure you want to make this ' + getTitle($scope.repository) + ' ' +
|
|
|
|
newAccess + '?';
|
|
|
|
|
|
|
|
bootbox.confirm(msg, function(r) {
|
2015-03-16 21:03:26 +00:00
|
|
|
if (!r) { return; }
|
|
|
|
$scope.changeAccess(newAccess);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.changeAccess = function(newAccess) {
|
|
|
|
var visibility = {
|
|
|
|
'visibility': newAccess
|
|
|
|
};
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
'repository': $scope.repository.namespace + '/' + $scope.repository.name
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.changeRepoVisibility(visibility, params).then(function() {
|
|
|
|
$scope.repository.is_public = newAccess == 'public';
|
2017-03-23 21:16:19 +00:00
|
|
|
}, ApiService.errorDisplay('Could not change visibility'));
|
2015-03-16 21:03:26 +00:00
|
|
|
};
|
2017-05-08 16:46:38 +00:00
|
|
|
|
|
|
|
$scope.signingWhitelisted = function(repository) {
|
|
|
|
return Config.SIGNING_NAMESPACE_WHITELIST.indexOf(repository.namespace) !== -1;
|
|
|
|
};
|
2015-03-16 18:17:27 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
return directiveDefinitionObject;
|
|
|
|
});
|
|
|
|
|