@phis/ui 0.7.5 → 0.7.8

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.
Files changed (158) hide show
  1. package/components/controls/phi-form-control.d.ts +3 -1
  2. package/components/controls/phi-form-control.js +15 -4
  3. package/components/forms/auth-admin-settings-labels.d.ts +1 -1
  4. package/components/forms/auth-admin-settings-labels.js +2 -2
  5. package/components/forms/extended-form-field-controls.d.ts +1 -1
  6. package/components/forms/extended-form-field-controls.js +23 -7
  7. package/components/forms/form-descriptor-contract.d.ts +1 -1
  8. package/components/forms/form-descriptor-contract.js +1 -1
  9. package/components/forms/form-descriptor-runtime-client.d.ts +4 -1
  10. package/components/forms/form-descriptor-runtime-client.js +33 -11
  11. package/components/forms/form-media-limits.d.ts +12 -0
  12. package/components/forms/form-media-limits.js +14 -0
  13. package/components/forms/form-provider-contract.d.ts +5 -0
  14. package/components/forms/form-provider-contract.js +9 -2
  15. package/components/forms/form-provider-registry.d.ts +14 -0
  16. package/components/forms/form-record-title.d.ts +14 -0
  17. package/components/forms/form-record-title.js +38 -0
  18. package/components/forms/form-widget-config.d.ts +3 -0
  19. package/components/forms/form-widget-config.js +2 -0
  20. package/components/forms/money-field-currency-key.d.ts +6 -0
  21. package/components/forms/money-field-currency-key.js +14 -0
  22. package/components/forms/money-field.d.ts +26 -3
  23. package/components/forms/money-field.js +54 -4
  24. package/components/forms/phi-form-widget.d.ts +1 -1
  25. package/components/forms/phi-form-widget.js +4 -0
  26. package/components/overlays/phi-overlay-container-client.js +8 -8
  27. package/components/overlays/phi-overlay-title.d.ts +7 -0
  28. package/components/overlays/phi-overlay-title.js +21 -0
  29. package/components/regions/presets/navigation-redirect.d.ts +4 -1
  30. package/components/regions/presets/navigation-redirect.js +6 -3
  31. package/components/tables/client/phi-table-binding.d.ts +3 -1
  32. package/components/tables/client/phi-table-binding.js +90 -49
  33. package/components/tables/client/phi-table-filter-options.d.ts +27 -0
  34. package/components/tables/client/phi-table-filter-options.js +35 -0
  35. package/components/widgets/accessible-areas.d.ts +1 -1
  36. package/components/widgets/accessible-areas.js +1 -1
  37. package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
  38. package/components/widgets/client/shared/phi-rendered-value.js +54 -4
  39. package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
  40. package/components/widgets/client/shared/phi-table-provider.js +22 -0
  41. package/components/widgets/label-sets/admin-users.d.ts +15 -0
  42. package/components/widgets/label-sets/admin-users.js +31 -0
  43. package/constants/core-data-provider-keys.d.ts +7 -0
  44. package/constants/core-data-provider-keys.js +7 -0
  45. package/constants/phi-base-role-metadata.d.ts +2 -2
  46. package/constants/phi-base-role-metadata.js +1 -1
  47. package/constants/runtime-module-ownership.js +3 -0
  48. package/forms.d.ts +1 -1
  49. package/forms.js +1 -1
  50. package/gateway/capability-media-limits.d.ts +10 -0
  51. package/gateway/capability-media-limits.js +40 -0
  52. package/gateway/server-capabilities.js +4 -0
  53. package/helpers/money-amount.d.ts +7 -0
  54. package/helpers/money-amount.js +15 -0
  55. package/helpers/preset-tree-contract-check.d.ts +3 -2
  56. package/helpers/preset-tree-contract-check.js +60 -0
  57. package/helpers/record-title.d.ts +7 -0
  58. package/helpers/record-title.js +25 -0
  59. package/helpers/record-widget.d.ts +15 -0
  60. package/helpers/record-widget.js +57 -0
  61. package/package.json +2 -2
  62. package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
  63. package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
  64. package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
  65. package/plugins/runtime-modules/accounting/data-providers.js +127 -0
  66. package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
  67. package/plugins/runtime-modules/accounting/definition.js +5 -3
  68. package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
  69. package/plugins/runtime-modules/accounting/ids.js +27 -0
  70. package/plugins/runtime-modules/accounting/module.d.ts +52 -0
  71. package/plugins/runtime-modules/accounting/presets.js +23 -4
  72. package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
  73. package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
  74. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
  75. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
  76. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
  77. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
  78. package/plugins/runtime-modules/app/presets.js +3 -6
  79. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +3 -6
  80. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +4 -7
  81. package/plugins/runtime-modules/area-definitions.js +2 -2
  82. package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
  83. package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
  84. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
  85. package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
  86. package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
  87. package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
  88. package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
  89. package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
  90. package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
  91. package/plugins/runtime-modules/builder/controller/client.d.ts +5 -5
  92. package/plugins/runtime-modules/builder/controller/client.js +2 -1
  93. package/plugins/runtime-modules/builder/controller/definition.d.ts +4 -4
  94. package/plugins/runtime-modules/builder/controller/definition.js +7 -0
  95. package/plugins/runtime-modules/builder/controller/draft-command-controller.d.ts +3 -1
  96. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +2 -1
  97. package/plugins/runtime-modules/builder/controller/draft-status-controller.js +44 -17
  98. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +4 -4
  99. package/plugins/runtime-modules/builder/controller/workspace-controller.d.ts +3 -1
  100. package/plugins/runtime-modules/builder/controller/workspace-controller.js +8 -10
  101. package/plugins/runtime-modules/builder/developer-workspace-store.d.ts +10 -0
  102. package/plugins/runtime-modules/builder/developer-workspace-store.js +35 -1
  103. package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +6 -0
  104. package/plugins/runtime-modules/builder/offered-page-catalog.js +35 -6
  105. package/plugins/runtime-modules/builder/persistence.d.ts +4 -1
  106. package/plugins/runtime-modules/builder/persistence.js +10 -3
  107. package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
  108. package/plugins/runtime-modules/core/cards.js +2 -2
  109. package/plugins/runtime-modules/core/client-data-providers.js +5 -0
  110. package/plugins/runtime-modules/core/data-providers.js +14 -0
  111. package/plugins/runtime-modules/core/definition.d.ts +5 -0
  112. package/plugins/runtime-modules/core/form-providers.d.ts +5 -0
  113. package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
  114. package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
  115. package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
  116. package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
  117. package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
  118. package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
  119. package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
  120. package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
  121. package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
  122. package/plugins/runtime-modules/core/widgets/spacer/client.js +3 -3
  123. package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
  124. package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
  125. package/plugins/runtime-modules/groups/data-providers.js +1 -1
  126. package/plugins/runtime-modules/groups/definition.js +1 -1
  127. package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
  128. package/plugins/runtime-modules/groups/page-visibility.js +1 -1
  129. package/plugins/runtime-modules/groups/presets.js +1 -1
  130. package/plugins/runtime-modules/groups/services/options.js +1 -1
  131. package/plugins/runtime-modules/groups/services/table.js +1 -1
  132. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
  133. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +46 -39
  134. package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
  135. package/plugins/runtime-modules/preset-contracts/pub-area.js +1 -0
  136. package/plugins/runtime-modules/revisions/controller/client.js +48 -46
  137. package/plugins/runtime-modules/revisions/services/table.js +3 -1
  138. package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
  139. package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
  140. package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
  141. package/plugins/runtime-modules/user-management/controller/client.js +1 -1
  142. package/plugins/runtime-modules/user-management/data-providers.js +1 -0
  143. package/plugins/runtime-modules/user-management/forms.js +22 -0
  144. package/plugins/runtime-modules/user-management/presets.js +2 -2
  145. package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
  146. package/plugins/runtime-modules/user-management/services/options.js +14 -6
  147. package/plugins/runtime-modules/user-management/services/table.js +12 -3
  148. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
  149. package/styles/builder-scaffold.css +7 -1
  150. package/styles/layout-authoring-scaffold.css +27 -0
  151. package/types/access.d.ts +1 -1
  152. package/types/access.js +7 -7
  153. package/types/core-widget-placements.d.ts +7 -0
  154. package/types/form-descriptor.d.ts +1 -1
  155. package/types/record-widget.d.ts +35 -0
  156. package/types/server-capabilities.d.ts +1 -1
  157. package/types/table-widget.d.ts +20 -0
  158. package/types/table-widget.js +44 -0
