Have the view repo page's URL be updated for the currently selected tag automatically.
This commit is contained in:
parent
0c3c1b9e0e
commit
f798345d1c
2 changed files with 16 additions and 5 deletions
|
@ -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}).
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Reference in a new issue