From f798345d1c7d48847f2c4472e626a9ad1f6cc457 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 16 Oct 2013 23:09:43 -0400 Subject: [PATCH] Have the view repo page's URL be updated for the currently selected tag automatically. --- static/js/app.js | 2 +- static/js/controllers.js | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/static/js/app.js b/static/js/app.js index e9e9f39cc..031b82c3c 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -129,7 +129,7 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics', // index rule to make sure that deep links directly deep into the app continue to work. // WARNING WARNING WARNING $routeProvider. - when('/repository/:namespace/:name', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl}). + when('/repository/:namespace/:name', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl, reloadOnSearch: false}). when('/repository/:namespace/:name/tag/:tag', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl}). when('/repository/:namespace/:name/admin', {templateUrl: '/static/partials/repo-admin.html', controller:RepoAdminCtrl}). when('/repository/', {title: 'Repositories', templateUrl: '/static/partials/repo-list.html', controller: RepoListCtrl}). diff --git a/static/js/controllers.js b/static/js/controllers.js index b103a4255..c1664cb27 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -256,9 +256,14 @@ function LandingCtrl($scope, $timeout, Restangular, UserService, KeyService) { browserchrome.update(); } -function RepoCtrl($scope, Restangular, $routeParams, $rootScope) { +function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location) { $rootScope.title = 'Loading...'; + // Watch for changes to the tag parameter. + $scope.$on('$routeUpdate', function(){ + $scope.setTag($location.search().tag, false); + }); + $scope.editDescription = function() { if (!$scope.repo.can_write) { return; } @@ -307,7 +312,7 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) { $scope.tree.draw('image-history-container'); $($scope.tree).bind('tagChanged', function(e) { - $scope.$apply(function() { $scope.setTag(e.tag); }); + $scope.$apply(function() { $scope.setTag(e.tag, true); }); }); $($scope.tree).bind('imageChanged', function(e) { $scope.$apply(function() { $scope.setImage(e.image); }); @@ -322,12 +327,18 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) { } }; - $scope.setTag = function(tagName) { + $scope.setTag = function(tagName, opt_updateURL) { var repo = $scope.repo; $scope.currentTag = repo.tags[tagName] || repo.tags['latest']; $scope.currentImage = $scope.currentTag.image; + + currentTagName = $scope.currentTag.name; if ($scope.tree) { - $scope.tree.setTag($scope.currentTag.name); + $scope.tree.setTag(currentTagName); + } + + if (opt_updateURL) { + $location.search('tag', currentTagName); } };