Files
wekan/client/lib/instanceFeatures.js
T
Lauri Ojansivu fc21b0b177 Feature profiles: an administrator hides features from chosen users, teams and organizations.
Decided by the maintainer on 2026-11-18 (TODO.md): administrator-defined
profiles. Admin Panel / Settings / Visibility / Features gains Feature
profiles: a name, a tick for each optional feature the profile hides,
and the users, teams and organizations it applies to. A user's own
profile wins, then the first profile naming one of their teams, then one
naming one of their organizations.

Strictly opt-in, because hiding features by default was tried and
removed as a support nightmare: a user with no profile sees everything,
a profile only hides (no data or permission changes), and the member
menu tells the user which profile hides how many features. The decision
is models/lib/featureProfiles.js, applied in isFeatureAvailable, so
every existing place that hides a disabled feature follows it.

Profiles are stored in Settings (featureProfiles) and a direct
assignment on the user (featureProfileId, published to that user only
and not writable by them). tests/featureProfiles.test.cjs covers the
decision, cleaning, the admin-only methods and the wiring;
feature-profiles.e2e.js drives the page, the hidden board view and the
notice.

The 11 new strings are translated into every language. Low confidence:
 qu, rup, rn, rw, sah, se, sm, sn, ss, st (low); sd, so, si, scn (medium); sr uses standard Тимови/Организације; ff, fj, gn, gv, haw (low); ha, hsb, fur, gd, ga, fo (medium); ace, ak, ay, bm, bi, bo, bua (low); ba, bho, ar-DZ/ar-EG/ary dialect spelling (medium); iu, kl, ks, kw, lld, lg, ig, la (low); kok (medium); tig, ti, tlh, ve-PP, ve-CC, uz-AR, ve, ts, tn, to, tpi (low); szl (medium); wal, vo, zgh, wa, wo, wa-RR, yi, wuu-Hans (low); chr, dz, ee, csb, cv, co, ckb (low); cmn uses 配置 for profile; nah, nap, nd, nso, om, mai (low); mg, ny, pap, or_IN, ps (medium).

Thanks to mimZD and xet7 !

Fixes #6837.
2026-11-19 00:01:42 +02:00

37 lines
1.9 KiB
JavaScript

// #6736: the instance's feature decisions (Admin Panel / Settings / Visibility /
// Features) for the signed-in user, reactively. The decisions themselves are
// models/lib/instanceFeatures.js; this only supplies what the client knows -
// the published Settings document and the user's own preview flag.
import { Template } from 'meteor/templating';
import { ReactiveCache } from '/imports/reactiveCache';
import { currentUserWith } from '/client/lib/currentUserWith';
const { isBoardViewAvailable, isFeatureAvailable } = require('/models/lib/instanceFeatures');
// #6745: only the two fields canPreviewFeatures() reads. Utils.boardView()
// calls this, and every list's card loop reads boardView(): with the whole user
// document here, a card open (a user write) re-ran every list and Blaze then
// re-evaluated every minicard.
// #6837: and the three that pick the user's feature profile.
const PREVIEW_USER_FIELDS = ['featurePreview', 'isAdmin', 'featureProfileId', 'teams', 'orgs'];
export function allowBoardView(view) {
return isBoardViewAvailable(ReactiveCache.getCurrentSetting(), currentUserWith(PREVIEW_USER_FIELDS), view);
}
// A catalog feature without a board view of its own (the helpers that need no
// AI: rule suggestions, ...), for the signed-in user.
export function allowFeature(key) {
return isFeatureAvailable(ReactiveCache.getCurrentSetting(), currentUserWith(PREVIEW_USER_FIELDS), key);
}
// {{#if allowFeature 'board-summary'}} in a template.
Template.registerHelper('allowFeature', key => allowFeature(key));
// #6837: the profile that hides features for the signed-in user, so the
// interface can say so - a hidden feature must never look like a missing one.
export function featureProfileNotice() {
return require('/models/lib/featureProfiles').featureProfileNotice(
ReactiveCache.getCurrentSetting(), currentUserWith(PREVIEW_USER_FIELDS));
}
Template.registerHelper('featureProfileNotice', () => featureProfileNotice());