Add ability to copy the full SHA256 or V1ID for an image

Clicking the little (SHA256) or (V1ID) bubble next to the ID will now show a dialog with a copy box.
This commit is contained in:
Joseph Schorr 2017-10-25 14:56:59 -04:00
parent 514cd42eec
commit 86e4539c04
2 changed files with 54 additions and 14 deletions

View file

@ -13,7 +13,9 @@ angular.module('quay').directive('imageLink', function () {
'imageId': '=imageId',
'manifestDigest': '=?manifestDigest'
},
controller: function($scope, $element) {
controller: function($scope, $element, $timeout) {
$scope.showingCopyBox = false;
$scope.hasSHA256 = function(digest) {
return digest && digest.indexOf('sha256:') == 0;
};
@ -21,6 +23,24 @@ angular.module('quay').directive('imageLink', function () {
$scope.getShortDigest = function(digest) {
return digest.substr('sha256:'.length).substr(0, 12);
};
$scope.showCopyBox = function() {
$scope.showingCopyBox = true;
// Necessary to wait for digest cycle to complete.
$timeout(function() {
$element.find('.modal').modal('show');
}, 10);
};
$scope.hideCopyBox = function() {
$element.find('.modal').modal('hide');
// Wait for the modal to hide before removing from the DOM.
$timeout(function() {
$scope.showingCopyBox = false;
}, 10);
};
}
};
return directiveDefinitionObject;