@@ -11,7 +11,7 @@ import { usePhiApplicationFeedback } from "../../../../components/runtime/use-ph
11
11
  import { getPhiWorkspaceCatalogSnapshot, usePhiWorkspaceCatalogValue, } from "../../../../components/workspace/catalog-store";
12
12
  import { PHI_BUILDER_NAVIGATION_KEY_SEARCH_PARAM, PHI_BUILDER_PAGE_SEARCH_PARAM, PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM, PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM, PHI_BUILDER_THEME_KEY_SEARCH_PARAM, normalizePhiBuilderAreaSearchParam, normalizePhiBuilderPageSearchParam, normalizePhiBuilderRevisionsKindSearchParam, } from "../../../../helpers/cms-scope-search-params";
13
13
  import { resolvePhiBuilderRevisionPagePath, } from "../types";
14
- import { resolvePhiBuilderActivePageCatalog, resolvePhiBuilderActivePageKey, resolvePhiBuilderPageKeyFromCatalogPath, } from "../../../../helpers/cms-page-catalog";
14
+ import { findPhiBuilderPageKeyFromStoragePath, resolvePhiBuilderActivePageCatalog, resolvePhiBuilderActivePageKey, resolvePhiBuilderPageKeyFromCatalogPath, } from "../../../../helpers/cms-page-catalog";
15
15
  import { PHI_REVISIONS_RUNTIME_CONTROLLER_DEFINITION, } from "../controller/definition";
16
16
  import { resolvePhiBuilderRevisionNavScopeKey } from "../../../../helpers/cms-navigation-scope-key";
17
17
  import { deleteCmsDraft } from "../../../../helpers/cms-draft-delete";
@@ -28,6 +28,20 @@ function PhiRevisionsControllerMount({ address, config, }) {
28
28
  */
29
29
  const emitRoutes = useMemo(() => config.signalRoutes?.emits ?? [], [config.signalRoutes?.emits]);
30
30
  const emitCapability = useCallback((capabilityId, value, correlationId) => dispatchPhiSignalCapability(dispatchSignal, address, emitRoutes, capabilityId, value, correlationId), [address, dispatchSignal, emitRoutes]);
31
+ const reportDraftStatus = useCallback((value, correlationId) => {
32
+ dispatchSignal({
33
+ scope: "area",
34
+ channel: "draftStatus",
35
+ action: "change",
36
+ value,
37
+ valueType: "json",
38
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.revisionsDraftStatus,
39
+ sender: address,
40
+ receiver: "broadcast",
41
+ correlationId,
42
+ timestamp: Date.now(),
43
+ });
44
+ }, [address, dispatchSignal]);
31
45
  const { showMessage } = usePhiApplicationFeedback();
32
46
  const pathname = usePhiPathname();
33
47
  const router = useRouter();
@@ -86,6 +100,7 @@ function PhiRevisionsControllerMount({ address, config, }) {
86
100
  ownerModuleId: source?.ownerModuleId,
87
101
  presetKey: source?.presetKey,
88
102
  });
103
+ reportDraftStatus({ status: "published", revisionId: null, area }, correlationId);
89
104
  emitCapability("deleteAreaClose", null, correlationId);
90
105
  emitCapability("historyReload", null, correlationId);
91
106
  showMessage({ level: "success", content: `Cleared the ${area} structure back to its preset. Its Modules are kept.` });
@@ -97,7 +112,7 @@ function PhiRevisionsControllerMount({ address, config, }) {
97
112
  content: error instanceof Error ? error.message : "Clearing the Area failed.",
98
113
  });
99
114
  }
