Start on new org view
This commit is contained in:
		
							parent
							
								
									a7a8571396
								
							
						
					
					
						commit
						2459b6b467
					
				
					 11 changed files with 442 additions and 103 deletions
				
			
		|  | @ -11,9 +11,9 @@ angular.module('quay').directive('repoListGrid', function () { | |||
|     scope: { | ||||
|       repositoriesResource: '=repositoriesResource', | ||||
|       starred: '=starred', | ||||
|       user: "=user", | ||||
|       namespace: '=namespace', | ||||
|       starToggled: '&starToggled' | ||||
|       starToggled: '&starToggled', | ||||
|       hideTitle: '=hideTitle' | ||||
|     }, | ||||
|     controller: function($scope, $element, UserService) { | ||||
|       $scope.isOrganization = function(namespace) { | ||||
|  |  | |||
							
								
								
									
										82
									
								
								static/js/directives/ui/teams-manager.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								static/js/directives/ui/teams-manager.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,82 @@ | |||
| /** | ||||
|  * Element for managing the teams of an organization. | ||||
|  */ | ||||
| angular.module('quay').directive('teamsManager', function () { | ||||
|   var directiveDefinitionObject = { | ||||
|     priority: 0, | ||||
|     templateUrl: '/static/directives/teams-manager.html', | ||||
|     replace: false, | ||||
|     transclude: false, | ||||
|     restrict: 'C', | ||||
|     scope: { | ||||
|       'organization': '=organization' | ||||
|     }, | ||||
|     controller: function($scope, $element, ApiService, CreateService) { | ||||
|       $scope.TEAM_PATTERN = TEAM_PATTERN; | ||||
|       $scope.teamRoles = [ | ||||
|           { 'id': 'member', 'title': 'Member', 'kind': 'default' }, | ||||
|           { 'id': 'creator', 'title': 'Creator', 'kind': 'success' }, | ||||
|           { 'id': 'admin', 'title': 'Admin', 'kind': 'primary' } | ||||
|       ]; | ||||
| 
 | ||||
|       $scope.setRole = function(role, teamname) { | ||||
|         var previousRole = $scope.organization.teams[teamname].role; | ||||
|         $scope.organization.teams[teamname].role = role; | ||||
| 
 | ||||
|         var params = { | ||||
|           'orgname': $scope.organization.name, | ||||
|           'teamname': teamname | ||||
|         }; | ||||
| 
 | ||||
|         var data = $scope.organization.teams[teamname]; | ||||
| 
 | ||||
|         var errorHandler = ApiService.errorDisplay('Cannot update team', function(resp) { | ||||
|           $scope.organization.teams[teamname].role = previousRole; | ||||
|         }); | ||||
| 
 | ||||
|         ApiService.updateOrganizationTeam(data, params).then(function(resp) { | ||||
|         }, errorHandler); | ||||
|       }; | ||||
| 
 | ||||
|       $scope.createTeam = function(teamname) { | ||||
|         if (!teamname) { | ||||
|           return; | ||||
|         } | ||||
| 
 | ||||
|         if ($scope.organization.teams[teamname]) { | ||||
|           $('#team-' + teamname).removeClass('highlight'); | ||||
|           setTimeout(function() { | ||||
|             $('#team-' + teamname).addClass('highlight'); | ||||
|           }, 10); | ||||
|           return; | ||||
|         } | ||||
| 
 | ||||
|         var orgname = $scope.organization.name; | ||||
|         CreateService.createOrganizationTeam(ApiService, orgname, teamname, function(created) { | ||||
|           $scope.organization.teams[teamname] = created; | ||||
|         }); | ||||
|       }; | ||||
| 
 | ||||
|       $scope.askDeleteTeam = function(teamname) { | ||||
|         bootbox.confirm('Are you sure you want to delete team ' + teamname + '?', function(resp) { | ||||
|           if (resp) { | ||||
|             $scope.deleteTeam(teamname); | ||||
|           } | ||||
|         }); | ||||
|       }; | ||||
| 
 | ||||
|       $scope.deleteTeam = function(teamname) { | ||||
|         var params = { | ||||
|           'orgname': $scope.organization.name, | ||||
|           'teamname': teamname | ||||
|         }; | ||||
| 
 | ||||
|         ApiService.deleteOrganizationTeam(null, params).then(function() { | ||||
|           delete $scope.organization.teams[teamname]; | ||||
|         }, ApiService.errorDisplay('Cannot delete team')); | ||||
|       }; | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   return directiveDefinitionObject; | ||||
| }); | ||||
		Reference in a new issue