Zone page: links to the same zone in the other views

The header says "also in VIEW" for every zone of the same name in
another view, linked or not, in the view's colour, keeping the open tab
where the other zone has it. The zone API gains in_views.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adamandClaude Opus 5.5 committed 2026-10-18 15:45:41 +01:00
1 parent a36c54ce60
commit 4cc2ab2287
7 files changed
+58 -2

No files matched your search

+17 -1
View File
@@ -9,6 +9,15 @@ import { registrarTab } from "./registrar.js";
let renderSeq = 0;
// tabIn is the "/tab" part of the address of zone o (an in_views entry)
// that keeps the tab open now, when o has that tab.
function tabIn(o, tab) {
if (!tab || tab === "registrar") return "";
if (["records", "file", "dnssec", "compare"].includes(tab) && o.type !== "primary") return "";
if (tab === "servers" && !["primary", "secondary", "mirror"].includes(o.type)) return "";
return "/" + tab;
}
export async function render(el, params, query) {
const id = params.id;
const [zone, views] = await Promise.all([get("/zones/" + id, draftQuery()), get("/views")]);
@@ -33,12 +42,19 @@ export async function render(el, params, query) {
badge(zone.type, "accent"), " ",
zone.pending ? [pendingBadge(zone.pending), " "] : null,
zone.view ? ["view ", viewLink(view, zone.view, "#/zones/" + id + (params.tab ? "/" + params.tab : "")), " · "] : null,
zone.in_views ? [h("span", { title: "The zone " + zone.display_name + " in another view" }, "also in ",
zone.in_views.map((o, i) => {
const v = views.find((x) => x.name === o.view);
return [i ? ", " : "", h("a", { href: "#/zones/" + o.id + tabIn(o, params.tab), class: v && v.color ? "vc-" + v.color : null,
title: "Go to " + zone.display_name + " in view " + o.view + (o.type !== zone.type ? " (" + o.type + ")" : "") + (o.linked ? ", linked with this one" : "") }, o.view),
o.type !== zone.type ? h("span", { class: "muted" }, " (" + o.type + ")") : null];
})), " · "] : null,
zone.type === "primary" ? "serial " + zone.soa.serial + " · " : null,
zone.prefix ? h("span", { class: "mono" }, zone.prefix + " · ") : null,
zone.auto_ptr ? [h("a", { href: "#/zones/" + id + "/settings", title: "Adding, changing, disabling or deleting an A or AAAA record does the same to its PTR record" }, badge("PTRs kept in step", "ok")), " "] : null,
zone.dnssec_policy ? [h("a", { href: "#/zones/" + id + "/dnssec" }, badge(zone.dnssec_policy === "insecure" ? "DNSSEC: turning off" : "DNSSEC", zone.dnssec_policy === "insecure" ? "warn" : "ok")), " "] : null,
zone.links ? [h("span", { class: "badge accent" }, "linked with ",
zone.links.map((l, i) => [i ? ", " : "", h("a", { href: "#/zones/" + l.id + (params.tab ? "/" + params.tab : ""), title: "The zone in view " + l.view }, l.view)])), " "] : null,
zone.links.map((l, i) => [i ? ", " : "", h("a", { href: "#/zones/" + l.id + tabIn({ type: zone.type }, params.tab), title: "The zone in view " + l.view }, l.view)])), " "] : null,
zone.zone_file ? h("span", { class: "mono small" }, zone.zone_file) : null)),
h("div", { class: "actions" },
zone.disabled