@masterteam/users-groups 0.0.44 → 0.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1284,7 +1284,8 @@ function buildRoleTree(roles, lang, labels) {
|
|
|
1284
1284
|
* Walks/creates the scope spine for a row and returns the children array the
|
|
1285
1285
|
* leaf (permission/role) should be pushed into:
|
|
1286
1286
|
* - level scope → Template → Level → (Module)
|
|
1287
|
-
* - module scope with no level → "Other modules" → Module
|
|
1287
|
+
* - module scope with no level → "Other modules" → Module (the modules move
|
|
1288
|
+
* to the root when no row has a level; see `liftOtherModulesWithoutLevels`)
|
|
1288
1289
|
* - no scope → "Unknown scope"
|
|
1289
1290
|
*/
|
|
1290
1291
|
function resolveScopeContainer(roots, prefix, scope, fallbackTemplateName, lang, labels) {
|
|
@@ -1363,10 +1364,25 @@ const isScopeNode = (node) => SCOPE_NODE_TYPES.has(node.data?.type ?? '');
|
|
|
1363
1364
|
* to every scope node's label.
|
|
1364
1365
|
*/
|
|
1365
1366
|
function finalizeTree(nodes, leafType) {
|
|
1367
|
+
liftOtherModulesWithoutLevels(nodes);
|
|
1366
1368
|
orderNodes(nodes);
|
|
1367
1369
|
appendScopeCounts(nodes, leafType);
|
|
1368
1370
|
return nodes;
|
|
1369
1371
|
}
|
|
1372
|
+
/**
|
|
1373
|
+
* "Other modules" only means something next to Template → Level branches.
|
|
1374
|
+
* When no row has a level scope — a product without levels, such as Diwan,
|
|
1375
|
+
* or a principal holding only module-wide access — the bucket would wrap
|
|
1376
|
+
* every module, so its modules move up to the root instead.
|
|
1377
|
+
*/
|
|
1378
|
+
function liftOtherModulesWithoutLevels(nodes) {
|
|
1379
|
+
if (nodes.some((node) => node.data?.type === 'template'))
|
|
1380
|
+
return;
|
|
1381
|
+
const index = nodes.findIndex((node) => node.data?.type === 'other');
|
|
1382
|
+
if (index < 0)
|
|
1383
|
+
return;
|
|
1384
|
+
nodes.splice(index, 1, ...(nodes[index].children ?? []));
|
|
1385
|
+
}
|
|
1370
1386
|
function orderNodes(nodes) {
|
|
1371
1387
|
const leaves = nodes.filter((node) => !isScopeNode(node));
|
|
1372
1388
|
const scopes = nodes.filter(isScopeNode).sort(compareScopeNodes);
|