@7365admin1/layer-common 4.4.2-staging.290 → 4.4.2-staging.291
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.
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
// Relative import: this layer's `utils/` is not auto-imported into consumers.
|
|
203
203
|
import { showSiteField } from "../utils/role";
|
|
204
204
|
import { holdsPermission } from "../utils/permission-spellings";
|
|
205
|
-
import { catalogueForOrg } from "../utils/org-modules";
|
|
205
|
+
import { catalogueForOrg, effectiveModules } from "../utils/org-modules";
|
|
206
206
|
|
|
207
207
|
const props = defineProps({
|
|
208
208
|
orgId: {
|
|
@@ -332,9 +332,38 @@ const { data: orgForModules } = useLazyAsyncData(
|
|
|
332
332
|
{ watch: [() => props.orgId] }
|
|
333
333
|
);
|
|
334
334
|
|
|
335
|
-
|
|
335
|
+
/*
|
|
336
|
+
* TIER TWO OF THE CASCADE: THE MODULES THIS SITE WAS GIVEN.
|
|
337
|
+
*
|
|
338
|
+
* R1, 2026-09-10: the organisation may only give a site what Seven365 gave the
|
|
339
|
+
* organisation. When this editor is scoped to a site, the boxes it offers are
|
|
340
|
+
* the INTERSECTION of the two lists, not the organisation's alone.
|
|
341
|
+
*
|
|
342
|
+
* Only fetched when there is a site to fetch - an organisation-level role
|
|
343
|
+
* editor has no second tier and must not pay for a request. Fails open exactly
|
|
344
|
+
* as the org lookup does: no site, no field, or a failed request all leave the
|
|
345
|
+
* organisation's list in charge.
|
|
346
|
+
*/
|
|
347
|
+
const { getSiteById: _getSiteForModules } = useSite();
|
|
348
|
+
|
|
349
|
+
const { data: siteForModules } = useLazyAsyncData(
|
|
350
|
+
`site-modules-${props.siteId}`,
|
|
351
|
+
() =>
|
|
352
|
+
props.siteId
|
|
353
|
+
? _getSiteForModules(props.siteId).catch(() => null)
|
|
354
|
+
: Promise.resolve(null),
|
|
355
|
+
{ watch: [() => props.siteId] }
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
/** `props.permissions`, narrowed to what this client - and this site - was given. */
|
|
336
359
|
const offeredPermissions = computed(() =>
|
|
337
|
-
catalogueForOrg(
|
|
360
|
+
catalogueForOrg(
|
|
361
|
+
props.permissions ?? {},
|
|
362
|
+
effectiveModules(
|
|
363
|
+
(orgForModules.value as any)?.modules,
|
|
364
|
+
(siteForModules.value as any)?.metadata?.modules
|
|
365
|
+
)
|
|
366
|
+
)
|
|
338
367
|
);
|
|
339
368
|
|
|
340
369
|
const { getRoles: _getRoles } = useRole();
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.4.2-staging.
|
|
5
|
+
"version": "4.4.2-staging.291",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
package/utils/org-modules.ts
CHANGED
|
@@ -72,3 +72,43 @@ export function catalogueForOrg<T extends Record<string, unknown>>(
|
|
|
72
72
|
*/
|
|
73
73
|
return (Object.keys(narrowed).length ? narrowed : catalogue) as T;
|
|
74
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* TIER THREE: THE MODULES A SITE'S ROLE EDITOR MAY OFFER.
|
|
78
|
+
*
|
|
79
|
+
* The client copy of `core src/utils/site-modules.util.ts`
|
|
80
|
+
* (`effectiveSiteModules`), same cases, same fail-open rule. R1, 2026-09-10:
|
|
81
|
+
* whatever Seven365 gave the ORGANISATION is the only set the organisation can
|
|
82
|
+
* give to a SITE, and then to that site's team members.
|
|
83
|
+
*
|
|
84
|
+
* Seven365 -> organizations.modules tier one
|
|
85
|
+
* the org -> sites.metadata.modules tier two
|
|
86
|
+
* the org -> a site role's permissions THIS - the editor offers the
|
|
87
|
+
* intersection of the two above
|
|
88
|
+
*
|
|
89
|
+
* Returns `[]` for EVERYTHING, exactly as the org tier does, so `catalogueForOrg`
|
|
90
|
+
* reads the same whichever tier fed it.
|
|
91
|
+
*
|
|
92
|
+
* Fails open at every step, and an intersection that comes out EMPTY falls back
|
|
93
|
+
* to the organisation's list rather than to nothing: the likeliest cause of a
|
|
94
|
+
* site list matching nothing is that Seven365 changed the org's set and the
|
|
95
|
+
* site's went stale, and a role editor offering zero boxes is indistinguishable
|
|
96
|
+
* from a broken screen.
|
|
97
|
+
*/
|
|
98
|
+
export function effectiveModules(
|
|
99
|
+
orgModules: readonly string[] | null | undefined,
|
|
100
|
+
siteModules: readonly string[] | null | undefined,
|
|
101
|
+
): string[] {
|
|
102
|
+
const org = Array.isArray(orgModules) ? orgModules.filter(isKey) : [];
|
|
103
|
+
const site = Array.isArray(siteModules) ? siteModules.filter(isKey) : [];
|
|
104
|
+
|
|
105
|
+
if (!org.length) return site;
|
|
106
|
+
if (!site.length) return org;
|
|
107
|
+
|
|
108
|
+
const allowed = site.filter((key) => org.includes(key));
|
|
109
|
+
return allowed.length ? allowed : org;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isKey(value: unknown): value is string {
|
|
113
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
114
|
+
}
|