Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

1.2 KB
Raw Blame
import { AlertDialog } from '@signozhq/ui/alert-dialog';
import { Button } from '@signozhq/ui/button';
import { Trash2, X } from '@signozhq/icons';

interface DiscardChangesDialogProps {
	open: boolean;
	onConfirm: () => void;
	onCancel: () => void;
}

function DiscardChangesDialog({
	open,
	onConfirm,
	onCancel,
}: DiscardChangesDialogProps): JSX.Element {
	return (
		<AlertDialog
			open={open}
			onOpenChange={(isOpen): void => {
				if (!isOpen) {
					onCancel();
				}
			}}
			width="narrow"
			title="Discard unsaved changes?"
			titleIcon={<Trash2 size={16} />}
			footer={
				<>
					<Button
						size="md"
						variant="solid"
						color="secondary"
						onClick={onCancel}
						prefix={<X size={12} />}
						testId="discard-changes-cancel-btn"
					>
						Keep editing
					</Button>
					<Button
						size="md"
						variant="solid"
						color="danger"
						onClick={onConfirm}
						prefix={<Trash2 size={12} />}
						testId="discard-changes-confirm-btn"
					>
						Discard changes
					</Button>
				</>
			}
		>
			This reverts every unsaved group and mapping change back to the last saved
			state. This action cannot be undone.
		</AlertDialog>
	);
}

export default DiscardChangesDialog;