Skip to content

Commit 200952a

Browse files
AlexTugarevroboquat
authored andcommitted
[teams] don't show error if already in team
1 parent 89754f7 commit 200952a

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
@@ -22,7 +22,21 @@ export default function() {
2222
if (!inviteId) {
2323
throw new Error('This invite URL is incorrect.');
2424
}
25-
const team = await getGitpodService().server.joinTeam(inviteId);
25+
26+
let team;
27+
try {
28+
team = await getGitpodService().server.joinTeam(inviteId);
29+
} catch (error) {
30+
const message: string | undefined = error && typeof error.message === "string" && error.message;
31+
const regExp = /You are already a member of this team. \((.*)\)/;
32+
const match = message && regExp.exec(message);
33+
if (match && match[1]) {
34+
const slug = match[1];
35+
history.push(`/t/${slug}/members`);
36+
return;
37+
}
38+
throw error;
39+
}
2640
const teams = await getGitpodService().server.getTeams();
2741
setTeams(teams);
2842

@@ -36,5 +50,5 @@ export default function() {
3650

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

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

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)