Skip to content

[dashboard] Add confirmation modal when deleting projects #6432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion components/dashboard/src/projects/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ThemeContext } from "../theme-context";
import { PrebuildWithStatus, Project } from "@gitpod/gitpod-protocol";
import { toRemoteURL } from "./render-utils";
import ContextMenu from "../components/ContextMenu";
import ConfirmationModal from "../components/ConfirmationModal"
import { prebuildStatusIcon } from "./Prebuilds";

export default function () {
Expand Down Expand Up @@ -68,6 +69,7 @@ export default function () {
}

const onRemoveProject = async (p: Project) => {
setRemoveModalVisible(false)
await getGitpodService().server.deleteProject(p.id);
await updateProjects();
}
Expand All @@ -84,8 +86,24 @@ export default function () {
}

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

return <>

{isRemoveModalVisible && <ConfirmationModal
title="Remove Project"
areYouSureText="Are you sure you want to remove this project from this team? Team members will also lose access to this project."
children={{
name: willRemoveProject?.name ?? "",
description: willRemoveProject?.cloneUrl ?? "",
}}
buttonText="Remove Project"
visible={isRemoveModalVisible}
onClose={() => setRemoveModalVisible(false)}
onConfirm={removeProjectHandler}
/>}
<Header title="Projects" subtitle="Manage recently added projects." />
{projects.length === 0 && (
<div>
Expand Down Expand Up @@ -133,7 +151,13 @@ export default function () {
{
title: "Remove Project",
customFontStyle: 'text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-300',
onClick: () => onRemoveProject(p)
onClick: () => {
setWillRemoveProject(p)
setRemoveProjectHandler(() => () => {
onRemoveProject(p)
})
setRemoveModalVisible(true)
}
},
]} />
</div>
Expand Down