mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Which group kinds - Organizations, Teams, email Domains - Admin Panel / People / Shared templates allows came from the browser's localStorage, so it differed per browser and was empty for every user but the admin who ticked it. It is Settings.sharedTemplatesScopes now, published to every client, and an admin's earlier ticks are carried over once. The All Boards / Templates targets were empty for everyone anyway: getMyShareableGroups did not await ReactiveCache.getUser, so it read orgs, teams and emails from a Promise. Thanks to xet7 !
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
// Admin Panel / People / Shared templates: which group kinds - Organizations,
|
|
// Teams, email Domains - a template board may be shared with by dragging it
|
|
// onto one in All Boards / Templates, and which groupings the admin's own
|
|
// Shared templates view lists. One instance setting, Settings.sharedTemplatesScopes,
|
|
// so every browser of every user sees the same choice. It used to be read from
|
|
// the browser's localStorage, which made it different per browser and empty
|
|
// for everyone but the admin who ticked it.
|
|
const SHARED_TEMPLATES_SCOPES = ['organizations', 'teams', 'domains'];
|
|
// The localStorage key the choice used to live in, read once to carry an
|
|
// admin's earlier ticks over to the setting.
|
|
const LEGACY_STORAGE_KEY = 'sharedTemplatesScopes';
|
|
|
|
// Only known kinds, each once, in a fixed order.
|
|
function normalizeScopes(value) {
|
|
if (!Array.isArray(value)) return [];
|
|
return SHARED_TEMPLATES_SCOPES.filter(scope => value.includes(scope));
|
|
}
|
|
|
|
function sharedTemplatesScopes(setting) {
|
|
return normalizeScopes(setting && setting.sharedTemplatesScopes);
|
|
}
|
|
|
|
function toggleScope(current, scope) {
|
|
if (!SHARED_TEMPLATES_SCOPES.includes(scope)) return normalizeScopes(current);
|
|
const list = normalizeScopes(current);
|
|
return list.includes(scope)
|
|
? list.filter(s => s !== scope)
|
|
: normalizeScopes([...list, scope]);
|
|
}
|
|
|
|
module.exports = {
|
|
SHARED_TEMPLATES_SCOPES,
|
|
LEGACY_STORAGE_KEY,
|
|
normalizeScopes,
|
|
sharedTemplatesScopes,
|
|
toggleScope,
|
|
};
|