Files
wekan/models/lib/pageSidebar.js
T
Lauri Ojansivu daaf563910 Docs: implemented designs move to docs/Features, filed the way the menu is.
A design that describes what WeKan already DOES belongs with the feature it
describes, not in the folder for things being proposed. Fifteen docs move:

  Design/Accessibility.md      -> Features/Accessibility/Accessibility-Improvements.md
  Design/Original-Positions.md -> Features/Board/Original-Positions.md
  Design/Page/*                -> Features/Page/*   (thirteen pages that exist)
  Design/AdminPanelProblems.md -> Features/Admin-Panel/Problems/Design.md

What stays in docs/Design is what the folder is for: the principles
(Design-Principles, Monkey-Proof-Software), the comparisons, the roadmap
(Multiverse), and the proposals not yet built (Multitenancy, Autoupdate).

The Admin Panel Problems design is new and covers six changes - summaries, the
per-actor tally, IPv4/IPv6 columns, an API report, a per-address login tally,
and blocking with increasing delays. Three are shipped and three are planned;
it is filed under the feature because the pane exists, with each planned item
marked so it can become plain description as it lands.

Every reference in the repository is rewritten - 152 files, including the CSS
comments that point at the table-page design, which a first pass over .md and
.js alone missed. Two suites asserted the old paths and now assert the new
ones. A moved doc whose links nobody fixed is worse than one nobody moved.

Thanks to xet7 !
2026-08-16 15:15:01 +03:00

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/Features/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,
};