Add Project Graph nav link
Some checks failed
plugin-tests / test (push) Failing after 5s

This commit is contained in:
Svrnty 2026-05-26 05:26:15 -04:00
parent 4ad595506a
commit 4b1f2075ae
2 changed files with 33 additions and 3 deletions

View File

@ -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 // .sidebar-nav and wraps switchPanel so our panels participate in the existing
// main-view show/hide system (showing-<name> on <main>). // main-view show/hide system (showing-<name> on <main>).
// //
@ -22,10 +22,19 @@
'<circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="6"/><circle cx="12" cy="12" r="2"/>', '<circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="6"/><circle cx="12" cy="12" r="2"/>',
bte: bte:
'<path d="M12 2l1.8 5.6L19.4 9.4l-4.5 3.3 1.7 5.7L12 15l-4.6 3.4 1.7-5.7L4.6 9.4l5.6-1.8L12 2z"/>', '<path d="M12 2l1.8 5.6L19.4 9.4l-4.5 3.3 1.7 5.7L12 15l-4.6 3.4 1.7-5.7L4.6 9.4l5.6-1.8L12 2z"/>',
graph:
'<circle cx="5" cy="12" r="2"/><circle cx="12" cy="5" r="2"/><circle cx="19" cy="12" r="2"/><circle cx="12" cy="19" r="2"/><path d="M6.7 10.6l3.9-4"/><path d="M13.4 6.6l3.9 4"/><path d="M17.3 13.4l-3.9 4"/><path d="M10.6 17.4l-3.9-4"/><path d="M7 12h10"/>',
}; };
const TABS = [ const TABS = [
{ id: "adwright", label: "Adwright", tooltip: "Adwright — marketing intelligence" }, { id: "adwright", label: "Adwright", tooltip: "Adwright — marketing intelligence" },
{ id: "bte", label: "BTE", tooltip: "BTE — brand creative studio" }, { 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) { function _svg(iconPath, size, stroke) {
@ -72,9 +81,13 @@
btn.setAttribute("data-label", t.label); btn.setAttribute("data-label", t.label);
btn.setAttribute("data-tooltip", t.tooltip); btn.setAttribute("data-tooltip", t.tooltip);
btn.setAttribute("aria-label", t.label); 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", () => { btn.addEventListener("click", () => {
LOG("clicked:", t.id); LOG("clicked:", t.id);
if (t.href) {
window.open(t.href, "_blank", "noopener,noreferrer");
return;
}
if (typeof window.switchPanel === "function") { if (typeof window.switchPanel === "function") {
window.switchPanel(t.id, { fromRailClick: true }); window.switchPanel(t.id, { fromRailClick: true });
} else { } else {
@ -103,7 +116,7 @@
if (typeof window.switchPanel !== "function") return false; if (typeof window.switchPanel !== "function") return false;
if (window.switchPanel.__svrntyWrapped) return true; if (window.switchPanel.__svrntyWrapped) return true;
const original = window.switchPanel; 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) { async function wrapped(name, opts) {
const result = await original(name, opts); const result = await original(name, opts);

View File

@ -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