mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
The Rules page had a separate right sidebar holding only Back and its views (List view, Workflow view, Blocks, History, Import / Export rules). It now uses the board's own sidebar, like the board: the same views are in its Board Settings under Rules, and choosing one there while on the Rules page closes the sidebar so the view is not left under it. The separate sidebar and its template are removed. Its Back button went with it, so picking a view in the Board View menu while on the Rules page now goes back to the board, asking first before unsaved Blocks work would be lost. Source tests pin the Rules route to the board sidebar, the absence of the old controls, the way back and the Board Settings entries' existing translated labels. The Rules browser specs open views through Board Settings; a member who is not a board admin is not offered them there, and the Blocks view still refuses such a member. The Rules and Board Settings specs pass in Chromium and WebKit. Thanks to xet7 !
81 lines
3.0 KiB
JavaScript
81 lines
3.0 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',
|
|
};
|
|
|
|
// 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. The Rules page is a page of the
|
|
// board and uses it too; its own sidebar, which held only its views, is gone
|
|
// - they are in Board Settings under Rules, in the board sidebar.
|
|
'board', 'card', 'boardCard', 'board-rules',
|
|
// 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,
|
|
};
|