mirror of
https://github.com/wekan/wekan.git
synced 2026-11-26 20:45:07 -05:00
The four pages sat at the TOP level - /settings, /people, /attachments - as if they were pages of the app rather than of the Admin Panel, and /attachments is also the path the file server serves attachments from (server/routes/universalFileServer.js), so the panel and the files were claiming one address. They are under /admin now: /admin/settings/version, /admin/people/login, /admin/problems/database, /admin/attachments/backup. The default pane is named too. It used to be left implicit in a bare page URL - /settings rather than /settings/version - so the address of "Settings" and the address of "Settings showing Version" were one string. The address is meant to say where you are, and the first pane is somewhere too. The bare /admin/settings still resolves; it redirects to the pane's own address rather than being a second name for it. Every path the panel used to answer on redirects - the bare old address, the old one with a pane in it, and /setting, /information, /translation. They are built from the same map the URLs are, so a page cannot be given an address without also being given its redirect, and a bookmarked /settings/global-webhooks keeps its pane instead of landing on the top of the panel. The title beside the house icon names the same three things: Admin Panel / Settings / Version. The page's words are the tab's own key and the pane's words are the menu row's own label, so the title, the tab that is marked active, and the row that opened the pane cannot say different things about one place. The pane title is read from the URL rather than from the page, because the header is a separate Blaze instance from the Admin Panel's pages and must not import them - doing that once ran a page module before its own template was registered, and the throw aborted every module after it. That makes ADMIN_PANE_TITLES a second copy of the menus' labels, and a guard checks every entry of it against the real menu entry for that pane. The button of the page you are ON keeps the hover background, permanently and a shade darker. The tabs had marked themselves .active all along, but the only rule that drew it was scoped to #header-main-bar - the second bar, which those tabs no longer live in - so the state had been computed and invisible since they moved. Darker than the hover rather than equal to it: hovering the tab you are already on must still look like a hover. --wekan-header-height measured #header - the SECOND bar - from when every page had one. Most pages have none now, so on those the variable was 0 and everything laid out against it started at the top of the WINDOW, underneath the first bar: the All Boards sidebar covered it. It measures both bars now, as the BOTTOM of the lowest rather than a sum of heights, so any margin between them counts and a bar that is absent contributes nothing without a special case - and each bar has its own ResizeObserver, because the first one wrapping to a second row is a resize of that element and of nothing else. A divider after the notification bell. Everything before it belongs to the page - its controls, its view menu, the panel's tabs; everything after belongs to you - help, your account, the sidebar toggle. Without it the run of icons reads as one list of unrelated things. The URLs went through a hyphenated shape - /admin-settings-version, /allboards-starred - before xet7 asked for the slash form instead. All Boards is back to exactly what it was; only the Admin Panel moved. Guards: tests/adminUrls.test.cjs pins the /admin prefix, that every pane is named in its URL including the default, that each page records the path it used to answer on, that the three redirect shapes exist and carry the pane along, and that every pane title matches the real menu entry's label - both directions, and a translation key has to be a real one. tests/headerBars pins the divider and the darker active mark; tests/sidebarBelowHeader pins that the height covers both bars. tests/adminOldUrlRedirect's route-body helper now understands a route whose path is an expression, since the panel's four take theirs from adminRoutePath(page) so the route and the links cannot disagree. Thanks to xet7 !
77 lines
4.0 KiB
JavaScript
77 lines
4.0 KiB
JavaScript
'use strict';
|
|
|
|
// The right sidebar's upper part was hidden behind the header bars.
|
|
//
|
|
// On a phone the sidebar is `position: fixed` - it has to be, or it pins to the
|
|
// far right of a board that is wider than the screen and shows as a narrow strip.
|
|
// But fixed means "against the viewport", and it was pinned at `top: 0`: the
|
|
// panel's own top - its title, its tabs, the members row - sat underneath the two
|
|
// header bars, so it appeared to start in the middle of itself.
|
|
//
|
|
// There is no fixed number for the header: the quick-access bar plus a board bar
|
|
// whose buttons wrap to one, two or three rows depending on the language and the
|
|
// window width. So the header MEASURES itself into --wekan-header-height and the
|
|
// sidebar starts there.
|
|
//
|
|
// Run: node tests/sidebarBelowHeader.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
const read = rel => fs.readFileSync(path.join(__dirname, '..', rel), 'utf8');
|
|
|
|
const sidebarCss = read('client/components/sidebar/sidebar.css');
|
|
const utils = read('client/lib/utils.js');
|
|
|
|
console.log('sidebarBelowHeader:');
|
|
|
|
test('the phone sidebar starts below the header, not at the viewport top', () => {
|
|
const at = sidebarCss.indexOf('.board-sidebar.sidebar {');
|
|
assert.ok(at !== -1, 'the phone sidebar rule must be there');
|
|
const rule = sidebarCss.slice(at, sidebarCss.indexOf('}', at));
|
|
assert.ok(/position: fixed;/.test(rule), 'fixed, so it spans the screen not the board');
|
|
assert.ok(/top: var\(--wekan-header-height, 0px\);/.test(rule),
|
|
'and it starts at the measured header height');
|
|
assert.ok(!/(?<![-\w])top: 0;/.test(rule),
|
|
'`top: 0` is what put the panel behind the header bars');
|
|
assert.ok(/bottom: 0;/.test(rule), 'and it still reaches the bottom of the screen');
|
|
});
|
|
|
|
test('the header publishes its own height, and keeps it current', () => {
|
|
const at = utils.indexOf('--wekan-header-height: how tall the two header bars actually are');
|
|
assert.ok(at !== -1, 'the note explaining why a number will not do must be there');
|
|
const block = utils.slice(at);
|
|
// BOTH bars. This measured `#header` alone - the second bar - back when
|
|
// every page had one. Most pages have none now, so on those the variable was
|
|
// 0 and everything laid out against it started at the top of the WINDOW,
|
|
// under the first bar: the All Boards sidebar covered it.
|
|
assert.ok(/HEADER_IDS = \['header-quick-access', 'header'\]/.test(block),
|
|
'it measures the first bar as well as the second');
|
|
assert.ok(/getElementById\(id\)/.test(block), 'and measures the real elements');
|
|
assert.ok(/getBoundingClientRect\(\)\.bottom/.test(block),
|
|
'the BOTTOM of the lowest bar: any margin between them counts, and a bar '
|
|
+ 'that is absent contributes nothing without a special case');
|
|
assert.ok(/setProperty\(\s*'--wekan-header-height'/.test(block));
|
|
assert.ok(/new ResizeObserver\(publishHeaderHeight\)\.observe\(el\)/.test(block),
|
|
'a window resize does not fire when the buttons re-wrap - only a resize '
|
|
+ 'observer on each bar catches that');
|
|
assert.ok(/\$\(window\)\.on\('resize orientationchange', publishHeaderHeight\)/.test(block),
|
|
'and an orientation change moves the bars too');
|
|
assert.ok(/__wekanHeightObserved/.test(block), 'observed once, not once per call');
|
|
});
|
|
|
|
test('it survives the header not existing yet', () => {
|
|
const block = utils.slice(utils.indexOf('--wekan-header-height: how tall'));
|
|
assert.ok(/const el = document\.getElementById\(id\);\s*\n\s*if \(el\)/.test(block),
|
|
'no bar yet means it contributes 0, not a thrown TypeError');
|
|
assert.ok(/document\.readyState === 'loading'/.test(block),
|
|
'the header is rendered by Blaze, so this runs again after the first render');
|
|
assert.ok(/typeof window !== 'undefined' && typeof document !== 'undefined'/.test(block),
|
|
'and never on the server, where this file is also imported');
|
|
});
|
|
|
|
console.log(`\n${passed} tests passed`);
|