Make sure the repo exists when setting a tag

This commit is contained in:
Joseph Schorr 2014-06-10 14:43:52 -04:00
parent bbb48b1235
commit 257b66fa2a

View file

@ -539,6 +539,8 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
$scope.setTag = function(tagName, opt_updateURL) { $scope.setTag = function(tagName, opt_updateURL) {
var repo = $scope.repo; var repo = $scope.repo;
if (!repo) { return; }
var proposedTag = repo.tags[tagName]; var proposedTag = repo.tags[tagName];
if (!proposedTag) { if (!proposedTag) {
// We must find a good default // We must find a good default
@ -551,15 +553,15 @@ function RepoCtrl($scope, $sanitize, Restangular, ImageMetadataService, ApiServi
if (proposedTag) { if (proposedTag) {
$scope.currentTag = proposedTag; $scope.currentTag = proposedTag;
$scope.currentImage = $scope.currentTag.image; $scope.currentImage = proposedTag.image;
$scope.loadImageChanges($scope.currentImage); $scope.loadImageChanges($scope.currentImage);
if ($scope.tree) { if ($scope.tree) {
$scope.tree.setTag($scope.currentTag.name); $scope.tree.setTag(proposedTag.name);
} }
if (opt_updateURL) { if (opt_updateURL) {
$location.search('image', null); $location.search('image', null);
$location.search('tag', $scope.currentTag.name); $location.search('tag', proposedTag.name);
} }
} }