diff --git a/components/dashboard/src/teams/JoinTeam.tsx b/components/dashboard/src/teams/JoinTeam.tsx index 4eda2f85e5bcca..715202d2ccec62 100644 --- a/components/dashboard/src/teams/JoinTeam.tsx +++ b/components/dashboard/src/teams/JoinTeam.tsx @@ -24,7 +24,21 @@ export default function() { if (!inviteId) { throw new Error('This invite URL is incorrect.'); } - const team = await getGitpodService().server.joinTeam(inviteId); + + let team; + try { + team = await getGitpodService().server.joinTeam(inviteId); + } catch (error) { + const message: string | undefined = error && typeof error.message === "string" && error.message; + const regExp = /You are already a member of this team. \((.*)\)/; + const match = message && regExp.exec(message); + if (match && match[1]) { + const slug = match[1]; + history.push(`/t/${slug}/members`); + return; + } + throw error; + } const teams = await getGitpodService().server.getTeams(); setTeams(teams); @@ -44,5 +58,5 @@ export default function() { useEffect(() => { document.title = 'Joining Team — Gitpod' }, []); - return
{String(joinError)}
+ return joinError ?
{String(joinError)}
: <>; } \ No newline at end of file diff --git a/components/gitpod-db/src/typeorm/team-db-impl.ts b/components/gitpod-db/src/typeorm/team-db-impl.ts index cc84e8a162d7ba..73b1085149d54b 100644 --- a/components/gitpod-db/src/typeorm/team-db-impl.ts +++ b/components/gitpod-db/src/typeorm/team-db-impl.ts @@ -154,7 +154,7 @@ export class TeamDBImpl implements TeamDB { const membershipRepo = await this.getMembershipRepo(); const membership = await membershipRepo.findOne({ teamId, userId, deleted: false }); if (!!membership) { - throw new Error('You are already a member of this team'); + throw new Error(`You are already a member of this team. (${team.slug})`); } await membershipRepo.save({ id: uuidv4(),