Skip to content

Commit c618f35

Browse files
authored
feat(cells): Remove the legacy org invite route (#112634)
- removes the old /accept/:memberId/:token/ route. The component now only mounts via the org-scoped /accept/:orgId/:memberId/:token/ route - this is safe now because #112513 added a redirect that ensures the old route is never hit anymore - the react component is also simplified as it no longer has to handle the case where an org is not present
1 parent b7e8d18 commit c618f35

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

static/app/router/routes.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ function buildRoutes(): RouteObject[] {
157157
path: '/accept/:orgId/:memberId/:token/',
158158
component: make(() => import('sentry/views/acceptOrganizationInvite')),
159159
},
160-
{
161-
path: '/accept/:memberId/:token/',
162-
component: make(() => import('sentry/views/acceptOrganizationInvite')),
163-
},
164160
{
165161
path: '/accept-transfer/',
166162
component: make(() => import('sentry/views/acceptProjectTransfer')),

static/app/views/acceptOrganizationInvite/index.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('AcceptOrganizationInvite', () => {
106106

107107
it('renders error message', async () => {
108108
MockApiClient.addMockResponse({
109-
url: '/accept-invite/1/abc/',
109+
url: '/accept-invite/org-slug/1/abc/',
110110
method: 'GET',
111111
statusCode: 400,
112112
body: {detail: 'uh oh'},
@@ -115,9 +115,9 @@ describe('AcceptOrganizationInvite', () => {
115115
render(<AcceptOrganizationInvite />, {
116116
initialRouterConfig: {
117117
location: {
118-
pathname: '/accept-invite/1/abc/',
118+
pathname: '/accept-invite/org-slug/1/abc/',
119119
},
120-
route: '/accept-invite/:memberId/:token/',
120+
route: '/accept-invite/:orgId/:memberId/:token/',
121121
},
122122
});
123123

static/app/views/acceptOrganizationInvite/index.tsx

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -204,30 +204,22 @@ function AuthenticationActions({inviteDetails}: {inviteDetails: InviteDetails})
204204

205205
function AcceptOrganizationInvite() {
206206
const api = useApi({persistInFlight: true});
207-
const params = useParams<{memberId: string; token: string; orgId?: string}>();
208-
209-
const orgSlug = params.orgId || ConfigStore.get('customerDomain')?.subdomain || null;
207+
const params = useParams<{memberId: string; orgId: string; token: string}>();
210208

211209
const {
212210
data: inviteDetails,
213211
isPending,
214212
isError,
215213
} = useApiQuery<InviteDetails>(
216-
orgSlug
217-
? [
218-
getApiUrl('/accept-invite/$organizationIdOrSlug/$memberId/$token/', {
219-
path: {
220-
organizationIdOrSlug: orgSlug,
221-
memberId: params.memberId,
222-
token: params.token,
223-
},
224-
}),
225-
]
226-
: [
227-
getApiUrl('/accept-invite/$memberId/$token/', {
228-
path: {memberId: params.memberId, token: params.token},
229-
}),
230-
],
214+
[
215+
getApiUrl('/accept-invite/$organizationIdOrSlug/$memberId/$token/', {
216+
path: {
217+
organizationIdOrSlug: params.orgId,
218+
memberId: params.memberId,
219+
token: params.token,
220+
},
221+
}),
222+
],
231223
{
232224
staleTime: Infinity,
233225
retry: false,
@@ -241,9 +233,7 @@ function AcceptOrganizationInvite() {
241233
} = useMutation({
242234
mutationFn: () =>
243235
api.requestPromise(
244-
orgSlug
245-
? `/accept-invite/${orgSlug}/${params.memberId}/${params.token}/`
246-
: `/accept-invite/${params.memberId}/${params.token}/`,
236+
`/accept-invite/${params.orgId}/${params.memberId}/${params.token}/`,
247237
{
248238
method: 'POST',
249239
}
@@ -273,7 +263,10 @@ function AcceptOrganizationInvite() {
273263
data-test-id="existing-member-link"
274264
onClick={e => {
275265
e.preventDefault();
276-
logout(api, `/accept/${params.memberId}/${params.token}/`);
266+
logout(
267+
api,
268+
`/accept/${params.orgId}/${params.memberId}/${params.token}/`
269+
);
277270
}}
278271
/>
279272
),

0 commit comments

Comments
 (0)