Skip to content

Commit df8e0a5

Browse files
committed
[teams] don't show error if already in team
1 parent 7e34c6c commit df8e0a5

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

components/dashboard/src/teams/JoinTeam.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,21 @@ export default function() {
2424
if (!inviteId) {
2525
throw new Error('This invite URL is incorrect.');
2626
}
27-
const team = await getGitpodService().server.joinTeam(inviteId);
27+
28+
let team;
29+
try {
30+
team = await getGitpodService().server.joinTeam(inviteId);
31+
} catch (error) {
32+
const message: string | undefined = error && typeof error.message === "string" && error.message;
33+
const regExp = /You are already a member of this team. \((.*)\)/;
34+
const match = message && regExp.exec(message);
35+
if (match && match[1]) {
36+
const slug = match[1];
37+
history.push(`/t/${slug}`);
38+
return;
39+
}
40+
throw error;
41+
}
2842
const teams = await getGitpodService().server.getTeams();
2943
setTeams(teams);
3044

@@ -44,5 +58,5 @@ export default function() {
4458

4559
useEffect(() => { document.title = 'Joining Team — Gitpod' }, []);
4660

47-
return <div className="mt-16 text-center text-gitpod-red">{String(joinError)}</div>
61+
return joinError ? <div className="mt-16 text-center text-gitpod-red">{String(joinError)}</div> : <></>;
4862
}

components/gitpod-db/src/typeorm/team-db-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class TeamDBImpl implements TeamDB {
154154
const membershipRepo = await this.getMembershipRepo();
155155
const membership = await membershipRepo.findOne({ teamId, userId, deleted: false });
156156
if (!!membership) {
157-
throw new Error('You are already a member of this team');
157+
throw new Error(`You are already a member of this team. (${team.slug})`);
158158
}
159159
await membershipRepo.save({
160160
id: uuidv4(),

0 commit comments

Comments
 (0)