diff --git a/static/svrnty_nav.js b/static/svrnty_nav.js index 5729cf5..bb229c7 100644 --- a/static/svrnty_nav.js +++ b/static/svrnty_nav.js @@ -1,4 +1,4 @@ -// svrnty_nav.js — injects Adwright + BTE sidebar buttons into hermes-webui's +// svrnty_nav.js — injects Svrnty sidebar buttons into hermes-webui's // .sidebar-nav and wraps switchPanel so our panels participate in the existing // main-view show/hide system (showing- on
). // @@ -22,10 +22,19 @@ '', bte: '', + graph: + '', }; const TABS = [ { id: "adwright", label: "Adwright", tooltip: "Adwright — marketing intelligence" }, { id: "bte", label: "BTE", tooltip: "BTE — brand creative studio" }, + { + id: "project-graph", + label: "Project Graph", + tooltip: "Project Graph — open workspace graph", + href: "/plugins/svrnty/umbrella.html", + icon: "graph", + }, ]; function _svg(iconPath, size, stroke) { @@ -72,9 +81,13 @@ btn.setAttribute("data-label", t.label); btn.setAttribute("data-tooltip", t.tooltip); btn.setAttribute("aria-label", t.label); - btn.innerHTML = _svg(ICONS[t.id], c.size, c.stroke); + btn.innerHTML = _svg(ICONS[t.icon || t.id], c.size, c.stroke); btn.addEventListener("click", () => { LOG("clicked:", t.id); + if (t.href) { + window.open(t.href, "_blank", "noopener,noreferrer"); + return; + } if (typeof window.switchPanel === "function") { window.switchPanel(t.id, { fromRailClick: true }); } else { @@ -103,7 +116,7 @@ if (typeof window.switchPanel !== "function") return false; if (window.switchPanel.__svrntyWrapped) return true; const original = window.switchPanel; - const OUR_IDS = TABS.map((t) => t.id); + const OUR_IDS = TABS.filter((t) => !t.href).map((t) => t.id); async function wrapped(name, opts) { const result = await original(name, opts); diff --git a/tests/unit/test_svrnty_nav_js.py b/tests/unit/test_svrnty_nav_js.py new file mode 100644 index 0000000..67237c7 --- /dev/null +++ b/tests/unit/test_svrnty_nav_js.py @@ -0,0 +1,17 @@ +"""Static checks for the Svrnty sidebar navigation injection.""" + +from pathlib import Path + +NAV_JS = Path(__file__).resolve().parents[2] / "static" / "svrnty_nav.js" + + +def test_project_graph_nav_opens_umbrella_page_in_new_tab(): + src = NAV_JS.read_text() + assert "Project Graph" in src + assert "/plugins/svrnty/umbrella.html" in src + assert 'window.open(t.href, "_blank", "noopener,noreferrer")' in src + + +def test_project_graph_does_not_participate_in_panel_switching(): + src = NAV_JS.read_text() + assert "TABS.filter((t) => !t.href).map((t) => t.id)" in src