Merge pull request #28 from Alpaq92/menu-ustawienia
Nav: Ustawienia and Administracja at the foot, a column beside an icon rail
This commit is contained in:
@@ -182,8 +182,8 @@ every module, so it says where a leaked credential was issued and whose audit lo
|
||||
leaked app token that could mint would outlive its own revocation (a token row has no parent).
|
||||
Listing and revoking stay open to any credential, because revoking is how a leak is contained.
|
||||
That endpoint has a **screen**: *Połączone aplikacje / Connected apps* (`viewTokens` in
|
||||
`frontend/app.js`), in the main nav rather than under Administration, because everybody holds their
|
||||
own credentials. It is the family's only one — a console that cannot mint leaves curl as the user's
|
||||
`frontend/app.js`), under *Ustawienia / Settings* — the section everybody has, not Administration —
|
||||
because everybody holds their own credentials. It is the family's only one — a console that cannot mint leaves curl as the user's
|
||||
route, which is exactly what the three modules now have — so keep its two promises: it says out loud
|
||||
that a token authenticates in *every* module, and it shows the secret exactly once, in the reply to
|
||||
the mint (`mutate(..., { reopen })`, never the default close-and-re-render).
|
||||
|
||||
@@ -64,13 +64,17 @@ class TestTheScreenExistsAtAll:
|
||||
assert "'#/tokens'" in console
|
||||
|
||||
def test_it_is_everybodys_screen_not_an_administrators(self, console):
|
||||
"""A credential belongs to the person holding it. Putting the entry in ADMIN_NAV would hide
|
||||
it from every user who is not an administrator — which is most of the people who hold a
|
||||
desktop client — and `GET /me/tokens` is guarded by `get_current_user`, not by the tier."""
|
||||
nav = _block(console, "const NAV = [", "];")
|
||||
"""A credential belongs to the person holding it. Putting the entry in ADMIN_NAV, or marking
|
||||
it `admin: true` under Ustawienia, would hide it from every user who is not an administrator —
|
||||
which is most of the people who hold a desktop client — and `GET /me/tokens` is guarded by
|
||||
`get_current_user`, not by the tier."""
|
||||
settings = _block(console, "const SETTINGS_NAV = [", "];")
|
||||
admin_nav = _block(console, "const ADMIN_NAV = [", "];")
|
||||
assert "'#/tokens'" in nav
|
||||
line = next(ln for ln in settings.splitlines() if "'#/tokens'" in ln)
|
||||
assert "admin: true" not in line
|
||||
assert "tokens" not in admin_nav
|
||||
section = next(ln for ln in _block(console, "const SECTIONS = [", "];").splitlines() if "key: 'settings'" in ln)
|
||||
assert "admin: true" not in section, "Ustawienia itself must be everybody's"
|
||||
|
||||
def test_the_routes_it_calls_are_the_ones_that_exist(self, console, users_router):
|
||||
"""The console invents no endpoint: each path it posts to or deletes is declared in the
|
||||
|
||||
@@ -26,7 +26,8 @@ def _block(console: str, start: str, end: str) -> str:
|
||||
|
||||
|
||||
def _menus(console: str) -> str:
|
||||
return _block(console, "const NAV = [", "];") + _block(console, "const ADMIN_NAV = [", "];")
|
||||
return (_block(console, "const NAV = [", "];") + _block(console, "const SETTINGS_NAV = [", "];")
|
||||
+ _block(console, "const ADMIN_NAV = [", "];"))
|
||||
|
||||
|
||||
def _i18n(console: str) -> set[str]:
|
||||
@@ -37,7 +38,8 @@ def _i18n(console: str) -> set[str]:
|
||||
def test_every_admin_screen_is_in_the_menu(console):
|
||||
"""A screen the router serves and no menu reaches is a screen only a bookmark finds."""
|
||||
routed = set(re.findall(r"if \(page === '([a-z]+)'", _block(console, "async function adminRoute(", "\n}\n")))
|
||||
listed = set(re.findall(r"hash: '#/admin/([a-z]+)'", _block(console, "const ADMIN_NAV = [", "];")))
|
||||
listed = set(re.findall(r"hash: '#/admin/([a-z]+)'", _block(console, "const ADMIN_NAV = [", "];")
|
||||
+ _block(console, "const SETTINGS_NAV = [", "];")))
|
||||
# Module administration is a tab of the catalogue ("Moduły"), lit by its menu entry.
|
||||
tabbed = set(re.findall(r"'#/admin/([a-z]+)'", _block(console, "function catalogTabs(", "\n}\n")))
|
||||
assert "'#/admin/modules'" in _block(console, "const NAV = [", "];")
|
||||
@@ -63,7 +65,7 @@ def test_the_screens_that_left_the_menu_still_route(console):
|
||||
def test_every_label_the_menu_shows_is_translated(console):
|
||||
labels = re.findall(r"label: '([^']+)'", _menus(console))
|
||||
heads = re.findall(r"sep: '([^']+)'", _block(console, "const ADMIN_NAV = [", "];"))
|
||||
heads += re.findall(r'<div class="nav-sep">([^<$]+)</div>', _block(console, "function renderNav(", "\n}\n"))
|
||||
heads += re.findall(r"label: '([^']+)', (?:admin|groups)", _block(console, "const SECTIONS = [", "];"))
|
||||
tabs = re.findall(r"'#/[a-z/]+', '([^']+)'\)", _block(console, "function catalogTabs(", "\n}\n"))
|
||||
shown = labels + heads + tabs
|
||||
assert labels and heads and len(tabs) == 3
|
||||
|
||||
@@ -36,8 +36,9 @@ def _i18n(console: str) -> set[str]:
|
||||
def test_the_screen_is_routed_and_administrator_only(console):
|
||||
assert "async function viewAdminProviders(" in console
|
||||
assert "if (page === 'providers') return viewAdminProviders(C);" in console
|
||||
admin_nav = console.split("const ADMIN_NAV = [", 1)[1].split("];", 1)[0]
|
||||
assert "'#/admin/providers'" in admin_nav
|
||||
settings = console.split("const SETTINGS_NAV = [", 1)[1].split("];", 1)[0]
|
||||
line = next(ln for ln in settings.splitlines() if "'#/admin/providers'" in ln)
|
||||
assert "admin: true" in line, "an administrator's entry under Ustawienia"
|
||||
nav = console.split("const NAV = [", 1)[1].split("];", 1)[0]
|
||||
assert "providers" not in nav
|
||||
|
||||
|
||||
@@ -271,6 +271,7 @@ pre.diff {
|
||||
#app.framed { height: 100dvh; overflow: hidden; }
|
||||
#app.framed .content { padding: 0; display: flex; min-height: 0; overflow: hidden; }
|
||||
.modframe { flex: 1; width: 100%; border: 0; display: block; background: var(--at-canvas); }
|
||||
.setframe { height: calc(100vh - 130px); min-height: 420px; border-radius: 8px; }
|
||||
/* A module's nav, mirrored under its entry: indented on a hairline, like a tree. A mirrored item keeps
|
||||
the module's own active class, `.active` or `.on`. */
|
||||
.modnav { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 6px 10px;
|
||||
@@ -281,6 +282,20 @@ pre.diff {
|
||||
.modnav .nav-item.active, .modnav .nav-item.on { background: var(--at-active); color: var(--at-text); font-weight: 550; }
|
||||
.modnav .nav-sep { padding-top: 10px; }
|
||||
#app.nav-min .modnav { display: none; }
|
||||
/* The column beside the rail (renderNav): an open module's menu, or the screens of Ustawienia or
|
||||
Administracja. Collapsing the sidebar folds it away, as legalwork's does: the rail stays. */
|
||||
.modcol { display: none; }
|
||||
#app.mod-col:not(.nav-min) .modcol {
|
||||
display: flex; flex-direction: column; flex: none; width: 228px;
|
||||
position: sticky; top: 0; height: 100vh; overflow: hidden;
|
||||
background: var(--at-sidebar); border-right: 1px solid var(--at-border-subtle);
|
||||
}
|
||||
.modcol-head {
|
||||
display: flex; align-items: center; gap: 10px; flex: none;
|
||||
min-height: var(--at-topbar-h); padding: 12px 16px 10px; font-weight: 600; font-size: 15px;
|
||||
}
|
||||
.modcol-head span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.modcol .modnav { flex: 1; margin-left: 0; border-left: 0; padding: 4px 10px 10px; overflow-y: auto; }
|
||||
.mod-tools { display: flex; align-items: center; gap: 2px; }
|
||||
.mod-tools:empty { display: none; }
|
||||
.modcrumb { display: inline-flex; align-items: center; gap: 6px; }
|
||||
@@ -304,6 +319,12 @@ button.nav-sep.fold:hover { color: var(--at-text); }
|
||||
button.nav-sep.fold svg { width: 14px; height: 14px; margin-left: auto; transition: transform .15s; }
|
||||
button.nav-sep.fold[aria-expanded="false"] svg { transform: rotate(-90deg); }
|
||||
@media (prefers-reduced-motion: reduce) { button.nav-sep.fold svg { transition: none; } }
|
||||
/* On the icon rail a folded group still shows its icons (its head is gone, so nothing could unfold
|
||||
it), and "Dostosuj listę" leaves: beside Ustawienia it would be a second gear. */
|
||||
@media (min-width: 881px) {
|
||||
#app:is(.nav-min, .mod-col) .sidebar [id^="navGroup_"][hidden] { display: block; }
|
||||
#app:is(.nav-min, .mod-col) .sidebar .nav-tune { display: none; }
|
||||
}
|
||||
|
||||
/* ── home: "W skrócie" — stat tiles and 14-day column charts (inline SVG, no library) ── */
|
||||
.home-stats:empty { display: none; }
|
||||
|
||||
+98
-30
@@ -362,6 +362,7 @@ const I18N = {
|
||||
'Organizacja': 'Organization',
|
||||
'Użytkownicy': 'Users',
|
||||
'Ustawienia': 'Settings',
|
||||
'Ogólne': 'General',
|
||||
'Dziennik zdarzeń': 'Audit log',
|
||||
// home + launcher
|
||||
'Witaj,': 'Welcome,',
|
||||
@@ -884,13 +885,19 @@ const NAV = [
|
||||
/* One place for modules: the catalogue for everybody, and for an administrator a "Zarządzanie" tab
|
||||
with the admin table — not a second "Moduły" entry under Administracja. */
|
||||
{ hash: '#/marketplace', icon: 'store', label: 'Moduły', also: ['#/requests', '#/admin/modules'] },
|
||||
/* Not an administrator's screen: everybody holds their own credentials. It is in the main nav
|
||||
rather than tucked inside the account sheet because after the cutover this console is the ONLY
|
||||
place in the family a token can be made — no module holds INSERT on `session` — so a desktop
|
||||
client's user who cannot find it has no way left but curl. */
|
||||
{ hash: '#/tokens', icon: 'key', label: 'Połączone aplikacje' },
|
||||
];
|
||||
// The overview moved onto the dashboard; the rest is grouped by what an administrator is doing.
|
||||
/* Ustawienia, at the foot of the sidebar: everybody's, with an administrator's screens added, and a
|
||||
module's own settings screen for whoever administers that module (settingsModules).
|
||||
"Połączone aplikacje" is not an administrator's screen: everybody holds their own credentials, and
|
||||
after the cutover this console is the ONLY place in the family a token can be made — no module
|
||||
holds INSERT on `session` — so a desktop client's user who cannot find it has no way left but curl. */
|
||||
const SETTINGS_NAV = [
|
||||
{ hash: '#/tokens', icon: 'key', label: 'Połączone aplikacje' },
|
||||
{ hash: '#/admin/settings', icon: 'settings', label: 'Ogólne', admin: true },
|
||||
{ hash: '#/admin/providers', icon: 'globe', label: 'Dostawcy modeli', admin: true },
|
||||
];
|
||||
// Administracja, at the foot under Ustawienia: grouped by what an administrator is doing. The
|
||||
// overview moved onto the dashboard.
|
||||
const ADMIN_NAV = [
|
||||
{ sep: 'Dostęp', items: [
|
||||
{ hash: '#/admin/requests', icon: 'send', label: 'Wnioski', badge: 'pending' },
|
||||
@@ -900,11 +907,46 @@ const ADMIN_NAV = [
|
||||
{ hash: '#/admin/org', icon: 'workspace', label: 'Organizacja' },
|
||||
] },
|
||||
{ sep: 'Platforma', items: [
|
||||
{ hash: '#/admin/settings', icon: 'settings', label: 'Ustawienia' },
|
||||
{ hash: '#/admin/providers', icon: 'key', label: 'Dostawcy modeli' },
|
||||
{ hash: '#/admin/audit', icon: 'history', label: 'Dziennik zdarzeń' },
|
||||
] },
|
||||
];
|
||||
/* A module's own settings screen, shown framed under Ustawienia: slug → its route inside the module.
|
||||
Only for a module that is on (it is in the launcher) and only to whoever administers it. */
|
||||
const MODULE_SETTINGS = { sygna: 'admin', counsel: 'settings' };
|
||||
const administers = (slug) => isAdmin() || ((state.user && state.user.modules) || {})[slug] === 'moderator';
|
||||
const settingsModules = () => state.launcher.filter((m) => MODULE_SETTINGS[m.slug] && embeddable(m) && administers(m.slug));
|
||||
// The two sections at the foot. Each opens on its first screen; its screens stand in the column.
|
||||
const SECTIONS = [
|
||||
{ key: 'settings', icon: 'settings', label: 'Ustawienia', groups: () => [{ items: SETTINGS_NAV
|
||||
.concat(settingsModules().map((m) => ({ hash: '#/settings/' + enc(m.slug), label: m.name, mod: m }))) }] },
|
||||
{ key: 'admin', icon: 'users', label: 'Administracja', admin: true, groups: () => ADMIN_NAV },
|
||||
];
|
||||
const curHash = () => (location.hash || '#/').split('?')[0];
|
||||
const navOn = (n, cur) => (n.exact ? cur === n.hash : (cur === n.hash || cur.startsWith(n.hash + '/')))
|
||||
|| (n.also || []).some((h) => cur === h || cur.startsWith(h + '/'));
|
||||
const sectionItems = (s) => s.groups().flatMap((g) => g.items).filter((n) => !n.admin || isAdmin());
|
||||
const sectionOf = (cur) => SECTIONS.find((s) => (!s.admin || isAdmin()) && sectionItems(s).some((n) => navOn(n, cur)));
|
||||
const pendingBadge = (on) => (on && state.pending ? `<span class="cnt hot">${esc(String(state.pending))}</span>` : '');
|
||||
function navItem(n, cur) {
|
||||
const icon = n.mod ? moduleIcon(n.mod, 18) : svg(ICN[n.icon]);
|
||||
return `<a class="nav-item ${navOn(n, cur) ? 'on' : ''}" href="${esc(n.hash)}"${n.mod ? ' data-no-i18n' : ''}>`
|
||||
+ `${icon}<span>${esc(n.label)}</span>${pendingBadge(n.badge === 'pending')}</a>`;
|
||||
}
|
||||
// A section's screens, under their group heads: in the column beside the rail, or under the
|
||||
// section's entry in the drawer.
|
||||
const sectionList = (s, cur) => s.groups().map((g) => {
|
||||
const items = g.items.filter((n) => !n.admin || isAdmin()).map((n) => navItem(n, cur)).join('');
|
||||
return items && (g.sep ? `<div class="nav-sep">${esc(g.sep)}</div>` : '') + items;
|
||||
}).join('');
|
||||
|
||||
/* legalwork's layout: an open module, Ustawienia and Administracja each get a column of their own
|
||||
beside the icon rail, their whole menu in it. Galena and Compass keep their menu nested under their
|
||||
entry for now. Only on a wide screen: under 881px the sidebar is a drawer, one column. */
|
||||
const NESTED_NAV = new Set(['galena', 'compass']);
|
||||
const NARROW = window.matchMedia('(max-width: 880px)');
|
||||
NARROW.addEventListener('change', () => { if (state.user) renderNav(); });
|
||||
const ownColumn = () => frame.slug && !NESTED_NAV.has(frame.slug) && !NARROW.matches;
|
||||
const colHead = (icon, label, raw) => `<div class="modcol-head"${raw ? ' data-no-i18n' : ''}>${icon}<span>${esc(label)}</span></div>`;
|
||||
|
||||
// Sidebar sections fold (Aplikacje, Administracja); the choice is remembered per browser, and a
|
||||
// section is always open while you are inside it, so the page you are on never loses its place.
|
||||
@@ -924,26 +966,29 @@ function toggleNavGroup(btn) {
|
||||
}
|
||||
|
||||
function renderNav() {
|
||||
const cur = (location.hash || '#/').split('?')[0];
|
||||
const under = (h) => cur === h || cur.startsWith(h + '/');
|
||||
const item = (n) => {
|
||||
const on = (n.exact ? cur === n.hash : under(n.hash)) || (n.also || []).some(under);
|
||||
const c = n.badge === 'pending' ? state.pending : 0;
|
||||
const badge = c ? `<span class="cnt hot">${esc(String(c))}</span>` : '';
|
||||
return `<a class="nav-item ${on ? 'on' : ''}" href="${n.hash}">${svg(ICN[n.icon])}<span>${esc(n.label)}</span>${badge}</a>`;
|
||||
};
|
||||
const cur = curHash();
|
||||
const sec = sectionOf(cur);
|
||||
const modCol = ownColumn() && state.launcher.find((m) => m.slug === frame.slug);
|
||||
const secCol = !modCol && !NARROW.matches && sec;
|
||||
$('app').classList.toggle('mod-col', !!(modCol || secCol));
|
||||
$('modCol').innerHTML = modCol
|
||||
? colHead(moduleIcon(modCol, 22), modCol.name, true) + '<nav class="nav modnav" id="modNav" data-no-i18n></nav>'
|
||||
: (secCol ? colHead(svg(ICN[secCol.icon], 20), secCol.label) + `<nav class="nav modnav">${sectionList(secCol, cur)}</nav>` : '');
|
||||
const mods = navModules();
|
||||
const modItem = (m) => `<a class="nav-item ${frame.slug === m.slug ? 'on' : ''}" href="${esc(frameHash(m.slug))}" data-no-i18n>`
|
||||
+ `${moduleIcon(m, 18)}<span>${esc(m.name)}</span></a>`
|
||||
+ (frame.slug === m.slug ? '<div class="modnav" id="modNav" data-no-i18n></div>' : '');
|
||||
$('nav').innerHTML = NAV.map(item).join('')
|
||||
+ (frame.slug === m.slug && !modCol ? '<div class="modnav" id="modNav" data-no-i18n></div>' : '');
|
||||
$('nav').innerHTML = NAV.map((n) => navItem(n, cur)).join('')
|
||||
+ (mods.length || state.launcher.some(embeddable)
|
||||
? navGroup('apps', 'Aplikacje', mods.map(modItem).join('')
|
||||
+ `<button type="button" class="nav-item nav-tune" onclick="openNavPrefs()">${svg(ICN.settings)}<span>Dostosuj listę</span></button>`, !!frame.slug)
|
||||
: '')
|
||||
+ (isAdmin() ? ADMIN_NAV.map((g, i) => navGroup('admin' + i, g.sep, g.items.map(item).join(''),
|
||||
g.items.some((n) => under(n.hash)))).join('') : '');
|
||||
: '');
|
||||
$('navFoot').innerHTML = SECTIONS.filter((s) => !s.admin || isAdmin()).map((s) =>
|
||||
`<a class="nav-item ${sec === s ? 'on' : ''}" href="${esc(sectionItems(s)[0].hash)}">${svg(ICN[s.icon])}<span>${esc(s.label)}</span>`
|
||||
+ `${pendingBadge(s.key === 'admin')}</a>`
|
||||
+ (sec === s && !secCol ? `<div class="modnav">${sectionList(s, cur)}</div>` : '')).join('');
|
||||
localize($('sidebar'));
|
||||
localize($('modCol'));
|
||||
if (frame.win) mirror();
|
||||
}
|
||||
|
||||
@@ -1011,6 +1056,7 @@ async function router() {
|
||||
else if (seg[0] === 'marketplace') await viewMarketplace(C, q);
|
||||
else if (seg[0] === 'requests') await viewMyRequests(C);
|
||||
else if (seg[0] === 'tokens') await viewTokens(C);
|
||||
else if (seg[0] === 'settings' && seg[1]) viewModuleSettings(C, seg[1]);
|
||||
else if (seg[0] === 'admin' && isAdmin()) await adminRoute(C, seg.slice(1), q);
|
||||
else { setCrumb([]); C.innerHTML = '<div class="empty">Nie znaleziono strony.</div>'; }
|
||||
} catch (ex) {
|
||||
@@ -3327,7 +3373,7 @@ async function viewTokens(C) {
|
||||
// Kept so the revoke dialog can name a token from state instead of interpolating its name into
|
||||
// markup — the same reason the module pages look a row up rather than passing it around.
|
||||
state._tokens = tokens;
|
||||
setCrumb([{ label: 'Połączone aplikacje' }]);
|
||||
setCrumb([{ label: 'Ustawienia' }, { label: 'Połączone aplikacje' }]);
|
||||
const live = tokens.filter((t) => !t.revoked_at);
|
||||
const reach = sharesIdentity()
|
||||
? 'Token działa w każdym module platformy — przedrostek mówi, gdzie powstał, a nie gdzie działa.'
|
||||
@@ -4077,7 +4123,7 @@ const SETTING_UI = {
|
||||
|
||||
async function viewAdminSettings(C) {
|
||||
const specs = await api('GET', '/admin/settings');
|
||||
setCrumb([{ label: 'Administracja' }, { label: 'Ustawienia' }]);
|
||||
setCrumb([{ label: 'Ustawienia' }, { label: 'Ogólne' }]);
|
||||
const input = (s) => {
|
||||
const ui = SETTING_UI[s.key] || { label: s.key };
|
||||
const id = 'st_' + s.key;
|
||||
@@ -4095,7 +4141,7 @@ async function viewAdminSettings(C) {
|
||||
? `<label class="field">${esc(ui.label)}<textarea id="${id}" ${max}>${esc(s.value)}</textarea></label>${help}`
|
||||
: `<label class="field">${esc(ui.label)}<input id="${id}" ${max} value="${esc(s.value)}" /></label>${help}`;
|
||||
};
|
||||
C.innerHTML = pageHead('Ustawienia', '')
|
||||
C.innerHTML = pageHead('Ogólne', '')
|
||||
+ `<div class="card settings"><div class="stack">${specs.map((s) => `<div>${input(s)}</div>`).join('')}</div>
|
||||
<div class="acts-row"><button class="btn primary" onclick="saveSettings()">${svg(ICN.check)}<span>Zapisz</span></button></div></div>`;
|
||||
state._settings = specs;
|
||||
@@ -4128,7 +4174,7 @@ async function viewAdminProviders(C) {
|
||||
api('GET', '/admin/model-providers/policy')]);
|
||||
state._providers = rows;
|
||||
state._providerPolicy = policy;
|
||||
setCrumb([{ label: 'Administracja' }, { label: 'Dostawcy modeli' }]);
|
||||
setCrumb([{ label: 'Ustawienia' }, { label: 'Dostawcy modeli' }]);
|
||||
const kindChip = (p) => `<span class="chip">${esc(PROVIDER_KIND[p.kind] || p.kind)}</span>`;
|
||||
const euChip = (p) => (p.stays_in_the_eu ? '<span class="chip ok">UE/EOG</span>' : '<span class="chip warn">poza UE</span>');
|
||||
const keyCell = (p) => (p.has_key
|
||||
@@ -4444,6 +4490,31 @@ function showFrame(slug, inner) {
|
||||
closeDrawer();
|
||||
}
|
||||
|
||||
// The frame draws the workspace's edge and corner; the module's own copy of them would show inside
|
||||
// it as a second line.
|
||||
const FRAME_CHROME_CSS = '#sidebar,.sidebar,#navScrim,.nav-scrim,.topbar{display:none!important}'
|
||||
+ '#app{background:var(--at-canvas,inherit)!important}'
|
||||
+ '.content{border:0!important;border-radius:0!important}';
|
||||
|
||||
/* A module's settings screen inside Ustawienia: the module page without its own chrome. Not the
|
||||
module frame (showFrame): no mirrored nav, the sidebar stays on Ustawienia. */
|
||||
function viewModuleSettings(C, slug) {
|
||||
const m = settingsModules().find((x) => x.slug === slug);
|
||||
if (!m) { setCrumb([]); C.innerHTML = '<div class="empty">Nie znaleziono strony.</div>'; return; }
|
||||
setCrumb([{ label: 'Ustawienia' }, { label: m.name, data: true }]);
|
||||
seedModulePrefs(slug);
|
||||
const u = new URL(safeUrl(m.url), document.baseURI);
|
||||
u.hash = '#/' + MODULE_SETTINGS[slug];
|
||||
C.innerHTML = `<iframe class="modframe setframe" title="${esc(m.name)}" src="${esc(u.href)}"></iframe>`;
|
||||
C.firstChild.addEventListener('load', (e) => {
|
||||
try {
|
||||
const st = e.target.contentDocument.createElement('style');
|
||||
st.textContent = FRAME_CHROME_CSS;
|
||||
e.target.contentDocument.head.appendChild(st);
|
||||
} catch { /* another origin: shown as it is */ }
|
||||
});
|
||||
}
|
||||
|
||||
function attachFrame(m) {
|
||||
if (!frame.el || frame.slug !== m.slug) return;
|
||||
let win, doc;
|
||||
@@ -4467,11 +4538,7 @@ function attachFrame(m) {
|
||||
if (frame.obs) frame.obs.disconnect();
|
||||
frame.win = win;
|
||||
const st = doc.createElement('style');
|
||||
// The frame draws the workspace's edge and corner; the module's own copy of them would show
|
||||
// inside it as a second line.
|
||||
st.textContent = '#sidebar,.sidebar,#navScrim,.nav-scrim,.topbar{display:none!important}'
|
||||
+ '#app{background:var(--at-canvas,inherit)!important}'
|
||||
+ '.content{border:0!important;border-radius:0!important}';
|
||||
st.textContent = FRAME_CHROME_CSS;
|
||||
doc.head.appendChild(st);
|
||||
win.addEventListener('hashchange', () => {
|
||||
history.replaceState(null, '', frameHash(m.slug, innerOf(win)));
|
||||
@@ -4716,6 +4783,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
searchBtn.querySelector('.si').innerHTML = svg(ICN.search, 14);
|
||||
searchBtn.addEventListener('click', openFrameSearch);
|
||||
$('sidebar').addEventListener('click', forwardMirrored);
|
||||
$('modCol').addEventListener('click', forwardMirrored);
|
||||
document.querySelector('.topbar').addEventListener('click', forwardMirrored);
|
||||
$('aUser').addEventListener('click', openAccount);
|
||||
|
||||
|
||||
@@ -54,7 +54,9 @@
|
||||
<button class="iconbtn" id="navCollapse" title="Zwiń panel (Ctrl+B)" aria-label="Zwiń panel" aria-pressed="false"></button>
|
||||
</div>
|
||||
<nav class="nav" id="nav"></nav>
|
||||
<nav class="nav sidebar-foot" id="navFoot"></nav>
|
||||
</aside>
|
||||
<aside class="modcol" id="modCol"></aside>
|
||||
<div id="navScrim"></div>
|
||||
<div class="main">
|
||||
<header class="topbar">
|
||||
|
||||
+33
-12
@@ -99,15 +99,15 @@ a:hover { text-decoration: underline; }
|
||||
.nav-sep::before { content: ""; width: 6px; height: 6px; border-radius: 1px; background: var(--at-text); flex: none; }
|
||||
.sidebar-foot { flex: none; border-top: 1px solid var(--at-border-subtle); padding-bottom: 10px; }
|
||||
|
||||
/* Collapse to icons (Ctrl/⌘+B or #navCollapse, wired by shell.js). Labels live in a <span> in every
|
||||
console's nav markup, which is what lets one rule hide them. */
|
||||
/* Collapse to icons (Ctrl/⌘+B or #navCollapse, wired by shell.js): the rail itself is drawn under
|
||||
the breakpoints, because only a sidebar that is a column can be one — under 881px it is a drawer. */
|
||||
#navCollapse { margin-left: auto; flex: none; }
|
||||
#app.nav-min .sidebar { width: var(--at-sidebar-min-w); }
|
||||
#app.nav-min .brand { flex-direction: column; gap: 8px; padding: 12px 0 8px; }
|
||||
#app.nav-min #navCollapse { margin-left: 0; transform: scaleX(-1); }
|
||||
#app.nav-min .brand .nm, #app.nav-min .sidebar .nav-item > span, #app.nav-min .sidebar .nav-item .cnt,
|
||||
#app.nav-min .nav-sep { display: none; }
|
||||
#app.nav-min .sidebar .nav-item { justify-content: center; padding: 0; }
|
||||
/* The collapsed rail's hint (shell.js): the label beside the icon, as legalwork's tooltip does. */
|
||||
.nav-tip {
|
||||
position: fixed; z-index: 50; transform: translateY(-50%); pointer-events: none;
|
||||
background: var(--at-text); color: var(--at-canvas); font-size: 12px; font-weight: 500;
|
||||
padding: 4px 8px; border-radius: var(--at-radius-md); white-space: nowrap; box-shadow: var(--at-shadow-md);
|
||||
}
|
||||
|
||||
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--at-canvas); }
|
||||
.topbar {
|
||||
@@ -458,6 +458,31 @@ td.mono { font-family: var(--at-font-mono); font-size: 12.5px; }
|
||||
}
|
||||
|
||||
/* ── breakpoints (widest first, always last) ─────────────────────────────── */
|
||||
/* The icon rail: the sidebar collapsed, or standing beside a module's own column (Atrium's `.mod-col`).
|
||||
Labels live in a <span> in every console's nav markup, which is what lets one rule hide them. */
|
||||
@media (min-width: 881px) {
|
||||
#app:is(.nav-min, .mod-col) .sidebar { width: var(--at-sidebar-min-w); }
|
||||
#app:is(.nav-min, .mod-col) .brand { flex-direction: column; gap: 8px; padding: 12px 0 8px; }
|
||||
#app:is(.nav-min, .mod-col) #navCollapse { margin-left: 0; }
|
||||
#app.nav-min #navCollapse { transform: scaleX(-1); }
|
||||
#app:is(.nav-min, .mod-col) .brand .nm, #app:is(.nav-min, .mod-col) .sidebar .nav-item .cnt,
|
||||
#app:is(.nav-min, .mod-col) .sidebar .nav-sep { display: none; }
|
||||
/* The label is hidden from sight, not from a screen reader: it stays the link's name, and the
|
||||
hint reads it. A console's icon may itself be a <span> (Atrium's `.mi`), so the first span stays. */
|
||||
#app:is(.nav-min, .mod-col) .sidebar .nav-item > span:not(:first-child):not(.cnt) {
|
||||
position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
|
||||
}
|
||||
/* legalwork's icon rail: square tiles centred in the rail, the active one keeping its ground. */
|
||||
#app:is(.nav-min, .mod-col) .sidebar .nav { align-items: center; padding: 8px 0; }
|
||||
#app:is(.nav-min, .mod-col) .sidebar .nav-item {
|
||||
justify-content: center; gap: 0; padding: 0; width: 38px; min-height: 38px; position: relative;
|
||||
}
|
||||
/* A pending count survives as a dot on the icon's corner. */
|
||||
#app:is(.nav-min, .mod-col) .sidebar .nav-item .cnt.hot {
|
||||
display: block; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; padding: 0;
|
||||
font-size: 0; background: var(--at-danger);
|
||||
}
|
||||
}
|
||||
@media (max-width: 1100px) { .col-opt { display: none !important; } }
|
||||
|
||||
@media (max-width: 880px) {
|
||||
@@ -472,10 +497,6 @@ td.mono { font-family: var(--at-font-mono); font-size: 12.5px; }
|
||||
transition: transform .18s;
|
||||
}
|
||||
.sidebar.open { transform: none; visibility: visible; }
|
||||
#app.nav-min .sidebar { width: var(--at-sidebar-w); }
|
||||
#app.nav-min .brand { flex-direction: row; padding: 12px 14px 10px 16px; }
|
||||
#app.nav-min .brand .nm, #app.nav-min .sidebar .nav-item > span { display: revert; }
|
||||
#app.nav-min .sidebar .nav-item { justify-content: flex-start; padding: 0 12px; }
|
||||
#navCollapse { display: none; }
|
||||
#navToggle { display: inline-flex; }
|
||||
#navScrim.on { display: block; position: fixed; inset: 0; background: var(--at-overlay); z-index: 19; }
|
||||
|
||||
@@ -21,6 +21,29 @@
|
||||
document.addEventListener('click', function (ev) {
|
||||
if (ev.target.closest && ev.target.closest('#navCollapse')) set(!app.classList.contains('nav-min'));
|
||||
});
|
||||
// As a rail (collapsed, or beside a module's column), the sidebar is icons only; its hint names the
|
||||
// one under the pointer or the focus, at once, where a title attribute would wait a second and say
|
||||
// nothing to the keyboard. Positioned fixed
|
||||
// because the nav scrolls, and a scrolling box clips anything that hangs out of it.
|
||||
var tip = document.createElement('div');
|
||||
tip.className = 'nav-tip'; tip.hidden = true; tip.setAttribute('aria-hidden', 'true');
|
||||
document.body.appendChild(tip);
|
||||
function hint(ev) {
|
||||
var a = ev.target.closest && ev.target.closest('.sidebar .nav-item');
|
||||
var label = a && a.closest('.sidebar').offsetWidth < 100 && a.querySelector(':scope > span:not(:first-child):not(.cnt)');
|
||||
if (!label) { tip.hidden = true; return; }
|
||||
var r = a.getBoundingClientRect();
|
||||
tip.textContent = label.textContent;
|
||||
tip.style.top = (r.top + r.height / 2) + 'px';
|
||||
tip.style.left = (r.right + 10) + 'px';
|
||||
tip.hidden = false;
|
||||
}
|
||||
document.addEventListener('mouseover', hint);
|
||||
document.addEventListener('focusin', hint);
|
||||
['click', 'scroll', 'focusout'].forEach(function (t) {
|
||||
document.addEventListener(t, function () { tip.hidden = true; }, true);
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function (ev) {
|
||||
if ((ev.ctrlKey || ev.metaKey) && !ev.altKey && !ev.shiftKey && (ev.key === 'b' || ev.key === 'B')) {
|
||||
var t = ev.target;
|
||||
|
||||
Reference in New Issue
Block a user