100
- }, [emitCapability, router, showMessage]);
115
+ }, [emitCapability, reportDraftStatus, router, showMessage]);
101
116
  usePhiSignalListener(useCallback((signal) => {
102
117
  if (signal.channel === "areaSelection" &&
103
118
  signal.action === "change" &&
@@ -173,56 +188,43 @@ function PhiRevisionsControllerMount({ address, config, }) {
173
188
  const payload = signal.value;
174
189
  const action = isPhiRecord(payload.value) ? payload.value : null;
175
190
  const key = typeof action?.key === "string" ? action.key : "";
176
- if (key === "restore") {
177
- showMessage({ level: "success", content: `Restored revision #${String(action?.revisionId ?? "")}.` }, { correlationId: signal.correlationId });
178
- const state = getPhiWorkspaceCatalogSnapshot();
179
- const search = new URLSearchParams(window.location.search);
180
- const kind = normalizePhiBuilderRevisionsKindSearchParam(search.get(PHI_BUILDER_REVISIONS_KIND_SEARCH_PARAM)) ?? "area";
181
- const revisionScope = search.get(PHI_BUILDER_REVISIONS_SCOPE_SEARCH_PARAM)?.trim() ?? "";
182
- const pages = resolvePhiBuilderActivePageCatalog(state.area, state.modulePresetPagesByArea, state.customPages, state.persistedPageCatalogByArea);
183
- dispatchSignal({
184
- scope: "area",
185
- channel: "draftStatus",
186
- action: "change",
187
- value: {
188
- status: "draft",
189
- revisionId: typeof action?.restoredRevisionId === "number" ? action.restoredRevisionId : null,
190
- ...(kind === "navigation"
191
- ? { navKey: resolvePhiBuilderRevisionNavScopeKey(state.area, revisionScope.includes(":")
192
- ? revisionScope
193
- : search.get(PHI_BUILDER_NAVIGATION_KEY_SEARCH_PARAM)) }
194
- : kind === "theme"
195
- ? { themeKey: revisionScope || search.get(PHI_BUILDER_THEME_KEY_SEARCH_PARAM) || "default" }
196
- : kind === "page"
197
- ? {
198
- area: state.area,
199
- pageKey: revisionScope.startsWith("/")
200
- ? resolvePhiBuilderPageKeyFromCatalogPath(state.area, revisionScope, pages)
201
- : normalizePhiBuilderPageSearchParam(search.get(PHI_BUILDER_PAGE_SEARCH_PARAM)) ?? state.pageKey,
202
- }
203
- : {
204
- area: normalizePhiBuilderAreaSearchParam(revisionScope) ?? state.area,
205
- }),
206
- },
207
- valueType: "json",
208
- valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.revisionsDraftStatus,
209
- sender: address,
210
- receiver: "broadcast",
211
- correlationId: signal.correlationId,
212
- timestamp: Date.now(),
213
- });
214
- }
215
- else if (key === "resetPage") {
216
- showMessage({ level: "success", content: "The Page is back to its Module's preset." }, { correlationId: signal.correlationId });
217
- // What stands now is the preset, which only the server knows how to build.
218
- router.refresh();
191
+ const scope = isPhiRecord(action?.scope) ? action.scope : null;
192
+ const kind = normalizePhiBuilderRevisionsKindSearchParam(scope?.kind);
193
+ const area = scope?.area;
194
+ if (key === "restore" || key === "resetPage") {
195
+ const structural = (kind === "area" || kind === "page") && isPhiBuilderAreaKey(area);
196
+ let pageKey = null;
197
+ if (kind === "page" && isPhiBuilderAreaKey(area) && typeof scope?.path === "string") {
198
+ const state = getPhiWorkspaceCatalogSnapshot();
199
+ const pages = resolvePhiBuilderActivePageCatalog(area, state.modulePresetPagesByArea, state.customPages, state.persistedPageCatalogByArea);
200
+ pageKey = findPhiBuilderPageKeyFromStoragePath(area, scope.path, pages)
201
+ ?? resolvePhiBuilderPageKeyFromCatalogPath(area, scope.path, pages);
202
+ }
203
+ reportDraftStatus({
204
+ status: key === "restore" ? "draft" : "published",
205
+ revisionId: typeof action?.restoredRevisionId === "number" ? action.restoredRevisionId : null,
206
+ ...(kind === "navigation" ? { navKey: scope?.navKey } : {}),
207
+ ...(kind === "theme" ? { themeKey: scope?.themeKey } : {}),
208
+ ...(structural ? { area } : {}),
209
+ ...(pageKey !== null ? { pageKey } : {}),
210
+ ...(action?.areaModules === true ? { areaModules: true } : {}),
211
+ }, signal.correlationId);
212
+ if (structural) {
213
+ router.refresh();
214
+ }
215
+ showMessage({
216
+ level: "success",
217
+ content: key === "restore"
218
+ ? `Restored revision #${String(action?.revisionId ?? "")}.`
219
+ : "The Page is back to its Module's preset.",
220
+ }, { correlationId: signal.correlationId });
219
221
  }
220
222
  else if (key === "delete")
221
223
  showMessage({ level: "success", content: `Deleted revision #${String(action?.revisionId ?? "")}.` }, { correlationId: signal.correlationId });
222
224
  else if (key === "deleteSelected")
223
225
  showMessage({ level: "success", content: `Deleted ${String(action?.deletedCount ?? 0)} revisions.` }, { correlationId: signal.correlationId });
224
226
  }
225
- }, [address, deleteAreaShell, dispatchSignal, emitCapability, pathname, router, showMessage]), {
227
+ }, [address, deleteAreaShell, emitCapability, pathname, reportDraftStatus, router, showMessage]), {
226
228
  scopes: ["area", "page"],
227
229
  channels: ["areaSelection", "bindingParams", "command", "formValues", "mutation"],
228
230
  },
@@ -428,7 +428,7 @@ async function mutateRevision(request) {
428
428
  return {
429
429
  status: "accepted",
430
430
  invalidation: "view",
431
- value: { key: request.actionKey },
431
+ value: { key: request.actionKey, scope: params.scope },
432
432
  };
433
433
  }
434
434
  const current = await loadRevisionHistory(params.scope, request.signal);
@@ -443,6 +443,8 @@ async function mutateRevision(request) {
443
443
  key: request.actionKey,
444
444
  revisionId,
445
445
  restoredRevisionId: result.revisionId,
446
+ scope: params.scope,
447
+ areaModules: params.scope.kind === "area" && current.rows.some((row) => row.revisionId === revisionId && !row.sourcePreset),
446
448
  };
447
449
  }
448
450
  else if (request.actionKey === "delete") {
@@ -1,6 +1,10 @@
1
1
  export type PhiAddonRole = {
2
2
  name: string;
3
3
  description?: string;
4
+ /** The Site access whose holders hold the role without a grant, as the manifest declares it. */
5
+ impliedBy?: {
6
+ siteAccess: string;
7
+ };
4
8
  /** Whether the acting person may hand this role out, as the Core decided it for this request. */
5
9
  grantable: boolean;
6
10
  };
@@ -14,18 +18,52 @@ export type PhiAddonRoleAssignment = {
14
18
  addonId: string;
15
19
  role: string;
16
20
  };
21
+ /**
22
+ * A role somebody holds without a stored grant, because they hold the Site access it is `impliedBy` (or one
23
+ * that includes it is): the Core's `implied` / `impliedAddonRoles` entry `{ addonId, role, through: {
24
+ * siteAccess } }`. Shown as held, never sent back by a save -- only the access gives it and takes it away.
25
+ */
26
+ export type PhiAddonRoleHeldThroughSiteAccess = PhiAddonRoleAssignment & {
27
+ siteAccess: string;
28
+ };
29
+ /**
30
+ * Where a placement names the words for Add-on roles held through a Site access, in its language: the edit
31
+ * form's `formConfig` and the users Table's `source.params` carry them under this key, written by the users
32
+ * page preset from the Module's Label Set. The options and Table Providers are Client code without a Label
33
+ * Set; the placement has one (the curation Form's "Nobody" reaches its Provider the same way).
34
+ */
35
+ export declare const PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY = "addonRoleTexts";
36
+ /**
37
+ * The `params.list` value under which the edit form's choices Provider answers the roles held through a Site
38
+ * access instead of the roles to choose.
39
+ */
40
+ export declare const PHI_USER_MANAGEMENT_ADDON_ROLE_IMPLIED_LIST = "implied";
41
+ export type PhiAddonRoleTexts = {
42
+ /** A role (or an Add-on's roles, `%1`) and the Site access (`%2`) it is held through: "%1 (via %2)". */
43
+ via: string;
44
+ /** What a role in the catalog that a Site access implies says of it: "Implied by %1". */
45
+ impliedBy: string;
46
+ /** What each Site access is called; one not named here is shown by its key. */
47
+ siteAccess: Readonly<Record<string, string>>;
48
+ };
49
+ /** The words a placement named under `PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY`; the source text where none. */
50
+ export declare function readPhiAddonRoleTexts(value: unknown): PhiAddonRoleTexts;
17
51
  /** The catalog of an `GET /api/site/addon-roles` answer; entries and roles that do not read are left out. */
18
52
  export declare function readPhiAddonRoleCatalog(payload: unknown): PhiAddonRoleCatalogEntry[];
19
53
  /** The stored assignments in a user row's `addonRoles` or an answer's `held`. */
20
54
  export declare function readPhiAddonRoleAssignments(value: unknown): PhiAddonRoleAssignment[];
55
+ /** The Core's `implied` (an answer of `/api/site/addon-roles`) or a user row's `impliedAddonRoles`. */
56
+ export declare function readPhiAddonRolesHeldThroughSiteAccess(value: unknown): PhiAddonRoleHeldThroughSiteAccess[];
21
57
  /** The tag a Site Admin's row carries in place of single roles; the Table maps it to its label. */
22
58
  export declare const PHI_USER_MANAGEMENT_ADDON_ALL_ROLES_TAG = "all";
23
59
  /**
24
60
  * The tags of a row's Add-on roles column: one tag per Add-on with its stored roles, so the column stays
25
- * narrow, and for a Site Admin the one tag that says every role is held. Stored assignments for a Site Admin
26
- * are not listed (they apply when the person is no longer one; the dialog shows them).
61
+ * narrow, then one per Add-on and Site access with the roles held through that access ("@acme/books:
62
+ * licence-manager (via Accounting)"), and for a Site Admin the one tag that says every role is held. Stored
63
+ * assignments for a Site Admin are not listed (they apply when the person is no longer one; the dialog shows
64
+ * them). A role both stored and held through an access is in both tags: taking the grant back leaves it held.
27
65
  */
28
- export declare function buildPhiAddonRoleTags(row: Record<string, unknown>): string[];
66
+ export declare function buildPhiAddonRoleTags(row: Record<string, unknown>, texts?: PhiAddonRoleTexts): string[];
29
67
  /**
30
68
  * The users Table filter's options: one per Add-on, never a single role -- choosing one finds whoever holds
31
69
  * any of its roles (the Core's `addonId` filter). The label is the Add-on's title; the id is the description,
@@ -36,6 +74,8 @@ export declare function buildPhiAddonFilterOptions(catalog: readonly PhiAddonRol
36
74
  value: string;
37
75
  label: string;
38
76
  }[];
77
+ /** One role as the user save names it: `"<addonId>:<role>"`, which the Core splits at the last colon. */
78
+ export declare function formatPhiAddonRoleValue(addonId: string, role: string): string;
39
79
  /**
40
80
  * The edit form's Add-on role choices, under one heading per Add-on: every role the acting person may grant,
41
81
  * and the ones the person edited holds that the actor may not grant, disabled.
@@ -46,11 +86,27 @@ export declare function buildPhiAddonFilterOptions(catalog: readonly PhiAddonRol
46
86
  * standing over. As a disabled option it stays in the value as a tag nobody can remove, and the save sends it
47
87
  * unchanged. `held` is null where the Core did not say what the person holds; every role the actor may not
48
88
  * grant is listed disabled then, so whichever of them the person holds is kept the same way.
89
+ *
90
+ * A role a Site access implies says so in its description ("Implied by Accounting"): choosing it stores a
91
+ * grant beside the access, which keeps the role once the access is gone.
49
92
  */
50
- export declare function buildPhiAddonRoleChoiceOptions(catalog: readonly PhiAddonRoleCatalogEntry[], held: readonly PhiAddonRoleAssignment[] | null): {
93
+ export declare function buildPhiAddonRoleChoiceOptions(catalog: readonly PhiAddonRoleCatalogEntry[], held: readonly PhiAddonRoleAssignment[] | null, texts?: PhiAddonRoleTexts): {
51
94
  disabled?: boolean | undefined;
52
95
  group: string;
53
96
  description?: string | undefined;
54
97
  value: string;
55
98
  label: string;
56
99
  }[];
100
+ /**
101
+ * The options of the edit form's read-only list of roles held through a Site access: one per role, labelled
102
+ * with the access ("licence-manager (via Accounting)") so the tag says why it is there, under its Add-on's
103
+ * name, and disabled -- nobody removes a role an access gives. Valued as the save names roles; the save
104
+ * carries the list under its own key, which the Core does not read, so the stored grants stay the other
105
+ * field's alone.
106
+ */
107
+ export declare function buildPhiAddonRoleImpliedOptions(catalog: readonly PhiAddonRoleCatalogEntry[], implied: readonly PhiAddonRoleHeldThroughSiteAccess[], texts?: PhiAddonRoleTexts): {
108
+ value: string;
109
+ label: string;
110
+ group: string;
111
+ disabled: boolean;
112
+ }[];
@@ -1,5 +1,37 @@
1
1
  import { isPhiRecord } from "../../../helpers/is-record";
2
+ import { formatPhiTranslation } from "../../../helpers/translation-format";
2
3
  const ROLE_NAME = /^[a-z][a-z0-9-]{0,63}$/u;
4
+ const SITE_ACCESS_NAME = /^[a-z][a-z-]{0,63}$/u;
5
+ /**
6
+ * Where a placement names the words for Add-on roles held through a Site access, in its language: the edit
7
+ * form's `formConfig` and the users Table's `source.params` carry them under this key, written by the users
8
+ * page preset from the Module's Label Set. The options and Table Providers are Client code without a Label
9
+ * Set; the placement has one (the curation Form's "Nobody" reaches its Provider the same way).
10
+ */
11
+ export const PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY = "addonRoleTexts";
12
+ /**
13
+ * The `params.list` value under which the edit form's choices Provider answers the roles held through a Site
14
+ * access instead of the roles to choose.
15
+ */
16
+ export const PHI_USER_MANAGEMENT_ADDON_ROLE_IMPLIED_LIST = "implied";
17
+ /** The words a placement named under `PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY`; the source text where none. */
18
+ export function readPhiAddonRoleTexts(value) {
19
+ const record = isPhiRecord(value) ? value : {};
20
+ const siteAccess = isPhiRecord(record.siteAccess)
21
+ ? Object.fromEntries(Object.entries(record.siteAccess).flatMap(([access, word]) => {
22
+ const text = readString(word);
23
+ return text ? [[access, text]] : [];
24
+ }))
25
+ : {};
26
+ return {
27
+ via: readString(record.via) ?? "%1 (via %2)",
28
+ impliedBy: readString(record.impliedBy) ?? "Implied by %1",
29
+ siteAccess,
30
+ };
31
+ }
32
+ function nameSiteAccess(texts, siteAccess) {
33
+ return texts.siteAccess[siteAccess] ?? siteAccess;
34
+ }
3
35
  function readString(value) {
4
36
  return typeof value === "string" && value.trim() ? value.trim() : null;
5
37
  }
@@ -19,7 +51,13 @@ export function readPhiAddonRoleCatalog(payload) {
19
51
  if (!name || !ROLE_NAME.test(name))
20
52
  return [];
21
53
  const description = readString(role.description);
22
- return [{ name, ...(description ? { description } : {}), grantable: role.grantable === true }];
54
+ const impliedBy = isPhiRecord(role.impliedBy) ? readString(role.impliedBy.siteAccess) : null;
55
+ return [{
56
+ name,
57
+ ...(description ? { description } : {}),
58
+ ...(impliedBy && SITE_ACCESS_NAME.test(impliedBy) ? { impliedBy: { siteAccess: impliedBy } } : {}),
59
+ grantable: role.grantable === true,
60
+ }];
23
61
  });
24
62
  return roles.length > 0 ? [{ addonId, title: readString(addon.title) ?? addonId, roles }] : [];
25
63
  });
