This commit is contained in:
parent
4ad595506a
commit
4b1f2075ae
@ -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-<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"/>',
|
||||
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"/>',
|
||||
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 = [
|
||||
{ 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);
|
||||
|
||||
17
tests/unit/test_svrnty_nav_js.py
Normal file
17
tests/unit/test_svrnty_nav_js.py
Normal 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
|
||||
Loading…
Reference in New Issue
Block a user