fix(registry-manager): fix an issue when removing all tags of a repository (#2545)

* fix repository reload got error in remove tags

When I remove all tags, removeTags() will reload and do initView() again, but data.tags response null, that trigger data.tags.length got error.

* Revert "fix repository reload got error in remove tags"

This reverts commit 5d9b1778ef.

* fix(registry-management): change response repository tags type to array by force

* feat(registry-management): redirect to repositories page when no tag in the repository after delete tags
pull/2632/head
hiyao 2019-01-18 03:01:47 +08:00 committed by Anthony Lapenna
parent 50e77d2bf1
commit a33eca4bbb
1 changed files with 12 additions and 4 deletions

View File

@ -81,9 +81,17 @@ angular.module('portainer.app')
});
return $q.all(promises);
})
.then(function success() {
.then(function success(data) {
Notifications.success('Success', 'Tags successfully deleted');
$state.reload();
if (data.length === 0) {
$state.go('portainer.registries.registry.repositories', {
id: $scope.registryId
}, {
reload: true
});
} else {
$state.reload();
}
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to delete tags');
@ -127,9 +135,9 @@ angular.module('portainer.app')
})
.then(function success(data) {
$scope.registry = data.registry;
$scope.repository.Tags = data.tags;
$scope.repository.Tags = [].concat(data.tags || []);
$scope.tags = [];
for (var i = 0; i < data.tags.length; i++) {
for (var i = 0; i < $scope.repository.Tags.length; i++) {
var tag = data.tags[i];
RegistryV2Service.tag(registryId, repository, tag)
.then(function success(data) {