Add messaging when trying to create a team that already exists

Fixes https://jira.coreos.com/browse/QUAY-827
This commit is contained in:
Joseph Schorr 2018-02-15 16:03:09 -05:00
parent 33b7ca0eaa
commit 72ca758c88
4 changed files with 16 additions and 4 deletions

View file

@ -68,7 +68,7 @@ def handle_addinvite_team(inviter, team, user=None, email=None):
orgname, team.name, inviter.username, invite.invite_token)
return invite
def team_view(orgname, team):
def team_view(orgname, team, is_new_team=False):
view_permission = ViewTeamPermission(orgname, team.name)
role = model.team.get_team_org_role(team).name
return {
@ -76,7 +76,8 @@ def team_view(orgname, team):
'description': team.description,
'can_view': view_permission.can(),
'role': role,
'avatar': avatar.get_data_for_team(team)
'avatar': avatar.get_data_for_team(team),
'new_team': is_new_team,
}
def member_view(member, invited=False):
@ -192,7 +193,7 @@ class OrganizationTeam(ApiResource):
get_authenticated_user().username)
log_action('org_set_team_role', orgname, {'team': teamname, 'role': details['role']})
return team_view(orgname, team), 200
return team_view(orgname, team, is_new_team=not is_existing), 200
raise Unauthorized()

View file

@ -35,6 +35,11 @@ angular.module('quay').directive('createTeamDialog', function () {
});
ApiService.updateOrganizationTeam(data, params).then(function(resp) {
if (!resp.new_team) {
callback(null);
bootbox.alert('Team with name "' + resp.name + '" already exists')
return;
}
callback(resp);
}, errorDisplay);
};

View file

@ -151,7 +151,9 @@ angular.module('quay').directive('entitySearch', function () {
$scope.handleTeamCreated = function(created) {
$scope.setEntity(created.name, 'team', false, created.avatar);
$scope.teams.push(created);
if (created.new_team) {
$scope.teams.push(created);
}
};
$scope.handleRobotCreated = function(created) {

View file

@ -101,6 +101,10 @@ angular.module('quay').directive('teamsManager', function () {
};
$scope.handleTeamCreated = function(created) {
if (!created.new_team) {
return;
}
var teamname = created.name;
created['member_count'] = 0;