Switch to using the UserService’s cache of org information for whether a user is an admin of a namespace/org (#2)

This commit is contained in:
Joseph Schorr 2013-12-10 15:49:34 -05:00
parent df1500b6d0
commit 3302b58cc3
3 changed files with 17 additions and 16 deletions

View file

@ -1275,6 +1275,8 @@ quayApp.directive('entitySearch', function () {
$scope.lazyLoad = function() {
if (!$scope.namespace || !$scope.lazyLoading) { return; }
$scope.isAdmin = UserService.isNamespaceAdmin($scope.namespace);
if ($scope.isOrganization && $scope.includeTeams) {
var url = getRestUrl('organization', $scope.namespace);
var getOrganization = Restangular.one(url);
@ -1283,23 +1285,19 @@ quayApp.directive('entitySearch', function () {
});
}
if (UserService.isNamespaceAdmin($scope.namespace)) {
$scope.isAdmin = true;
var url = $scope.isOrganization ? getRestUrl('organization', $scope.namespace, 'robots') : 'user/robots';
var getRobots = Restangular.one(url);
getRobots.customGET().then(function(resp) {
$scope.robots = resp.robots;
$scope.lazyLoading = false;
}, function() {
$scope.lazyLoading = false;
});
} else {
var url = $scope.isOrganization ? getRestUrl('organization', $scope.namespace, 'robots') : 'user/robots';
var getRobots = Restangular.one(url);
getRobots.customGET().then(function(resp) {
$scope.robots = resp.robots;
$scope.lazyLoading = false;
}
}, function() {
$scope.lazyLoading = false;
});
};
$scope.createTeam = function() {
if (!$scope.isAdmin) { return; }
bootbox.prompt('Enter the name of the new team', function(teamname) {
if (!teamname) { return; }
@ -1317,6 +1315,8 @@ quayApp.directive('entitySearch', function () {
};
$scope.createRobot = function() {
if (!$scope.isAdmin) { return; }
bootbox.prompt('Enter the name of the new robot account', function(robotname) {
if (!robotname) { return; }