Skip to content

Commit 69e973e

Browse files
committed
Update team deletion modal
1 parent 4f1c392 commit 69e973e

File tree

1 file changed

+52
-32
lines changed

1 file changed

+52
-32
lines changed

components/dashboard/src/teams/TeamSettings.tsx

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ import { getCurrentTeam, TeamsContext } from "./teams-context";
1717
export function getTeamSettingsMenu(team?: Team) {
1818
return [
1919
{
20-
title: 'General',
20+
title: "General",
2121
link: [`/t/${team?.slug}/settings`],
2222
},
2323
];
2424
}
2525

2626
export default function TeamSettings() {
2727
const [modal, setModal] = useState(false);
28-
const [teamSlug, setTeamSlug] = useState('');
28+
const [teamSlug, setTeamSlug] = useState("");
2929
const [isUserOwner, setIsUserOwner] = useState(true);
3030
const { teams } = useContext(TeamsContext);
3131
const { user } = useContext(UserContext);
@@ -38,46 +38,66 @@ export default function TeamSettings() {
3838
(async () => {
3939
if (!team) return;
4040
const members = await getGitpodService().server.getTeamMembers(team.id);
41-
const currentUserInTeam = members.find(member => member.userId === user?.id);
42-
setIsUserOwner(currentUserInTeam?.role === 'owner');
41+
const currentUserInTeam = members.find((member) => member.userId === user?.id);
42+
setIsUserOwner(currentUserInTeam?.role === "owner");
4343
})();
4444
}, []);
4545

4646
if (!isUserOwner) {
47-
return <Redirect to="/" />
48-
};
47+
return <Redirect to="/" />;
48+
}
4949
const deleteTeam = async () => {
5050
if (!team || !user) {
51-
return
51+
return;
5252
}
5353
await getGitpodService().server.deleteTeam(team.id, user.id);
5454
document.location.href = gitpodHostUrl.asDashboard().toString();
5555
};
5656

57-
return <>
58-
<PageWithSubMenu subMenu={getTeamSettingsMenu(team)} title="Settings" subtitle="Manage general team settings.">
59-
<h3>Delete Team</h3>
60-
<p className="text-base text-gray-500 pb-4 max-w-2xl">Deleting this team will also remove all associated data with this team, including projects and workspaces. Deleted teams cannot be restored!</p>
61-
<button className="danger secondary" onClick={() => setModal(true)}>Delete Team</button>
62-
</PageWithSubMenu>
57+
return (
58+
<>
59+
<PageWithSubMenu
60+
subMenu={getTeamSettingsMenu(team)}
61+
title="Settings"
62+
subtitle="Manage general team settings."
63+
>
64+
<h3>Delete Team</h3>
65+
<p className="text-base text-gray-500 pb-4 max-w-2xl">
66+
Deleting this team will also remove all associated data with this team, including projects and
67+
workspaces. Deleted teams cannot be restored!
68+
</p>
69+
<button className="danger secondary" onClick={() => setModal(true)}>
70+
Delete Team
71+
</button>
72+
</PageWithSubMenu>
6373

64-
<ConfirmationModal
65-
title="Delete Team"
66-
buttonText="Delete Team"
67-
buttonDisabled={teamSlug !== team!.slug}
68-
visible={modal}
69-
warningText="Warning: This action cannot be reversed."
70-
onClose={close}
71-
onConfirm={deleteTeam}
72-
>
73-
<p className="text-base text-gray-500">You are about to permanently delete <b>{team?.slug}</b> including all associated data with this team.</p>
74-
<ol className="text-gray-500 text-m list-outside list-decimal">
75-
<li className="ml-5">All <b>projects</b> added in this team will be deleted and cannot be restored afterwards.</li>
76-
<li className="ml-5">All <b>workspaces</b> opened for projects within this team will be deleted for all team members and cannot be restored afterwards.</li>
77-
<li className="ml-5">All <b>members</b> of this team will lose access to this team, associated projects and workspaces.</li>
78-
</ol>
79-
<p className="pt-4 pb-2 text-gray-600 dark:text-gray-400 text-base font-semibold">Type <CodeText>{team?.slug}</CodeText> to confirm</p>
80-
<input autoFocus className="w-full" type="text" onChange={e => setTeamSlug(e.target.value)}></input>
81-
</ConfirmationModal>
82-
</>
74+
<ConfirmationModal
75+
title="Delete Team"
76+
buttonText="Delete Team"
77+
buttonDisabled={teamSlug !== team!.slug}
78+
visible={modal}
79+
warningText="Warning: This action cannot be reversed."
80+
onClose={close}
81+
onConfirm={deleteTeam}
82+
>
83+
<p className="text-base text-gray-500">
84+
You are about to permanently delete <b>{team?.slug}</b> including all associated data with this
85+
team.
86+
</p>
87+
<ol className="text-gray-500 text-m list-outside list-decimal">
88+
<li className="ml-5">
89+
All <b>projects</b> added in this team will be deleted and cannot be restored afterwards.
90+
</li>
91+
<li className="ml-5">
92+
All <b>members</b> of this team will lose access to this team, associated projects and
93+
workspaces.
94+
</li>
95+
</ol>
96+
<p className="pt-4 pb-2 text-gray-600 dark:text-gray-400 text-base font-semibold">
97+
Type <CodeText>{team?.slug}</CodeText> to confirm
98+
</p>
99+
<input autoFocus className="w-full" type="text" onChange={(e) => setTeamSlug(e.target.value)}></input>
100+
</ConfirmationModal>
101+
</>
102+
);
83103
}

0 commit comments

Comments
 (0)