@@ -34,6 +72,17 @@ export function readPhiAddonRoleAssignments(value) {
34
72
  return addonId && role ? [{ addonId, role }] : [];
35
73
  });
36
74
  }
75
+ /** The Core's `implied` (an answer of `/api/site/addon-roles`) or a user row's `impliedAddonRoles`. */
76
+ export function readPhiAddonRolesHeldThroughSiteAccess(value) {
77
+ return (Array.isArray(value) ? value : []).flatMap((entry) => {
78
+ if (!isPhiRecord(entry) || !isPhiRecord(entry.through))
79
+ return [];
80
+ const addonId = readString(entry.addonId);
81
+ const role = readString(entry.role);
82
+ const siteAccess = readString(entry.through.siteAccess);
83
+ return addonId && role && siteAccess ? [{ addonId, role, siteAccess }] : [];
84
+ });
85
+ }
37
86
  /** The tag a Site Admin's row carries in place of single roles; the Table maps it to its label. */
38
87
  export const PHI_USER_MANAGEMENT_ADDON_ALL_ROLES_TAG = "all";
39
88
  /**
@@ -45,17 +94,29 @@ function isPhiAddonRoleHolderOfAll(row) {
45
94
  }
46
95
  /**
47
96
  * The tags of a row's Add-on roles column: one tag per Add-on with its stored roles, so the column stays
48
- * narrow, and for a Site Admin the one tag that says every role is held. Stored assignments for a Site Admin
49
- * are not listed (they apply when the person is no longer one; the dialog shows them).
97
+ * narrow, then one per Add-on and Site access with the roles held through that access ("@acme/books:
98
+ * licence-manager (via Accounting)"), and for a Site Admin the one tag that says every role is held. Stored
99
+ * assignments for a Site Admin are not listed (they apply when the person is no longer one; the dialog shows
100
+ * them). A role both stored and held through an access is in both tags: taking the grant back leaves it held.
50
101
  */
