Skip to content

Commit 9afad16

Browse files
iQQBotLaurie T. Malau
authored andcommitted
Add confirmation modal when deleting projects
Co-authored-by: Laurie T. Malau <[email protected]>
1 parent f6daf3a commit 9afad16

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

components/dashboard/src/projects/Projects.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ThemeContext } from "../theme-context";
1717
import { PrebuildWithStatus, Project } from "@gitpod/gitpod-protocol";
1818
import { toRemoteURL } from "./render-utils";
1919
import ContextMenu from "../components/ContextMenu";
20+
import ConfirmationModal from "../components/ConfirmationModal"
2021
import { prebuildStatusIcon } from "./Prebuilds";
2122

2223
export default function () {
@@ -68,6 +69,7 @@ export default function () {
6869
}
6970

7071
const onRemoveProject = async (p: Project) => {
72+
setRemoveModalVisible(false)
7173
await getGitpodService().server.deleteProject(p.id);
7274
await updateProjects();
7375
}
@@ -84,8 +86,24 @@ export default function () {
8486
}
8587

8688
const teamOrUserSlug = !!team ? 't/'+team.slug : 'projects';
89+
let [ isRemoveModalVisible, setRemoveModalVisible ] = useState(false);
90+
let [ removeProjectHandler, setRemoveProjectHandler ] = useState<() => void>(()=> () => {})
91+
let [ willRemoveProject, setWillRemoveProject ] = useState<Project>()
8792

8893
return <>
94+
95+
{isRemoveModalVisible && <ConfirmationModal
96+
title="Remove Project"
97+
areYouSureText="Are you sure you want to remove this project from this team? Team members will also lose access to this project."
98+
children={{
99+
name: willRemoveProject?.name ?? "",
100+
description: willRemoveProject?.cloneUrl ?? "",
101+
}}
102+
buttonText="Remove Project"
103+
visible={isRemoveModalVisible}
104+
onClose={() => setRemoveModalVisible(false)}
105+
onConfirm={removeProjectHandler}
106+
/>}
89107
<Header title="Projects" subtitle="Manage recently added projects." />
90108
{projects.length === 0 && (
91109
<div>
@@ -133,7 +151,13 @@ export default function () {
133151
{
134152
title: "Remove Project",
135153
customFontStyle: 'text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300',
136-
onClick: () => onRemoveProject(p)
154+
onClick: () => {
155+
setWillRemoveProject(p)
156+
setRemoveProjectHandler(() => () => {
157+
onRemoveProject(p)
158+
})
159+
setRemoveModalVisible(true)
160+
}
137161
},
138162
]} />
139163
</div>

0 commit comments

Comments
 (0)