Delete Technitium zones from the DNS page

A Delete zone button on the open zone of a Technitium provider deletes the zone
and every record in it: the name has to be typed, and the server checks it
against the zone as the provider lists it now (so a stale page, a wrong id or
an internal zone cannot be deleted by mistake). What this app cached of the
zone and its records goes with it. Technitium's own refusal is shown and
nothing is changed. Administrators only, audited with how many records were
cached; the adapter gets an optional deleteZone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-01 22:51:19 +01:00
1 parent 0244f5a8ab
commit 082c524125
10 files changed
+197 -16

No files matched your search

+33 -1
View File
@@ -20,9 +20,10 @@ import SortableTh from "../components/SortableTh";
import { usePagination } from "../hooks/usePagination";
import Pagination from "../components/Pagination";
import { downloadCsv } from "../utils/csv";
import { confirmDialog } from "../utils/dialogs";
import { confirmDialog, promptDialog } from "../utils/dialogs";
import { ErrorNotice } from "../components/Notice";
import { toast } from "../utils/toast";
import { readableError } from "../utils/errors";
import { EmptyRow, LoadingRow } from "../components/EmptyState";
const PROVIDER_LABELS: Record<DnsProviderType, string> = {
@@ -242,6 +243,32 @@ function DnsRecords({ user, tabs }: { user: CurrentUser; tabs: ReactNode }) {
}
}
/** Deletes the open zone, and every record in it, on the provider. The name of the zone has to be typed. */
async function deleteZone() {
if (!selectedProviderId || !selectedZone || !selectedProvider) return;
const zone = selectedZone;
const cached = zone.recordCount > 0 ? ` (${zone.recordCount} record${zone.recordCount === 1 ? " is" : "s are"} cached here)` : "";
const typed = await promptDialog({
title: "Delete zone",
message: `This deletes the zone "${zone.name}" on ${selectedProvider.name}, and every record in it${cached}, for good. It cannot be undone, and what uses this server stops finding the names in it. Type the name of the zone to confirm.`,
label: "Zone name",
confirmLabel: "Delete",
required: true,
});
if (typed === null) return;
if (typed.trim() !== zone.name) {
toast.error("That is not the name of the zone, so nothing was deleted.");
return;
}
try {
await api.dns.zones.remove(selectedProviderId, zone.id, zone.name);
toast.success(`Deleted the zone ${zone.name}.`);
loadZones(selectedProviderId);
} catch (err) {
toast.error(readableError(err));
}
}
async function removeProvider(p: DnsProviderSummary) {
if (!(await confirmDialog({ title: "Delete DNS provider", message: `Delete provider "${p.name}"? This removes its cached zones and records too.`, confirmLabel: "Delete", danger: true }))) return;
try {
@@ -529,6 +556,11 @@ function DnsRecords({ user, tabs }: { user: CurrentUser; tabs: ReactNode }) {
Add record
</button>
)}
{isAdmin && selectedProvider?.canDeleteZones && selectedProvider.enabled && (
<button className="btn btn-sm btn-outline-danger ms-2" onClick={() => void deleteZone()}>
Delete zone
</button>
)}
</div>
</div>