feat(ui): replace all native confirm() dialogs with styled ConfirmDialog
All checks were successful
Deploy to Production / Trigger production update (push) Successful in 8s

Add ConfirmDialogProvider + useConfirm hook (Promise-based API) so every
window.confirm() in the app is replaced with a consistent themed modal.

Replaced in 11 files (16 call-sites):
- Settings: update panel action
- Templates: delete template
- Storages: delete storage
- SSH Keys: delete key
- Nodes: delete server
- NodeNetworks: delete interface, apply pending, revert pending
- HAResources: remove HA resource
- SDNManager: apply SDN, delete zone/vnet, delete subnet
- IPAM: release allocation, delete pool, cleanup orphans

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 09:09:26 +05:00
parent 9b4fbf13ba
commit 14cac12191
13 changed files with 132 additions and 33 deletions

View File

@@ -15,12 +15,14 @@ import {
} from '@/hooks/use-ipam';
import type { IPAMAllocation } from '@/types';
import { toast } from 'sonner';
import { useConfirm } from '@/components/shared/ConfirmDialog';
const STATUSES = ['allocated', 'reserved', 'available', 'conflict'] as const;
const RESOURCE_TYPES = ['vm', 'lxc', 'physical', 'service', 'reserved'] as const;
export default function IPAMAllocationsPage() {
const { t } = useTranslation();
const confirm = useConfirm();
const [networkId, setNetworkId] = useState<string>('all');
const [statusFilter, setStatusFilter] = useState<string>('all');
const [search, setSearch] = useState('');
@@ -48,8 +50,8 @@ export default function IPAMAllocationsPage() {
return true;
});
const handleDelete = (a: IPAMAllocation) => {
if (!confirm(t('ipam.delete_allocation_confirm', { ip: a.ip_address }))) return;
const handleDelete = async (a: IPAMAllocation) => {
if (!await confirm(t('ipam.delete_allocation_confirm', { ip: a.ip_address }))) return;
deleteAllocation.mutate(a.id, {
onSuccess: () => toast.success(t('ipam.released')),
onError: (e: Error) => toast.error(e.message),

View File

@@ -16,6 +16,7 @@ import {
} from '@/hooks/use-ipam';
import type { IPAMNetwork, IPAMPool } from '@/types';
import { toast } from 'sonner';
import { useConfirm } from '@/components/shared/ConfirmDialog';
export default function IPAMNetworkDetailPage() {
const { t } = useTranslation();
@@ -223,6 +224,7 @@ const emptyPool = { name: '', pool_type: 'static', range_start: '', range_end: '
function PoolsCard({ networkId, pools }: { networkId: number; pools: IPAMPool[] }) {
const { t } = useTranslation();
const confirm = useConfirm();
const createPool = useCreatePool();
const updatePool = useUpdatePool();
const deletePool = useDeletePool();
@@ -259,8 +261,8 @@ function PoolsCard({ networkId, pools }: { networkId: number; pools: IPAMPool[]
}
};
const handleDelete = (p: IPAMPool) => {
if (!confirm(t('ipam.delete_pool_confirm', { name: p.name }))) return;
const handleDelete = async (p: IPAMPool) => {
if (!await confirm(t('ipam.delete_pool_confirm', { name: p.name }))) return;
deletePool.mutate(p.id, {
onSuccess: () => toast.success(t('ipam.pool_deleted')),
onError: (e: Error) => toast.error(e.message),

View File

@@ -15,6 +15,7 @@ import {
useCleanupOrphans, useLinkAllocations, useAutoAllocate, useNextAvailableIP, useIPHistoryLookup,
} from '@/hooks/use-ipam';
import { toast } from 'sonner';
import { useConfirm } from '@/components/shared/ConfirmDialog';
export default function IPAMToolsPage() {
const { t } = useTranslation();
@@ -174,12 +175,13 @@ function ConflictsCard() {
function OrphansCard() {
const { t } = useTranslation();
const confirm = useConfirm();
const { data, isLoading } = useIPAMOrphans();
const cleanup = useCleanupOrphans();
const orphans = data?.orphans ?? [];
const handleCleanup = () => {
if (!confirm(t('ipam.cleanup_confirm'))) return;
const handleCleanup = async () => {
if (!await confirm(t('ipam.cleanup_confirm'))) return;
cleanup.mutate(undefined, {
onSuccess: (r) => toast.success(`${t('ipam.released')}: ${r.released_count}`),
onError: (e: Error) => toast.error(e.message),