mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Admin Panel / Settings / Visibility / Rules gets "Boards may show their Rules to members, read-only", off by default (Settings rulesReadOnlyForMembers, site admin only). With it on, a board admin ticks "Show these Rules to board members, read-only" on the board's Rules page (rulesVisibleToMembers). Members of that board then get Rules in Board Settings and see the rules list and each rule's details, with no control that changes a rule; the methods that change rules keep their board-admin checks, so nothing is granted. Without both ticks only board and site admins see the Rules page, which until now drew its list for any member who opened the address. models/lib/rulesReadOnly.js decides 'edit', 'read' or 'none', and client/lib/rulesAccess.js is the one place the Rules page, Board Settings and rule details ask. tests/rulesReadOnly.test.cjs covers both switches, each alone, a non-member, and that a reader's page has no edit control. boardMenuOrder now leaves the reader's alternative branch out of the admin's sequence and pins it alone; instanceFeatures counts the fourth site-admin method; roleHelperRegressions follows the canAdmin check to rulesAccess.js. The new strings are English placeholders until the next translation pass. Thanks to justinr1234 and xet7 ! Fixes #2217.
20 lines
740 B
JavaScript
20 lines
740 B
JavaScript
// #2217: 'edit', 'read' or 'none' for the current user on the current board
|
|
// (models/lib/rulesReadOnly.js). The Rules page, Board Settings and the rule
|
|
// details all ask this one function.
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
|
import { Utils } from '/client/lib/utils';
|
|
const { rulesAccess } = require('/models/lib/rulesReadOnly');
|
|
|
|
export function currentRulesAccess() {
|
|
const user = ReactiveCache.getCurrentUser();
|
|
const board = Utils.getCurrentBoard();
|
|
if (!user || !board) return 'none';
|
|
return rulesAccess({
|
|
setting: ReactiveCache.getCurrentSetting(),
|
|
board,
|
|
isBoardAdmin: !!user.isBoardAdmin(),
|
|
isSiteAdmin: user.isAdmin === true,
|
|
isActiveMember: !!board.hasMember(user._id),
|
|
});
|
|
}
|