Merge ac9216d0d1 into 238750c025
This commit is contained in:
commit
3e39bb0efc
|
|
@ -10,6 +10,9 @@ import {
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
const REQUIRED_CONFIRMATION_TEXT = "DELETE";
|
||||||
|
|
||||||
export function DeleteProjectDialog({
|
export function DeleteProjectDialog({
|
||||||
isOpen,
|
isOpen,
|
||||||
|
|
@ -25,6 +28,8 @@ export function DeleteProjectDialog({
|
||||||
const count = projectNames.length;
|
const count = projectNames.length;
|
||||||
const isSingle = count === 1;
|
const isSingle = count === 1;
|
||||||
const singleName = isSingle ? projectNames[0] : null;
|
const singleName = isSingle ? projectNames[0] : null;
|
||||||
|
|
||||||
|
const [confirmationInput, setConfirmationInput] = useState<string>("");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
<Dialog open={isOpen} onOpenChange={onOpenChange}>
|
||||||
|
|
@ -59,12 +64,15 @@ export function DeleteProjectDialog({
|
||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
<div className="flex flex-col gap-3">
|
<div className="flex flex-col gap-3">
|
||||||
<Label className="text-xs font-semibold text-slate-500">
|
<Label htmlFor="confirmation-input" className="text-xs font-semibold text-slate-500">
|
||||||
Type "DELETE" to confirm
|
{`Type "${REQUIRED_CONFIRMATION_TEXT}" to confirm`}
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
|
id={"confirmation-input"}
|
||||||
|
onChange={(e) => {setConfirmationInput(e.target.value)}}
|
||||||
|
value={confirmationInput}
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="DELETE"
|
placeholder={REQUIRED_CONFIRMATION_TEXT}
|
||||||
size="lg"
|
size="lg"
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
/>
|
/>
|
||||||
|
|
@ -74,7 +82,7 @@ export function DeleteProjectDialog({
|
||||||
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="destructive" onClick={onConfirm}>
|
<Button variant="destructive" onClick={onConfirm} disabled={confirmationInput !== REQUIRED_CONFIRMATION_TEXT}>
|
||||||
Delete project
|
Delete project
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue