Fix create robot and create team in the new layout "new" header button
This commit is contained in:
parent
b02b98def3
commit
4dff6557ae
3 changed files with 35 additions and 12 deletions
|
@ -211,11 +211,11 @@ angular.module('quay').directive('headerBar', function () {
|
|||
|
||||
$scope.createRobot = function(context) {
|
||||
var namespace = $scope.getNamespace(context);
|
||||
CreateService.askCreateRobot(function(created) {
|
||||
if (isorg) {
|
||||
$location.url('/organization/' + namespace + '?tab=robots');
|
||||
CreateService.askCreateRobot(namespace, function(created) {
|
||||
if (UserService.isOrganization(namespace)) {
|
||||
$location.url('/organization/' + namespace + '?tab=robots&showRobot=' + created.name);
|
||||
} else {
|
||||
$location.url('/user/' + namespace + '?tab=robots');
|
||||
$location.url('/user/' + namespace + '?tab=robots&showRobot=' + created.name);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -224,8 +224,8 @@ angular.module('quay').directive('headerBar', function () {
|
|||
var namespace = $scope.getNamespace(context);
|
||||
if (!namespace || !UserService.isNamespaceAdmin(namespace)) { return; }
|
||||
|
||||
CreateService.askCreateTeam(function(created) {
|
||||
$location.url('/organization/' + namespace + '/teams/' + teamname);
|
||||
CreateService.askCreateTeam(namespace, function(created) {
|
||||
$location.url('/organization/' + namespace + '/teams/' + created.name);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ angular.module('quay').directive('robotsManager', function () {
|
|||
'user': '=user',
|
||||
'isEnabled': '=isEnabled'
|
||||
},
|
||||
controller: function($scope, $element, ApiService, $routeParams, CreateService, Config) {
|
||||
controller: function($scope, $element, ApiService, $routeParams, $location, CreateService,
|
||||
Config, $rootScope) {
|
||||
$scope.ROBOT_PATTERN = ROBOT_PATTERN;
|
||||
|
||||
$scope.robots = null;
|
||||
|
@ -22,6 +23,17 @@ angular.module('quay').directive('robotsManager', function () {
|
|||
$scope.showRobotCounter = 0;
|
||||
$scope.Config = Config;
|
||||
|
||||
// Listen for route changes and update the tabs accordingly.
|
||||
var locationListener = $rootScope.$on('$routeUpdate', function(){
|
||||
if ($location.search()['showRobot']) {
|
||||
$scope.filterToRobot($location.search()['showRobot']);
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
locationListener && locationListener();
|
||||
});
|
||||
|
||||
var loadRobotPermissions = function(info) {
|
||||
var shortName = $scope.getShortenedName(info.name);
|
||||
info.loading_permissions = true;
|
||||
|
@ -31,6 +43,20 @@ angular.module('quay').directive('robotsManager', function () {
|
|||
}, ApiService.errorDisplay('Could not load robot permissions'));
|
||||
};
|
||||
|
||||
$scope.filterToRobot = function(robotName) {
|
||||
if ($scope.robotFilter == robotName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var index = $scope.findRobotIndexByName(robotName);
|
||||
if (index < 0) {
|
||||
// Robot doesn't exist. Reload the list to see if we can find it.
|
||||
update();
|
||||
}
|
||||
|
||||
$scope.robotFilter = robotName;
|
||||
};
|
||||
|
||||
$scope.showPermissions = function(robotInfo) {
|
||||
robotInfo.showing_permissions = !robotInfo.showing_permissions;
|
||||
|
||||
|
@ -112,10 +138,7 @@ angular.module('quay').directive('robotsManager', function () {
|
|||
$scope.loading = false;
|
||||
|
||||
if ($routeParams.showRobot) {
|
||||
var index = $scope.findRobotIndexByName($routeParams.showRobot);
|
||||
if (index >= 0) {
|
||||
$scope.robotFilter = $routeParams.showRobot;
|
||||
}
|
||||
$scope.filterToRobot($routeParams.showRobot);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -216,7 +216,7 @@ angular.module('quay').factory('UIService', ['$timeout', '$rootScope', '$locatio
|
|||
var registerListeners = function(tabs) {
|
||||
// Listen for scope destruction.
|
||||
scope.$on('$destroy', function() {
|
||||
dispoed = true;
|
||||
disposed = true;
|
||||
locationListener && locationListener();
|
||||
});
|
||||
|
||||
|
|
Reference in a new issue