mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 10:48:06 -05:00
Sort, Search, Multi-Selection and Boards in Archive were rows of the right sidebar's home view, so reaching any of them meant opening a panel over the boards first. They are icons in the FIRST top header bar now, left of the notification bell - exactly where a board's own controls are - each named by a tooltip, like every other button of that bar. They have now been in three places: the page's own body, a second top header bar, and that sidebar view. The home view was the only thing the hamburger opened, so All Boards no longer offers one, nor the divider before it. A menu to reach what is already one click away is a step with nothing in it. NO_HAMBURGER_ROUTES in models/lib/pageSidebar.js is what says so, and a board is deliberately not in it: what a board's sidebar holds - members, labels, activities, settings - is not in the bar and has nowhere else to be opened from. The sidebar is still reachable, and that mattered enough to guard: removing the hamburger removes the only generic way in, so Search and Multi-Selection opening it ARE the way in, and if their event map went the panel would become unreachable and both features would stop existing. The home view is not dead markup either - it is what the back arrow of the other views leads to. Boards in Archive is drawn in two places now. A Blaze event map only sees events inside its own template, so each copy needs its own handler; a copy with markup and no map is a button that silently does nothing, which is exactly what happened to that button once before. The guard checks both copies rather than one. Three existing guards had to change, and each says why: the page-body check now scopes itself to the board-list markup rather than the whole file, since the controls live in that file again; the archive guard checks both copies instead of asserting the header must NOT handle it; and the hamburger guard learned that a page can have a sidebar and still not be offered one. docs/Design/Page/All-Boards.md described a second header bar that no longer exists, so its controls section is rewritten to what is there. Thanks to xet7 !
80 lines
2.8 KiB
JavaScript
80 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
// Which controls the shared page sidebar shows, per page.
|
|
//
|
|
// A page's controls used to live in its own second header bar, beside its `h1`.
|
|
// The title moved to the first bar (models/lib/pageTitles.js) and the controls
|
|
// moved into a right sidebar, so a page is its content plus one panel rather
|
|
// than its content plus a strip of buttons above it.
|
|
//
|
|
// A board has its own sidebar and All Boards has its own; this is for every
|
|
// OTHER page. Most have no controls at all - their second bar was only a title
|
|
// - and those get no sidebar and no hamburger, because an empty panel is worse
|
|
// than none.
|
|
//
|
|
// Pure: a route name in, a Blaze template name out. No Meteor, no router.
|
|
// docs/Design/Page/Header.md
|
|
|
|
// routeName -> the template that draws that page's controls.
|
|
const PAGE_SIDEBAR_TEMPLATES = {
|
|
'my-cards': 'myCardsControls',
|
|
'due-cards': 'dueCardsControls',
|
|
'global-search': 'globalSearchControls',
|
|
'board-rules': 'rulesControls',
|
|
};
|
|
|
|
// The routes that have their own sidebar already, and so must NOT get this one.
|
|
const OWN_SIDEBAR_ROUTES = [
|
|
// Every board route: the board sidebar.
|
|
'board', 'card', 'boardCard',
|
|
// All Boards and its sections, and Public: the All Boards sidebar.
|
|
'home', 'allboards', 'allboards-templates', 'allboards-remaining', 'public',
|
|
];
|
|
|
|
// ...and of those, the routes that must NOT be offered the HAMBURGER.
|
|
//
|
|
// All Boards has a sidebar, but nothing opens it from the top of the panel any
|
|
// more: its four controls are in the first header bar, and Search and
|
|
// Multi-Selection open the sidebar straight into their own view. The
|
|
// hamburger's only destination was a home view listing those same four things,
|
|
// so it opened a menu to reach what is now one click away.
|
|
//
|
|
// A board keeps its hamburger: what its sidebar holds - members, labels,
|
|
// activities, settings - is not in the bar and has nowhere else to be opened
|
|
// from.
|
|
const NO_HAMBURGER_ROUTES = [
|
|
'home', 'allboards', 'allboards-templates', 'allboards-remaining', 'public',
|
|
];
|
|
|
|
function hasHamburger(routeName) {
|
|
return !NO_HAMBURGER_ROUTES.includes(routeName);
|
|
}
|
|
|
|
function hasOwnSidebar(routeName) {
|
|
return OWN_SIDEBAR_ROUTES.includes(routeName);
|
|
}
|
|
|
|
// The controls template for a route, or null when that page has none.
|
|
function pageSidebarTemplate(routeName) {
|
|
if (hasOwnSidebar(routeName)) return null;
|
|
return Object.prototype.hasOwnProperty.call(PAGE_SIDEBAR_TEMPLATES, routeName)
|
|
? PAGE_SIDEBAR_TEMPLATES[routeName]
|
|
: null;
|
|
}
|
|
|
|
// Whether the hamburger should be offered at all. A page with no sidebar and
|
|
// nothing to put in one must not show a control that opens an empty panel.
|
|
function hasPageSidebar(routeName) {
|
|
return pageSidebarTemplate(routeName) !== null;
|
|
}
|
|
|
|
module.exports = {
|
|
PAGE_SIDEBAR_TEMPLATES,
|
|
OWN_SIDEBAR_ROUTES,
|
|
NO_HAMBURGER_ROUTES,
|
|
hasOwnSidebar,
|
|
hasHamburger,
|
|
pageSidebarTemplate,
|
|
hasPageSidebar,
|
|
};
|