mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -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 !
115 lines
5.7 KiB
JavaScript
115 lines
5.7 KiB
JavaScript
'use strict';
|
|
|
|
// /information and /translation are panes of Admin Panel / Settings now, and the
|
|
// old URLs redirect there.
|
|
//
|
|
// They redirected with `FlowRouter.go('setting')` called from INSIDE triggersEnter.
|
|
// A trigger runs while its own route is still entering, and a go() from there is
|
|
// swallowed - so nothing was rendered at all and the browser kept showing whatever
|
|
// page it was on. Playwright caught it on every browser: /information showed All
|
|
// Boards, so "Reactivity mode" was nowhere on the page.
|
|
//
|
|
// A trigger redirects with the `redirect` it is HANDED. That is the form the
|
|
// redirections table at the bottom of config/router.js has always used.
|
|
//
|
|
// Run: node tests/adminOldUrlRedirect.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 router = read('config/router.js');
|
|
|
|
// The body of one FlowRouter.route(<path>, {...}) definition. The path is
|
|
// either a literal - the old URLs are - or an EXPRESSION: the panel's own
|
|
// routes take their path from `adminRoutePath(page)`, so the route and the
|
|
// links cannot disagree about what it is.
|
|
function routeBody(routePath) {
|
|
const literal = router.indexOf(`FlowRouter.route('${routePath}', {`);
|
|
const at = literal !== -1 ? literal : router.indexOf(`FlowRouter.route(${routePath}, {`);
|
|
assert.notStrictEqual(at, -1, `no route for ${routePath}`);
|
|
const end = router.indexOf('\n});', at);
|
|
return router.slice(at, end);
|
|
}
|
|
|
|
console.log('adminOldUrlRedirect:');
|
|
|
|
test('the old page URLs redirect with the redirect they are given', () => {
|
|
for (const routePath of ['/information', '/translation', '/setting']) {
|
|
const body = routeBody(routePath);
|
|
assert.ok(/\(context, redirect\) => \{/.test(body),
|
|
`${routePath}: the trigger must take the redirect argument`);
|
|
assert.ok(/redirect\(/.test(body), `${routePath}: and use it`);
|
|
assert.ok(!/FlowRouter\.go\(/.test(body),
|
|
`${routePath}: FlowRouter.go() from inside a trigger is swallowed - the page `
|
|
+ 'never changes');
|
|
}
|
|
});
|
|
|
|
test('each one redirects to the URL of the pane it used to be a page of', () => {
|
|
// They used to hand the pane over in a Session value that the page consumed
|
|
// once. Every pane HAS an address now, so they redirect to it: the pane is in
|
|
// the URL, where it can be linked, bookmarked and gone back to.
|
|
const { adminPath } = require('../models/lib/adminUrls');
|
|
// The default pane is NAMED now, rather than being left implicit in a bare
|
|
// page URL: the address is meant to say where you are, and Version is
|
|
// somewhere too.
|
|
assert.strictEqual(adminPath('settings', 'version-setting'), '/admin/settings/version');
|
|
assert.strictEqual(adminPath('settings', 'translation-setting'), '/admin/settings/translation');
|
|
|
|
assert.ok(/redirect\(adminPath\('settings', 'version-setting'\)\)/
|
|
.test(routeBody('/information')), '/information is the Version pane');
|
|
assert.ok(/redirect\(adminPath\('settings', 'translation-setting'\)\)/
|
|
.test(routeBody('/translation')), '/translation is the Translation pane');
|
|
// And the singular page URL, which now names the pane it lands on rather
|
|
// than the page that opens it.
|
|
assert.ok(/redirect\(adminPath\('settings', 'version-setting'\)\)/
|
|
.test(routeBody('/setting')), '/setting redirects to /admin/settings/version');
|
|
});
|
|
|
|
test('the route puts the pane the URL names into the page', () => {
|
|
const body = routeBody("adminRoutePath('settings')");
|
|
assert.ok(/resolvePaneId\('settings', params && params\.pane\)/.test(body),
|
|
'the slug is resolved to a pane id');
|
|
assert.ok(/Session\.set\('settingsOpenPane'/.test(body),
|
|
'and handed to the page');
|
|
});
|
|
|
|
test('Settings opens that pane, and the autorun does not overrule it', () => {
|
|
const src = read('client/components/settings/settingBody.js');
|
|
const created = src.slice(src.indexOf('Template.setting.onCreated'));
|
|
const block = created.slice(created.indexOf("Session.get('settingsOpenPane')"));
|
|
assert.ok(block.length, 'Template.setting must read the requested pane');
|
|
assert.ok(/openSettingsPane\(this, paneId\)/.test(block.slice(0, 400)),
|
|
'through the one function that opens a pane');
|
|
// It must not be overruled a moment later by the site-admin autorun, which
|
|
// decides which pane a NON-site-admin opens on.
|
|
assert.ok(/this\.openPaneDecided = true/.test(block.slice(0, 600)),
|
|
'the pane the URL asked for is the decision - the autorun must not redo it');
|
|
// Reactive, so a link to another pane while the page is already open switches
|
|
// to it: the route action runs again without re-creating the template.
|
|
assert.ok(/this\.autorun\(\(\) => \{[\s\S]{0,200}Session\.get\('settingsOpenPane'\)/.test(created),
|
|
'and it is an autorun, not a one-shot read');
|
|
});
|
|
|
|
test('the state it sets exists by the time it runs', () => {
|
|
// Every pane is a ReactiveVar created in onCreated; reading one before its
|
|
// line would be `undefined.set()`, i.e. a blank page on that URL.
|
|
const src = read('client/components/settings/settingBody.js');
|
|
const created = src.slice(src.indexOf('Template.setting.onCreated'));
|
|
const use = created.indexOf("Session.get('settingsOpenPane')");
|
|
for (const name of ['versionSetting', 'translationSetting', 'webhookSetting',
|
|
'layoutSetting', 'announcementSetting', 'accessibilitySetting',
|
|
'tableVisibilityModeSetting', 'attachmentSettings']) {
|
|
const declared = created.indexOf(`this.${name} = new ReactiveVar(`);
|
|
assert.ok(declared !== -1 && declared < use,
|
|
`this.${name} must be created before the requested pane is applied`);
|
|
}
|
|
});
|
|
|
|
console.log(`\n${passed} tests passed`);
|