SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
/**
* Delete Namespace Confirmation Dialog
*
* Requires user to type namespace label to confirm deletion
*/
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@src/react/shared/components/ui/dialog';
import { Input } from '@src/react/shared/components/ui/input';
import { Button as CustomButton } from '@src/react/shared/components/ui/newDesign/button';
import { ChangeEvent, FC, useEffect, useState } from 'react';
interface DeleteNamespaceDialogProps {
isOpen: boolean;
namespaceName: string;
onClose: () => void;
onConfirm: () => Promise<void>;
}
export const DeleteNamespaceDialog: FC<DeleteNamespaceDialogProps> = ({
isOpen,
namespaceName,
onClose,
onConfirm,
}) => {
const [confirmText, setConfirmText] = useState<string>('');
const [isDeleting, setIsDeleting] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
// Reset state when dialog opens/closes
useEffect(() => {
if (isOpen) {
setConfirmText('');
setError(null);
setIsDeleting(false);
}
}, [isOpen]);
const handleConfirmTextChange = (e: ChangeEvent<HTMLInputElement>) => {
setConfirmText(e.target.value);
setError(null);
};
const handleConfirm = async () => {
if (confirmText !== namespaceName) {
setError('Data space name does not match');
return;
}
setIsDeleting(true);
try {
await onConfirm();
onClose();
} catch {
// Error handling is done in parent component
setIsDeleting(false);
}
};
const isValid = confirmText === namespaceName;
return (
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent className="sm:max-w-[500px]">
<DialogHeader>
<DialogTitle>Delete Data Space</DialogTitle>
</DialogHeader>
<div className="py-4 space-y-4">
<div className="bg-red-50 border border-red-200 rounded-md p-4">
<p className="text-sm text-red-800">
<strong>Warning:</strong> This action cannot be undone. This will permanently delete
the data space and all associated data.
</p>
</div>
<div className="space-y-2">
<p className="text-sm text-gray-700">
Please type <strong className="font-semibold text-gray-900">{namespaceName}</strong>{' '}
to confirm deletion.
</p>
<Input
fullWidth
type="text"
placeholder="Type data space name"
value={confirmText}
onChange={handleConfirmTextChange}
disabled={isDeleting}
error={!!error}
errorMessage={error || undefined}
autoFocus
/>
</div>
</div>
<DialogFooter>
<CustomButton
variant="primary"
label={isDeleting ? 'Deleting...' : 'Delete Data Space'}
handleClick={handleConfirm}
disabled={!isValid || isDeleting}
loading={isDeleting}
// when not disabled (only when not disabled!!)
className="bg-red-600 hover:bg-red-700 text-white disabled:bg-gray-100 disabled:hover:bg-gray-100 disabled:text-gray-500"
/>
</DialogFooter>
</DialogContent>
</Dialog>
);
};