From 0a5fef679526703f563d6a83d78b34cc70cfef54 Mon Sep 17 00:00:00 2001 From: Megan Heskett Date: Thu, 9 Jan 2020 12:15:38 -0800 Subject: [PATCH] feat(teams): Update open membership team permissions (#16244) --- .../organization_member_team_details.py | 4 + .../organizationTeams/teamDetails.jsx | 10 +- .../organizationTeams/teamMembers.jsx | 12 +- tests/js/spec/views/teamMembers.spec.jsx | 59 +- .../test_organization_member_team_details.py | 505 +++++++----------- 5 files changed, 252 insertions(+), 338 deletions(-) diff --git a/src/sentry/api/endpoints/organization_member_team_details.py b/src/sentry/api/endpoints/organization_member_team_details.py index 9802d80ebde9eb..3007c31f51d166 100644 --- a/src/sentry/api/endpoints/organization_member_team_details.py +++ b/src/sentry/api/endpoints/organization_member_team_details.py @@ -56,6 +56,7 @@ def _can_access(self, request, member, organization): * If they are modifying their own membership * If the user's role is higher than the targeted user's role (e.g. "admin" can't modify "owner") * If the user is an "admin" and they are modifying a team they are a member of + * If the "open membership" setting is enabled and the targeted user is being added to a team """ if is_active_superuser(request): @@ -76,6 +77,9 @@ def _can_access(self, request, member, organization): ): return True + if request.method == "POST" and organization.flags.allow_joinleave: + return True + return False def _can_admin_team(self, request, organization, team_slug): diff --git a/src/sentry/static/sentry/app/views/settings/organizationTeams/teamDetails.jsx b/src/sentry/static/sentry/app/views/settings/organizationTeams/teamDetails.jsx index 40f822f3836553..51bb01922ba6db 100644 --- a/src/sentry/static/sentry/app/views/settings/organizationTeams/teamDetails.jsx +++ b/src/sentry/static/sentry/app/views/settings/organizationTeams/teamDetails.jsx @@ -137,11 +137,11 @@ const TeamDetails = createReactClass({ } else if (!team || !team.hasAccess) { return ( -

{t('You do not have access to this team')}

- - {team && ( + {team ? ( - {tct('You may try to request access to [team]', {team: `#${team.slug}`})} + {tct('You do not have access to the [teamSlug] team.', { + teamSlug: {`#${team.slug}`}, + })}