Franknoirot/file tree fixes (#2525)
* Navigate between files with single-click * Better semantic name for optional event passed into FileTree * Bug fix: reset modeling state when navigating to a new file * Add more context to E2E test TODO comment * Newly-created file tree items are immediately set to renaming mode * Bug fix: redirect to working file if you delete your current one * Remove ContextMenu, unrelated branch * Turn off autocorrect in renaming form * Gracefully handle renaming a folder that our current file is inside of * Update cargo.lock * Fix renaming queue * Navigate to newly-created files * Make delete project and delete file/folder share deletion confirmation component * Bug fix: navigate to project root if we delete our current file's parent directory * Don't navigate to newly-created directories
This commit is contained in:
@ -1,33 +1,26 @@
|
||||
import { Dialog } from '@headlessui/react'
|
||||
import { ActionButton } from 'components/ActionButton'
|
||||
|
||||
interface DeleteProjectDialogProps {
|
||||
projectName: string
|
||||
interface DeleteConfirmationDialogProps extends React.PropsWithChildren<{}> {
|
||||
title: string
|
||||
onConfirm: () => void
|
||||
onDismiss: () => void
|
||||
}
|
||||
|
||||
export function DeleteProjectDialog({
|
||||
projectName,
|
||||
export function DeleteConfirmationDialog({
|
||||
title,
|
||||
onConfirm,
|
||||
onDismiss,
|
||||
}: DeleteProjectDialogProps) {
|
||||
children,
|
||||
}: DeleteConfirmationDialogProps) {
|
||||
return (
|
||||
<Dialog open={true} onClose={onDismiss} className="relative z-50">
|
||||
<div className="fixed inset-0 grid bg-chalkboard-110/80 place-content-center">
|
||||
<Dialog.Panel className="max-w-2xl p-4 border rounded bg-chalkboard-10 dark:bg-chalkboard-100 border-destroy-80">
|
||||
<Dialog.Title as="h2" className="mb-4 text-2xl font-bold">
|
||||
Delete File
|
||||
{title}
|
||||
</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
This will permanently delete "{projectName || 'this file'}
|
||||
".
|
||||
</Dialog.Description>
|
||||
|
||||
<p className="my-4">
|
||||
Are you sure you want to delete "{projectName || 'this file'}
|
||||
"? This action cannot be undone.
|
||||
</p>
|
||||
<Dialog.Description>{children}</Dialog.Description>
|
||||
|
||||
<div className="flex justify-between">
|
||||
<ActionButton
|
||||
|
@ -5,7 +5,7 @@ import { ActionButton } from '../ActionButton'
|
||||
import { FILE_EXT } from 'lib/constants'
|
||||
import { useHotkeys } from 'react-hotkeys-hook'
|
||||
import Tooltip from '../Tooltip'
|
||||
import { DeleteProjectDialog } from './DeleteProjectDialog'
|
||||
import { DeleteConfirmationDialog } from './DeleteProjectDialog'
|
||||
import { ProjectCardRenameForm } from './ProjectCardRenameForm'
|
||||
import { Project } from 'wasm-lib/kcl/bindings/Project'
|
||||
|
||||
@ -160,14 +160,23 @@ function ProjectCard({
|
||||
</div>
|
||||
)}
|
||||
{isConfirmingDelete && (
|
||||
<DeleteProjectDialog
|
||||
projectName={project.name}
|
||||
<DeleteConfirmationDialog
|
||||
title="Delete Project"
|
||||
onConfirm={async () => {
|
||||
await handleDeleteProject(project)
|
||||
setIsConfirmingDelete(false)
|
||||
}}
|
||||
onDismiss={() => setIsConfirmingDelete(false)}
|
||||
/>
|
||||
>
|
||||
<p className="my-4">
|
||||
This will permanently delete "{project.name || 'this file'}
|
||||
".
|
||||
</p>
|
||||
<p className="my-4">
|
||||
Are you sure you want to delete "{project.name || 'this file'}
|
||||
"? This action cannot be undone.
|
||||
</p>
|
||||
</DeleteConfirmationDialog>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
|
Reference in New Issue
Block a user