Files
wekan/client/lib/pageTitleSources.js
T
Lauri Ojansivu 79b0950c33 Header: do not import a page module from the header.
The first header bar names three pages that carry a name of their own - Support
and Accessibility can be renamed by an admin, and Import names the source it is
importing from - and it asked for those names by importing each page's own
module.

The header is rendered by the layout, so it loads very early. Importing a page's
module pulls that module into the header's graph and RUNS it, before its .jade
has registered. `Template.import.onCreated` was `undefined.onCreated`: a
TypeError at module load. A module that throws aborts every module after it, so
the visible symptom was not that one page - it was "No such template:
connectionMethod" and a string of others that never got to register at all.

The three titles are in client/lib/pageTitleSources.js now, which registers no
template and touches no DOM, so it is safe to load at any point. The header asks
that; the pages use the same one rather than each keeping a copy.

A guard asserts the header imports nothing from client/components, that the
module it does import registers no template, and that neither page defines a
second copy of its own title. It reads the CODE and not the comments - the
module explains the bug by naming Template.import.onCreated, and the first
version of the guard failed on its own explanation.

Thanks to xet7 !
2026-07-31 13:44:51 +03:00

51 lines
1.8 KiB
JavaScript

import { ReactiveCache } from '/imports/reactiveCache';
import { Session } from 'meteor/session';
import { TAPi18n } from '/imports/i18n';
import AccessibilitySettings from '/models/accessibilitySettings';
// The three pages that carry a name of their own: an admin can rename Support
// and Accessibility, and Import names the source it is importing from.
//
// They live HERE, not in the pages themselves, because the top header bar has
// to ask for them and the header is loaded by the layout - that is, very early.
// Importing a page's own module from the header pulls that module into the
// header's graph and runs it before its .jade has registered, so
// `Template.import.onCreated` was `undefined.onCreated`: a TypeError at module
// load, which aborts every module after it. That is why `connectionMethod` and
// the rest went missing at the same time.
//
// This module registers no template and touches no DOM, so it is safe to load
// at any point. models/lib/pageTitles.js, docs/Design/Page/Header.md
export function supportPageTitle() {
const setting = ReactiveCache.getCurrentSetting();
return (setting && setting.supportTitle) || '';
}
export function accessibilityPageTitle() {
const setting = AccessibilitySettings.findOne({});
return (setting && setting.title) || '';
}
const IMPORT_SOURCE_NAMES = {
trello: 'Trello',
wekan: 'JSON',
csv: 'CSV-TSV',
excel: 'Excel',
jira: 'Jira',
kanboard: 'Kanboard',
deck: 'NextCloud Deck',
openproject: 'OpenProject',
github: 'GitHub',
gitlab: 'GitLab',
gitea: 'Gitea',
forgejo: 'Forgejo',
asana: 'Asana',
zenkit: 'Zenkit',
};
export function importPageTitle() {
const sourceName = IMPORT_SOURCE_NAMES[Session.get('importSource')] || 'JSON';
return `${TAPi18n.__('import')} / ${sourceName}`;
}