Redo UI of the tag history timeline and add restoration

This commit is contained in:
Joseph Schorr 2017-03-03 18:41:26 -05:00
parent e90cab4d77
commit 25db46c341
8 changed files with 256 additions and 90 deletions

View file

@ -125,7 +125,13 @@ angular.module('quay').directive('logsView', function () {
return 'Remove permission for token {token} from repository {namespace}/{repo}';
}
},
'revert_tag': 'Tag {tag} reverted to image {image} from image {original_image}',
'revert_tag': function(metadata) {
if (metadata.original_image) {
return 'Tag {tag} restored to image {image} from image {original_image}';
} else {
return 'Tag {tag} recreated pointing to image {image}';
}
},
'delete_tag': 'Tag {tag} deleted in repository {namespace}/{repo} by user {username}',
'create_tag': 'Tag {tag} created in repository {namespace}/{repo} on image {image} by user {username}',
'move_tag': 'Tag {tag} moved from image {original_image} to image {image} in repository {namespace}/{repo} by user {username}',
@ -266,7 +272,7 @@ angular.module('quay').directive('logsView', function () {
'delete_tag': 'Delete Tag',
'create_tag': 'Create Tag',
'move_tag': 'Move Tag',
'revert_tag':' Revert Tag',
'revert_tag':'Restore Tag',
'org_create_team': 'Create team',
'org_delete_team': 'Delete team',
'org_add_team_member': 'Add team member',

View file

@ -11,7 +11,8 @@ angular.module('quay').directive('repoTagHistory', function () {
scope: {
'repository': '=repository',
'filter': '=filter',
'isEnabled': '=isEnabled'
'isEnabled': '=isEnabled',
'imageLoader': '=imageLoader'
},
controller: function($scope, $element, ApiService) {
$scope.tagHistoryData = null;
@ -57,6 +58,7 @@ angular.module('quay').directive('repoTagHistory', function () {
var addEntry = function(action, time, opt_docker_id, opt_old_docker_id,
opt_manifest_digest, opt_old_manifest_digest) {
var entry = {
'tag': tag,
'tag_name': tagName,
'action': action,
'start_ts': tag.start_ts,
@ -66,7 +68,7 @@ angular.module('quay').directive('repoTagHistory', function () {
'docker_image_id': opt_docker_id || dockerImageId,
'old_docker_image_id': opt_old_docker_id || '',
'manifest_digest': opt_manifest_digest || manifestDigest,
'old_manifest_digest': opt_old_manifest_digest || ''
'old_manifest_digest': opt_old_manifest_digest || null
};
tagEntries[tagName].push(entry);
@ -92,7 +94,7 @@ angular.module('quay').directive('repoTagHistory', function () {
// If the tag has a start time, it was created.
if (tag.start_ts) {
addEntry('create', tag.start_ts);
addEntry(tag.reversion ? 'recreate' : 'create', tag.start_ts);
}
});
@ -139,6 +141,14 @@ angular.module('quay').directive('repoTagHistory', function () {
return $scope.historyEntryMap[entry.tag_name][0] == entry;
};
$scope.askRestoreTag = function(entity, use_current_id) {
if ($scope.repository.can_write) {
var docker_id = use_current_id ? entity.docker_image_id : entity.old_docker_image_id;
var digest = use_current_id ? entity.manifest_digest : entity.old_manifest_digest;
$scope.tagActionHandler.askRestoreTag(entity.tag, docker_id, digest);
}
};
$scope.getEntryClasses = function(entry, historyFilter) {
if (!entry.action) { return ''; }

View file

@ -115,7 +115,7 @@ angular.module('quay').directive('tagOperationsDialog', function () {
}, errorHandler);
};
$scope.revertTag = function(tag, image_id, callback) {
$scope.restoreTag = function(tag, image_id, opt_manifest_digest, callback) {
if (!$scope.repository.can_write) { return; }
var params = {
@ -127,8 +127,12 @@ angular.module('quay').directive('tagOperationsDialog', function () {
'image': image_id
};
var errorHandler = ApiService.errorDisplay('Cannot revert tag', callback);
ApiService.revertTag(data, params).then(function() {
if (opt_manifest_digest) {
data['manifest_digest'] = opt_manifest_digest;
}
var errorHandler = ApiService.errorDisplay('Cannot restore tag', callback);
ApiService.restoreTag(data, params).then(function() {
callback(true);
markChanged([], [tag]);
}, errorHandler);
@ -155,18 +159,19 @@ angular.module('quay').directive('tagOperationsDialog', function () {
$element.find('#createOrMoveTagModal').modal('show');
},
'askRevertTag': function(tag, image_id) {
'askRestoreTag': function(tag, image_id, opt_manifest_digest) {
if (tag.image_id == image_id) {
bootbox.alert('This is the current image for the tag');
return;
}
$scope.revertTagInfo = {
$scope.restoreTagInfo = {
'tag': tag,
'image_id': image_id
'image_id': image_id,
'manifest_digest': opt_manifest_digest
};
$element.find('#revertTagModal').modal('show');
$element.find('#restoreTagModal').modal('show');
}
};
}