Files
wekan/models/lib/importedBoardMemberPlan.js
T
Lauri Ojansivu 50bb989eb8 Custom board roles, and team memberships that leave with the team.
#3022 (decided 2026-10-14): a site admin builds named roles in Admin
Panel / People / Roles from the capability matrix - sees all cards,
comments, edits, moves cards, invites - and a board admin gives one to a
member in the same popup as the built-in roles. Board admin stays
built-in. Every permission check asks boardRoleCapabilities, which
answers a custom role from the role; the member's built-in flags carry
the strongest built-in role that grants nothing more (fallbackRoleFor,
checked for every combination), so code reading a flag never grants
more, and a deleted role leaves exactly that. Where a role is asked by
name (hasWorker, isCommentOnly, ...) a custom role reads as the built-in
role that does what it does; commenting is asked as a capability
everywhere. Invites, REST whole-board reads, imports (a foreign custom
role is dropped) and member mapping (all eight flags now, not four)
follow it. The six new strings are translated in all 234 locales.

#4178 (decided 2026-10-14): a team or organization that gives board
memberships takes them away again when the user leaves it - only those:
each records where it came from (grantedBy), a direct membership is
never touched, a board admin is kept, and a board admin's own add or
removal is final. Teams through user edits, LDAP, OIDC and the board
sidebar; organizations where they propagate members.

Also: the Roles Status table gets a Move cards column; the comment form,
reactions and chat ask the comment capability (a No comments member was
offered reactions the server refused).

Tests: customBoardRoles and groupBoardMembership node suites, and the
runtime suites (9 passing) against a real database.

Thanks to xet7 and mfnalex !

Fixes #3022,
Fixes #4178.
2026-10-14 08:20:49 +03:00

30 lines
1.4 KiB
JavaScript

'use strict';
// Pure decision for how an original member of an imported board becomes a member of the
// newly created board (see models/wekanCreator.js). Split out so it is unit-testable.
//
// Returns the member entry to add, or null when there is no id or the member is the
// importer (who is already the board's active admin). Without an explicit deliberate
// mapping (wekanMember.wekanId), the ORIGINAL member is kept — reusing their original id
// — but added INACTIVE and non-admin, so they are visible in the member list yet hold no
// board permission until reconciled later. A real mapping preserves the mapped role.
function planImportedBoardMember(wekanMember, importerId) {
if (!wekanMember) return null;
const memberId = wekanMember.wekanId || wekanMember.userId || wekanMember.id;
if (!memberId || memberId === importerId) return null;
const mapped = !!wekanMember.wekanId;
// A custom role (#3022) is this instance's; another instance's id would name
// nothing here, or worse, a different role. The member keeps the built-in
// flags, which are the role's safe mirror.
const { customRoleId: foreignCustomRole, ...member } = wekanMember;
return {
...member,
userId: memberId,
wekanId: memberId,
isActive: mapped ? wekanMember.isActive !== false : false,
isAdmin: mapped ? !!wekanMember.isAdmin : false,
};
}
export { planImportedBoardMember };