51
- export function buildPhiAddonRoleTags(row) {
102
+ export function buildPhiAddonRoleTags(row, texts = readPhiAddonRoleTexts(null)) {
52
103
  if (isPhiAddonRoleHolderOfAll(row))
53
104
  return [PHI_USER_MANAGEMENT_ADDON_ALL_ROLES_TAG];
54
105
  const byAddon = new Map();
55
106
  for (const { addonId, role } of readPhiAddonRoleAssignments(row.addonRoles)) {
56
107
  byAddon.set(addonId, [...(byAddon.get(addonId) ?? []), role]);
57
108
  }
58
- return [...byAddon].map(([addonId, roles]) => `${addonId}: ${roles.join(", ")}`);
109
+ const byAccess = new Map();
110
+ for (const { addonId, role, siteAccess } of readPhiAddonRolesHeldThroughSiteAccess(row.impliedAddonRoles)) {
111
+ const key = `${addonId}\u0000${siteAccess}`;
112
+ const entry = byAccess.get(key) ?? { addonId, siteAccess, roles: [] };
113
+ entry.roles.push(role);
114
+ byAccess.set(key, entry);
115
+ }
116
+ return [
117
+ ...[...byAddon].map(([addonId, roles]) => `${addonId}: ${roles.join(", ")}`),
118
+ ...[...byAccess.values()].map(({ addonId, siteAccess, roles }) => formatPhiTranslation(texts.via, [`${addonId}: ${roles.join(", ")}`, nameSiteAccess(texts, siteAccess)])),
119
+ ];
59
120
  }
60
121
  /**
61
122
  * The users Table filter's options: one per Add-on, never a single role -- choosing one finds whoever holds
@@ -70,7 +131,7 @@ export function buildPhiAddonFilterOptions(catalog) {
70
131
  }));
71
132
  }
72
133
  /** One role as the user save names it: `"<addonId>:<role>"`, which the Core splits at the last colon. */
73
- function formatPhiAddonRoleValue(addonId, role) {
134
+ export function formatPhiAddonRoleValue(addonId, role) {
74
135
  return `${addonId}:${role}`;
75
136
  }
76
137
  /**
@@ -83,19 +144,42 @@ function formatPhiAddonRoleValue(addonId, role) {
83
144
  * standing over. As a disabled option it stays in the value as a tag nobody can remove, and the save sends it
84
145
  * unchanged. `held` is null where the Core did not say what the person holds; every role the actor may not
85
146
  * grant is listed disabled then, so whichever of them the person holds is kept the same way.
147
+ *
148
+ * A role a Site access implies says so in its description ("Implied by Accounting"): choosing it stores a
149
+ * grant beside the access, which keeps the role once the access is gone.
86
150
  */
87
- export function buildPhiAddonRoleChoiceOptions(catalog, held) {
151
+ export function buildPhiAddonRoleChoiceOptions(catalog, held, texts = readPhiAddonRoleTexts(null)) {
88
152
  const heldValues = held ? new Set(held.map(({ addonId, role }) => formatPhiAddonRoleValue(addonId, role))) : null;
89
153
  return catalog.flatMap((entry) => entry.roles.flatMap((role) => {
90
154
  const value = formatPhiAddonRoleValue(entry.addonId, role.name);
91
155
  if (!role.grantable && heldValues && !heldValues.has(value))
92
156
  return [];
157
+ const description = [
158
+ role.description,
159
+ role.impliedBy ? formatPhiTranslation(texts.impliedBy, [nameSiteAccess(texts, role.impliedBy.siteAccess)]) : undefined,
160
+ ].filter(Boolean).join(" · ");
93
161
  return [{
94
162
  value,
95
163
  label: role.name,
96
- ...(role.description ? { description: role.description } : {}),
164
+ ...(description ? { description } : {}),
97
165
  group: entry.title,
98
166
  ...(role.grantable ? {} : { disabled: true }),
99
167
  }];
100
168
  }));
101
169
  }
170
+ /**
171
+ * The options of the edit form's read-only list of roles held through a Site access: one per role, labelled
172
+ * with the access ("licence-manager (via Accounting)") so the tag says why it is there, under its Add-on's
173
+ * name, and disabled -- nobody removes a role an access gives. Valued as the save names roles; the save
174
+ * carries the list under its own key, which the Core does not read, so the stored grants stay the other
175
+ * field's alone.
176
+ */
177
+ export function buildPhiAddonRoleImpliedOptions(catalog, implied, texts = readPhiAddonRoleTexts(null)) {
178
+ const titles = new Map(catalog.map((entry) => [entry.addonId, entry.title]));
179
+ return implied.map(({ addonId, role, siteAccess }) => ({
180
+ value: formatPhiAddonRoleValue(addonId, role),
181
+ label: formatPhiTranslation(texts.via, [role, nameSiteAccess(texts, siteAccess)]),
182
+ group: titles.get(addonId) ?? addonId,
183
+ disabled: true,
184
+ }));
185
+ }
@@ -1,3 +1,3 @@
1
1
  export declare const PHI_USER_MANAGEMENT_PAGE_LAYOUT_IDS: Readonly<Record<"layoutCreate" | "layoutCreateFooter" | "layoutEdit" | "layoutEditFooter" | "layoutHistory", import("@phis/contracts/cms").PhiCmsInstanceId>>;
2
2
  export declare const PHI_USER_MANAGEMENT_PAGE_OVERLAY_IDS: Readonly<Record<"overlayCreate" | "overlayEdit" | "overlayHistory", import("@phis/contracts/cms").PhiCmsInstanceId>>;
3
- export declare const PHI_USER_MANAGEMENT_PAGE_WIDGET_IDS: Readonly<Record<"widgetCreateForm" | "widgetCreateCommands" | "widgetTable" | "widgetEditForm" | "widgetEditCommands" | "widgetHistoryTable", import("@phis/contracts/cms").PhiCmsInstanceId>>;
3
+ export declare const PHI_USER_MANAGEMENT_PAGE_WIDGET_IDS: Readonly<Record<"widgetTable" | "widgetCreateForm" | "widgetCreateCommands" | "widgetEditForm" | "widgetEditCommands" | "widgetHistoryTable", import("@phis/contracts/cms").PhiCmsInstanceId>>;
@@ -33,7 +33,7 @@ function PhiUserManagementControllerView({ address, runtime, config, }) {
33
33
  const { provider } = usePhiTableProvider(source);
34
34
  const locale = usePhiIntlLocale();
35
35
  const timeZone = usePhiIntlTimeZone();
36
- // The route lets a Developer in; only a Site admin may change anything. Stated as the policy the
36
+ // The route lets a Maintainer in; only a Site admin may change anything. Stated as the policy the
37
37
  // rest of the system speaks rather than as a role check, so a widened admin mask carries here too.
38
38
  const readOnly = !canPhiViewerAccess(runtime.viewer, PHI_VIEWER_ACCESS_SITE_ADMIN);
39
39
  const [workflowState, setWorkflowState] = useState(null);
@@ -54,6 +54,7 @@ export const PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
54
54
  { key: "accountType", title: "Account type", type: "string" },
55
55
  { key: "roleTags", title: "Roles", type: "json" },
56
56
  { key: "addonRoles", title: "Add-on role assignments", type: "json" },
57
+ { key: "impliedAddonRoles", title: "Add-on roles through a Site access", type: "json" },
57
58
  { key: "addonRoleTags", title: "Add-on roles", type: "json" },
58
59
  { key: "userFlagTags", title: "User flags", type: "json" },
59
60
  { key: "siteFlagTags", title: "Site flags", type: "json" },
@@ -7,6 +7,7 @@ import { PHI_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_VALIDATION_PROVIDER_KEYS, create
7
7
  import { definePhiRuntimeModuleForm } from "../../../components/forms/form-registry";
8
8
  import { createPhiUserManagementControllerAddress } from "./controller/address";
9
9
  import { phiFormLabel as label, phiFormRequired as required } from "../../../components/forms/form-descriptor-text";
10
+ import { PHI_USER_MANAGEMENT_ADDON_ROLE_IMPLIED_LIST } from "./addon-roles";
10
11
  export const PHI_USER_MANAGEMENT_FORM_IDS = {
11
12
  create: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "user-management/create"),
12
13
  edit: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "user-management/edit"),
@@ -148,6 +149,25 @@ function descriptor(formId, mode) {
148
149
  conditions: [readOnlyCondition, selfRoleCondition, siteAdminTargetCondition],
149
150
  },
150
151
  },
152
+ /*
153
+ * What a Site access gives without a grant, beside the grants: shown, never edited. The record carries
154
+ * it as `"<addonId>:<role>"` strings (null where there are none, which hides the field); the options are
155
+ * the same answer's `implied`, each labelled with its access. The save sends the field along under its
156
+ * own key, which the Core does not read, so nothing here is ever stored or taken back.
157
+ */
158
+ {
159
+ key: "impliedAddonRoles",
160
+ fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.multiSelect,
161
+ label: label("impliedAddonRoles", "Add-on roles through Core roles"),
162
+ description: label("impliedAddonRolesHint", "Held without a grant while the person has the Core role that implies them. They cannot be removed here."),
163
+ optionsProvider: {
164
+ providerKey: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.addonRoleChoiceOptions,
165
+ params: { list: PHI_USER_MANAGEMENT_ADDON_ROLE_IMPLIED_LIST },
166
+ dependencies: [{ param: "userId", source: "form", valuePath: "userId", required: true }],
167
+ },
168
+ config: { disabled: true },
169
+ visibleWhen: { source: "form", valuePath: "impliedAddonRoles", operator: "truthy" },
170
+ },
151
171
  {
152
172
  key: "enabled",
153
173
  fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.switch,
@@ -184,6 +204,8 @@ const loadLabels = createPhiFormLabelSetLoader(() => import("../../../components
184
204
  addonRoles: labels.editor.addonRoles,
185
205
  addonRolesPlaceholder: labels.editor.addonRolesPlaceholder,
186
206
  addonRolesHint: labels.editor.addonRolesHint,
207
+ impliedAddonRoles: labels.editor.impliedAddonRoles,
208
+ impliedAddonRolesHint: labels.editor.impliedAddonRolesHint,
187
209
  authOnlyHint: labels.editor.authOnlyHint,
188
210
  createPasswordHint: labels.editor.createPasswordHint,
189
211
  enabled: labels.columns.enabled,
@@ -7,8 +7,8 @@ export const PHI_USER_MANAGEMENT_RUNTIME_MODULE_ROUTES = [
7
7
  ownerModuleId: PHI_USER_MANAGEMENT_RUNTIME_MODULE_ID,
8
8
  presetKey: "admin-users-page",
9
9
  title: "Users",
10
- // A Developer reads user management but changes nothing, matching what `phi-server` enforces:
11
- // GET on /api/site/admin/users takes the developer guard, every mutating method the admin-only
10
+ // A Maintainer reads user management but changes nothing, matching what `phi-server` enforces:
11
+ // GET on /api/site/admin/users takes the maintainer guard, every mutating method the admin-only
12
12
  // one. The page carries that split through the controller's `permissions.readOnly` projection and
13
13
  // the `disabledWhen` conditions built on it, so entry is the route's decision and capability is
14
14
  // the surface's.
@@ -13,6 +13,10 @@ export declare const PhiUserManagementAddonRoleOptionsProviderClient: import("re
13
13
  * The Core refuses that question to an actor who may grant no role at all; such an actor is offered nothing,
14
14
  * and the plain catalog lists every role disabled, which keeps whatever the person holds. So does an answer
15
15
  * without a user to ask about.
16
+ *
17
+ * With `params.list` `implied` the same answer gives the read-only list beside it: the roles the person holds
18
+ * through a Site access (`implied`, `buildPhiAddonRoleImpliedOptions`), one load for both fields. The words
19
+ * for the access come from the placement (`PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY` in the form's config).
16
20
  */
17
21
  export declare const PhiUserManagementAddonRoleChoiceOptionsProviderClient: import("react").ComponentType<{
18
22
  children: import("react").ReactNode;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import { createPhiControlOptionsProviderClient } from "../../../../components/controls/phi-options-provider";
2
+ import { createPhiControlOptionsProviderClient, readPhiControlOptionsProviderParam, } from "../../../../components/controls/phi-options-provider";
3
3
  import { isPhiRecord } from "../../../../helpers/is-record";
4
- import { buildPhiAddonFilterOptions, buildPhiAddonRoleChoiceOptions, readPhiAddonRoleAssignments, readPhiAddonRoleCatalog, } from "../addon-roles";
4
+ import { PHI_USER_MANAGEMENT_ADDON_ROLE_IMPLIED_LIST, PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY, buildPhiAddonFilterOptions, buildPhiAddonRoleChoiceOptions, buildPhiAddonRoleImpliedOptions, readPhiAddonRoleAssignments, readPhiAddonRoleCatalog, readPhiAddonRoleTexts, readPhiAddonRolesHeldThroughSiteAccess, } from "../addon-roles";
5
5
  import { PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
6
6
  const ADDON_ROLES_PATH = "/api/site/addon-roles";
7
7
  async function fetchAddonRoles(query) {
@@ -39,6 +39,10 @@ function readUserId(value) {
39
39
  * The Core refuses that question to an actor who may grant no role at all; such an actor is offered nothing,
40
40
  * and the plain catalog lists every role disabled, which keeps whatever the person holds. So does an answer
41
41
  * without a user to ask about.
42
+ *
43
+ * With `params.list` `implied` the same answer gives the read-only list beside it: the roles the person holds
44
+ * through a Site access (`implied`, `buildPhiAddonRoleImpliedOptions`), one load for both fields. The words
45
+ * for the access come from the placement (`PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY` in the form's config).
42
46
  */
43
47
  export const PhiUserManagementAddonRoleChoiceOptionsProviderClient = createPhiControlOptionsProviderClient({
44
48
  key: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.addonRoleChoiceOptions,
@@ -53,9 +57,13 @@ export const PhiUserManagementAddonRoleChoiceOptionsProviderClient = createPhiCo
53
57
  },
54
58
  resolveLoadKey: () => "user-management-addon-role-choices",
55
59
  resolve: (context) => {
56
- const held = isPhiRecord(context.asyncData) && Array.isArray(context.asyncData.held)
57
- ? readPhiAddonRoleAssignments(context.asyncData.held)
58
- : null;
59
- return { options: buildPhiAddonRoleChoiceOptions(readPhiAddonRoleCatalog(context.asyncData), held) };
60
+ const catalog = readPhiAddonRoleCatalog(context.asyncData);
61
+ const texts = readPhiAddonRoleTexts(context.sourceConfig?.[PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY]);
62
+ const answer = isPhiRecord(context.asyncData) ? context.asyncData : null;
63
+ if (readPhiControlOptionsProviderParam(context.optionsProvider, "list") === PHI_USER_MANAGEMENT_ADDON_ROLE_IMPLIED_LIST) {
64
+ return { options: buildPhiAddonRoleImpliedOptions(catalog, readPhiAddonRolesHeldThroughSiteAccess(answer?.implied), texts) };
65
+ }
66
+ const held = answer && Array.isArray(answer.held) ? readPhiAddonRoleAssignments(answer.held) : null;
67
+ return { options: buildPhiAddonRoleChoiceOptions(catalog, held, texts) };
60
68
  },
61
69
  });
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { isPhiRecord } from "../../../../helpers/is-record";
3
3
  import { PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
4
- import { buildPhiAddonRoleTags } from "../addon-roles";
4
+ import { PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY, buildPhiAddonRoleTags, formatPhiAddonRoleValue, readPhiAddonRoleTexts, readPhiAddonRolesHeldThroughSiteAccess, } from "../addon-roles";
5
5
  import { createPhiTableProviderRequestInit, readPhiPositiveInteger, readPhiTableRows, } from "../../../../components/widgets/client/shared/phi-table-provider-request";
6
6
  import { buildPhiUserManagementUsersQueryParams } from "./users-query";
7
7
  import { PhiTableProviderError, } from "../../../../types/table-widget";
@@ -10,10 +10,12 @@ import { PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_DESCRIPTORS } from "../../../
10
10
  import { readPhiTableProviderResponse, } from "../../../../components/widgets/client/shared/phi-table-provider-response";
11
11
  const API_PATH = "/api/site/admin/users";
12
12
  const RESPONSE_OPTIONS = { subject: "User Management" };
13
- async function loadUsers({ query, signal, }) {
13
+ async function loadUsers({ query, params: bindingParams, signal, }) {
14
14
  const params = buildPhiUserManagementUsersQueryParams(query);
15
15
  const result = await readPhiTableProviderResponse(await fetch(`${API_PATH}?${params.toString()}`, createPhiTableProviderRequestInit(signal)), RESPONSE_OPTIONS);
16
- const rows = readPhiTableRows(result?.rows).map((row) => ({ ...row, addonRoleTags: buildPhiAddonRoleTags(row) }));
16
+ // The words for roles held through a Site access come from the placement (`source.params`).
17
+ const texts = readPhiAddonRoleTexts(bindingParams?.[PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY]);
18
+ const rows = readPhiTableRows(result?.rows).map((row) => ({ ...row, addonRoleTags: buildPhiAddonRoleTags(row, texts) }));
17
19
  if (typeof result?.siteTotal !== "number" || !Number.isFinite(result.siteTotal) || result.siteTotal < 0) {
18
20
  throw new PhiTableProviderError("invalid-response", "User Management site total is invalid.");
19
21
  }
@@ -63,6 +65,8 @@ async function readUserRecord({ rowIdentity, signal }) {
63
65
  throw new PhiTableProviderError("invalid-response", "User record response is invalid.");
64
66
  }
65
67
  const user = result.user;
68
+ const implied = readPhiAddonRolesHeldThroughSiteAccess(user.impliedAddonRoles)
69
+ .map(({ addonId, role }) => formatPhiAddonRoleValue(addonId, role));
66
70
  return {
67
71
  ...user,
68
72
  userId: String(userId),
@@ -71,6 +75,11 @@ async function readUserRecord({ rowIdentity, signal }) {
71
75
  addonRoles: Array.isArray(user.addonRoles)
72
76
  ? user.addonRoles.filter((entry) => typeof entry === "string")
73
77
  : [],
78
+ /*
79
+ * The roles a Site access gives, in the same form, for the read-only field beside them; null rather than
80
+ * an empty list where there are none, so the field's `visibleWhen` hides it.
81
+ */
82
+ impliedAddonRoles: implied.length > 0 ? implied : null,
74
83
  changePassword: false,
75
84
  };
76
85
  }