Files
wekan/client/components/main/support.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

40 lines
1.2 KiB
JavaScript

import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
// Shared helpers for both support templates
import { supportPageTitle } from '/client/lib/pageTitleSources';
const supportHelpers = {
supportTitle() {
return supportPageTitle() || TAPi18n.__('support');
},
supportContent() {
const setting = ReactiveCache.getCurrentSetting();
return setting && setting.supportPageText ? setting.supportPageText : TAPi18n.__('support-info-not-added-yet');
},
isSupportEnabled() {
const setting = ReactiveCache.getCurrentSetting();
return setting && setting.supportPageEnabled;
},
isSupportPublic() {
const setting = ReactiveCache.getCurrentSetting();
return setting && setting.supportPagePublic;
}
};
// Main support page component
Template.support.onCreated(function () {
this.error = new ReactiveVar('');
this.loading = new ReactiveVar(false);
Meteor.subscribe('setting');
});
Template.support.helpers(supportHelpers);
// The subscription the header bar used to make. The top header bar names this
// page from the same setting, so it still has to be here.
Template.support.onCreated(function () {
Meteor.subscribe('setting');
});