diff --git a/static/js/directives/ui/set-repo-permissions.js b/static/js/directives/ui/set-repo-permissions.js index 5510503c6..5732b7649 100644 --- a/static/js/directives/ui/set-repo-permissions.js +++ b/static/js/directives/ui/set-repo-permissions.js @@ -39,6 +39,9 @@ angular.module('quay').directive('setRepoPermissions', function () { var checkForChanges = function() { var hasChanges = false; + if (!$scope.repositories) { + return; + } $scope.repositories.forEach(function(repo) { if (repo['permission'] != repo['original_permission']) { @@ -51,6 +54,9 @@ angular.module('quay').directive('setRepoPermissions', function () { }; var handleRepoCheckChange = function() { + if (!$scope.repositories) { + return; + } $scope.repositories.forEach(function(repo) { if ($scope.checkedRepos.isChecked(repo)) { if (repo['permission'] == 'none') { @@ -121,6 +127,11 @@ angular.module('quay').directive('setRepoPermissions', function () { $scope.currentNamespace = $scope.namespace; var repos = []; + if (!resp || !resp['repositories'] || resp['repositories'].length == 0) { + $scope.repositoriesLoaded({'repositories': []}); + return; + } + resp['repositories'].forEach(function(repo) { var existingPermission = existingPermissionsMap[repo.name] || 'none'; @@ -134,11 +145,6 @@ angular.module('quay').directive('setRepoPermissions', function () { }); }); - if (repos.length == 0) { - $scope.repositoriesLoaded({'repositories': repos}); - return; - } - $scope.repositories = repos; $scope.checkedRepos = UIService.createCheckStateController($scope.repositories, 'name'); @@ -232,4 +238,4 @@ angular.module('quay').directive('setRepoPermissions', function () { } }; return directiveDefinitionObject; -}); \ No newline at end of file +});