@phis/ui 0.7.5 → 0.7.7
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.
- package/components/controls/phi-form-control.d.ts +3 -1
- package/components/controls/phi-form-control.js +4 -4
- package/components/forms/auth-admin-settings-labels.d.ts +1 -1
- package/components/forms/auth-admin-settings-labels.js +2 -2
- package/components/forms/form-descriptor-contract.d.ts +1 -1
- package/components/forms/form-descriptor-contract.js +1 -1
- package/components/forms/form-descriptor-runtime-client.d.ts +4 -1
- package/components/forms/form-descriptor-runtime-client.js +33 -11
- package/components/forms/form-media-limits.d.ts +12 -0
- package/components/forms/form-media-limits.js +14 -0
- package/components/forms/form-provider-registry.d.ts +8 -0
- package/components/forms/form-record-title.d.ts +14 -0
- package/components/forms/form-record-title.js +38 -0
- package/components/forms/form-widget-config.d.ts +3 -0
- package/components/forms/form-widget-config.js +2 -0
- package/components/forms/phi-form-widget.d.ts +1 -1
- package/components/forms/phi-form-widget.js +4 -0
- package/components/overlays/phi-overlay-container-client.js +8 -8
- package/components/overlays/phi-overlay-title.d.ts +7 -0
- package/components/overlays/phi-overlay-title.js +21 -0
- package/components/tables/client/phi-table-binding.d.ts +3 -1
- package/components/tables/client/phi-table-binding.js +90 -49
- package/components/tables/client/phi-table-filter-options.d.ts +27 -0
- package/components/tables/client/phi-table-filter-options.js +35 -0
- package/components/widgets/accessible-areas.d.ts +1 -1
- package/components/widgets/accessible-areas.js +1 -1
- package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
- package/components/widgets/client/shared/phi-rendered-value.js +49 -1
- package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
- package/components/widgets/client/shared/phi-table-provider.js +22 -0
- package/components/widgets/label-sets/admin-users.d.ts +15 -0
- package/components/widgets/label-sets/admin-users.js +31 -0
- package/constants/core-data-provider-keys.d.ts +7 -0
- package/constants/core-data-provider-keys.js +7 -0
- package/constants/phi-base-role-metadata.d.ts +2 -2
- package/constants/phi-base-role-metadata.js +1 -1
- package/constants/runtime-module-ownership.js +3 -0
- package/forms.d.ts +1 -1
- package/forms.js +1 -1
- package/gateway/capability-media-limits.d.ts +10 -0
- package/gateway/capability-media-limits.js +40 -0
- package/gateway/server-capabilities.js +4 -0
- package/helpers/preset-tree-contract-check.d.ts +3 -2
- package/helpers/preset-tree-contract-check.js +60 -0
- package/helpers/record-title.d.ts +7 -0
- package/helpers/record-title.js +25 -0
- package/helpers/record-widget.d.ts +15 -0
- package/helpers/record-widget.js +57 -0
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
- package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
- package/plugins/runtime-modules/accounting/data-providers.js +127 -0
- package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
- package/plugins/runtime-modules/accounting/definition.js +5 -3
- package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
- package/plugins/runtime-modules/accounting/ids.js +27 -0
- package/plugins/runtime-modules/accounting/module.d.ts +52 -0
- package/plugins/runtime-modules/accounting/presets.js +23 -4
- package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
- package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
- package/plugins/runtime-modules/area-definitions.js +2 -2
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
- package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
- package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
- package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
- package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
- package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
- package/plugins/runtime-modules/core/cards.js +2 -2
- package/plugins/runtime-modules/core/client-data-providers.js +5 -0
- package/plugins/runtime-modules/core/data-providers.js +14 -0
- package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
- package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
- package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
- package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
- package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
- package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
- package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
- package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
- package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
- package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
- package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
- package/plugins/runtime-modules/groups/data-providers.js +1 -1
- package/plugins/runtime-modules/groups/definition.js +1 -1
- package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
- package/plugins/runtime-modules/groups/page-visibility.js +1 -1
- package/plugins/runtime-modules/groups/presets.js +1 -1
- package/plugins/runtime-modules/groups/services/options.js +1 -1
- package/plugins/runtime-modules/groups/services/table.js +1 -1
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
- package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
- package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
- package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
- package/plugins/runtime-modules/user-management/controller/client.js +1 -1
- package/plugins/runtime-modules/user-management/data-providers.js +1 -0
- package/plugins/runtime-modules/user-management/forms.js +22 -0
- package/plugins/runtime-modules/user-management/presets.js +2 -2
- package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
- package/plugins/runtime-modules/user-management/services/options.js +14 -6
- package/plugins/runtime-modules/user-management/services/table.js +12 -3
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
- package/types/access.d.ts +1 -1
- package/types/access.js +7 -7
- package/types/core-widget-placements.d.ts +7 -0
- package/types/form-descriptor.d.ts +1 -1
- package/types/record-widget.d.ts +35 -0
- package/types/server-capabilities.d.ts +1 -1
- package/types/table-widget.d.ts +20 -0
- package/types/table-widget.js +44 -0
|
@@ -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
|
-
|
|
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,
|
|
49
|
-
*
|
|
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
|
-
|
|
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
|
-
...(
|
|
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<"
|
|
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
|
|
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
|
|
11
|
-
// GET on /api/site/admin/users takes the
|
|
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
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -6,7 +6,7 @@ import { buildPhiBasePageContentScaffold, PHI_BASE_PAGE_LAYOUT_NODE_ID } from ".
|
|
|
6
6
|
import { getPhiAdminUsersPageLabels } from "./admin-users-label-set";
|
|
7
7
|
import { getPhiAdminUsersTableWidgetLabels } from "../../../../components/widgets/label-sets/admin-users";
|
|
8
8
|
import { PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
|
|
9
|
-
import { PHI_USER_MANAGEMENT_ADDON_ALL_ROLES_TAG } from "../addon-roles";
|
|
9
|
+
import { PHI_USER_MANAGEMENT_ADDON_ALL_ROLES_TAG, PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY } from "../addon-roles";
|
|
10
10
|
import { createPhiSignalAddress, createPhiSignalSubcontrolAddress, PHI_SIGNAL_VALUE_SCHEMAS } from "../../../../types/signals";
|
|
11
11
|
import { createPhiUserManagementControllerAddress, PHI_USER_MANAGEMENT_CONTROLLER_INSTANCE_KEY, PHI_USER_MANAGEMENT_CONTROLLER_TYPE, } from "../controller/address";
|
|
12
12
|
import { PHI_USER_MANAGEMENT_FORM_IDS } from "../forms";
|
|
@@ -32,7 +32,7 @@ export async function buildPhiDefaultAdminUsersPageTree({ page, runtime, }) {
|
|
|
32
32
|
controllerAddress,
|
|
33
33
|
valuePath: "permissions.readOnly",
|
|
34
34
|
operator: "truthy",
|
|
35
|
-
reason: "
|
|
35
|
+
reason: "Maintainers can inspect users but cannot change them.",
|
|
36
36
|
};
|
|
37
37
|
const selfEnabledCondition = {
|
|
38
38
|
source: "row",
|
|
@@ -252,6 +252,8 @@ export async function buildPhiDefaultAdminUsersPageTree({ page, runtime, }) {
|
|
|
252
252
|
source: {
|
|
253
253
|
providerKey: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.table,
|
|
254
254
|
resourceKey: "users",
|
|
255
|
+
// The words for roles held through a Site access, in the page's language; the Provider reads them.
|
|
256
|
+
params: { [PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY]: widgetLabels.addonRoleTexts },
|
|
255
257
|
},
|
|
256
258
|
presentation: {
|
|
257
259
|
controlSize: "small",
|
|
@@ -282,7 +284,7 @@ export async function buildPhiDefaultAdminUsersPageTree({ page, runtime, }) {
|
|
|
282
284
|
sizing: { mode: "content" },
|
|
283
285
|
tagColorMap: {
|
|
284
286
|
admin: "error",
|
|
285
|
-
|
|
287
|
+
maintainer: "error",
|
|
286
288
|
editor: "processing",
|
|
287
289
|
author: "processing",
|
|
288
290
|
publisher: "warning",
|
|
@@ -460,7 +462,10 @@ export async function buildPhiDefaultAdminUsersPageTree({ page, runtime, }) {
|
|
|
460
462
|
label: `admin users ${mode} form`,
|
|
461
463
|
config: {
|
|
462
464
|
formId,
|
|
463
|
-
formConfig: mode === "create"
|
|
465
|
+
formConfig: mode === "create"
|
|
466
|
+
? { initialValues: { roles: [] } }
|
|
467
|
+
// The words the Add-on role Providers label roles held through a Site access with.
|
|
468
|
+
: { [PHI_USER_MANAGEMENT_ADDON_ROLE_TEXTS_KEY]: widgetLabels.addonRoleTexts },
|
|
464
469
|
execution: { mode: "handler" },
|
|
465
470
|
source: mode === "edit" ? {
|
|
466
471
|
providerKey: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.table,
|
package/types/access.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare const PHI_VIEWER_ACCESS_SITE_ADMIN: {
|
|
|
23
23
|
readonly providerId: "@phis/server/core";
|
|
24
24
|
readonly allowedRoleFlags: number;
|
|
25
25
|
};
|
|
26
|
-
export declare const
|
|
26
|
+
export declare const PHI_VIEWER_ACCESS_SITE_MAINTENANCE: {
|
|
27
27
|
readonly access: "roles";
|
|
28
28
|
readonly providerId: "@phis/server/core";
|
|
29
29
|
readonly allowedRoleFlags: number;
|
package/types/access.js
CHANGED
|
@@ -21,35 +21,35 @@ export const PHI_VIEWER_ACCESS_SITE_ADMIN = {
|
|
|
21
21
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
22
22
|
allowedRoleFlags: PhiBaseRole.Admin,
|
|
23
23
|
};
|
|
24
|
-
export const
|
|
24
|
+
export const PHI_VIEWER_ACCESS_SITE_MAINTENANCE = {
|
|
25
25
|
access: "roles",
|
|
26
26
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
27
|
-
allowedRoleFlags: PhiBaseRole.
|
|
27
|
+
allowedRoleFlags: PhiBaseRole.Maintainer,
|
|
28
28
|
};
|
|
29
29
|
export const PHI_VIEWER_ACCESS_STRUCTURE_AUTHORING = {
|
|
30
30
|
access: "roles",
|
|
31
31
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
32
|
-
allowedRoleFlags: PhiBaseRole.
|
|
32
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Builder,
|
|
33
33
|
};
|
|
34
34
|
export const PHI_VIEWER_ACCESS_CONTENT_EDITING = {
|
|
35
35
|
access: "roles",
|
|
36
36
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
37
|
-
allowedRoleFlags: PhiBaseRole.
|
|
37
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Author | PhiBaseRole.Publisher,
|
|
38
38
|
};
|
|
39
39
|
export const PHI_VIEWER_ACCESS_PUBLISHING = {
|
|
40
40
|
access: "roles",
|
|
41
41
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
42
|
-
allowedRoleFlags: PhiBaseRole.
|
|
42
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Publisher,
|
|
43
43
|
};
|
|
44
44
|
export const PHI_VIEWER_ACCESS_SUPPORT = {
|
|
45
45
|
access: "roles",
|
|
46
46
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
47
|
-
allowedRoleFlags: PhiBaseRole.
|
|
47
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Supporter,
|
|
48
48
|
};
|
|
49
49
|
export const PHI_VIEWER_ACCESS_ACCOUNTING = {
|
|
50
50
|
access: "roles",
|
|
51
51
|
providerId: PHI_CORE_ROLE_PROVIDER_ID,
|
|
52
|
-
allowedRoleFlags: PhiBaseRole.
|
|
52
|
+
allowedRoleFlags: PhiBaseRole.Maintainer | PhiBaseRole.Accountant,
|
|
53
53
|
};
|
|
54
54
|
function asSubject(viewer) {
|
|
55
55
|
return {
|
|
@@ -12,6 +12,7 @@ import type { PhiMediaKindValue } from "./media";
|
|
|
12
12
|
import type { PhiCollectionProviderQuery } from "./collection-provider";
|
|
13
13
|
import type { PhiProviderResourceSource } from "./runtime-data-provider";
|
|
14
14
|
import type { PhiFormId } from "./form-id";
|
|
15
|
+
import type { PhiFormWidgetTitleFromRecord } from "../components/forms/form-record-title";
|
|
15
16
|
import type { PhiLinkTarget } from "./references";
|
|
16
17
|
import type { PhiMediaImageSourceConfig } from "./media";
|
|
17
18
|
import type { PhiViewerAccessPolicy } from "./access";
|
|
@@ -175,6 +176,10 @@ export type PhiRecordWidgetPlacement = PhiWidgetPlacementBase & {
|
|
|
175
176
|
source?: PhiRecordWidgetConfig["source"];
|
|
176
177
|
openActionKey?: PhiRecordWidgetConfig["openActionKey"];
|
|
177
178
|
presentation?: Partial<PhiRecordWidgetPresentation>;
|
|
179
|
+
/** Provider row actions of the source, run on the record shown by their key on `action/activate`. */
|
|
180
|
+
actions?: PhiRecordWidgetConfig["actions"];
|
|
181
|
+
/** A title from the record shown, announced on `recordTitle`, for the Overlay's `title` (TABLES.md). */
|
|
182
|
+
titleFromRecord?: PhiRecordWidgetConfig["titleFromRecord"];
|
|
178
183
|
};
|
|
179
184
|
/**
|
|
180
185
|
* Where a file goes: the Add-on, its table and the slot. What the slot takes is the Add-on's schema
|
|
@@ -292,6 +297,8 @@ export type PhiFormWidgetPlacement = PhiWidgetPlacementBase & {
|
|
|
292
297
|
source?: PhiProviderResourceSource | null;
|
|
293
298
|
/** Absent is a single-record form; the Form Widget's config says why that is an answer. */
|
|
294
299
|
openActionKey?: string;
|
|
300
|
+
/** A title from the record `source` reads, announced on `recordTitle`, for the Overlay's `title` (FORMS.md). */
|
|
301
|
+
titleFromRecord?: PhiFormWidgetTitleFromRecord | null;
|
|
295
302
|
};
|
|
296
303
|
export type PhiCmsCollectionViewMode = "grid" | "masonry" | "stack";
|
|
297
304
|
export type PhiCmsCollectionFilterControl = "select" | "multi-select" | "cascader";
|
|
@@ -2,7 +2,7 @@ import type { PhiCmsConfigField } from "./cms-plugins";
|
|
|
2
2
|
import type { PhiRuntimeModuleId } from "./cms-plugins";
|
|
3
3
|
import type { PhiFormProviderKey } from "@phis/contracts/forms";
|
|
4
4
|
import type { PhiFormSubmitCategory, PhiFormSubmitMethod, PhiFormSubmitTransport } from "./form-submit-route";
|
|
5
|
-
export { PHI_FORM_DEFAULT_SUBMIT_LABEL, PHI_FORM_DESCRIPTOR_SCHEMA_VERSION, PHI_FORM_GRID_TRACKS, type PhiFormDescriptor, type PhiFormFieldDescriptor, type PhiFormFieldPlacementDescriptor, type PhiFormGridRange, type PhiFormLabelSetKey, type PhiFormLayoutDescriptor, type PhiFormLogicalAlignment, type PhiFormOptionDescriptor, type PhiFormProviderKey, type PhiFormResponsiveGridRange, type PhiFormSubmitDescriptor, type PhiFormSuccessDescriptor, type PhiFormTextDescriptor, type PhiFormValidationRuleDescriptor, } from "@phis/contracts/forms";
|
|
5
|
+
export { PHI_FORM_DEFAULT_SUBMIT_LABEL, PHI_FORM_DESCRIPTOR_SCHEMA_VERSION, PHI_FORM_GRID_TRACKS, type PhiFormDescriptor, type PhiFormErrorTemplateDescriptor, type PhiFormErrorTextDescriptor, type PhiFormFieldDescriptor, type PhiFormFieldPlacementDescriptor, type PhiFormGridRange, type PhiFormLabelSetKey, type PhiFormLayoutDescriptor, type PhiFormLogicalAlignment, type PhiFormOptionDescriptor, type PhiFormProviderKey, type PhiFormResponsiveGridRange, type PhiFormSubmitDescriptor, type PhiFormSuccessDescriptor, type PhiFormTextDescriptor, type PhiFormValidationRuleDescriptor, } from "@phis/contracts/forms";
|
|
6
6
|
export type PhiFormHandlerPhase = "submit" | "confirm" | "preview";
|
|
7
7
|
export type PhiFormHandlerCredentialPolicy = "none" | "site-session" | "auth-link";
|
|
8
8
|
export type PhiFormFieldTypeProviderDescriptor = {
|
package/types/record-widget.d.ts
CHANGED
|
@@ -34,6 +34,38 @@ export type PhiRecordWidgetPresentation = {
|
|
|
34
34
|
columns: number;
|
|
35
35
|
fields: readonly PhiRecordFieldDefinition[];
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* A Provider action of the record's own resource, run on the record shown (TABLES.md, "The record
|
|
39
|
+
* Widget").
|
|
40
|
+
*
|
|
41
|
+
* The Table's row action without what drawing it takes: the record Widget draws no button -- a press
|
|
42
|
+
* arrives on its `action/activate` input as the action's key, from a Command Toolbar in the dialog's
|
|
43
|
+
* footer or any Control beside it, and that Control carries the words and the icon. What stays is what
|
|
44
|
+
* running it takes: which action, whether it is the danger a destructive one must be drawn as, and the
|
|
45
|
+
* question to ask first where showing the record is not question enough.
|
|
46
|
+
*/
|
|
47
|
+
export type PhiRecordWidgetAction = {
|
|
48
|
+
/** The action's key in the resource's `actions`; its scope is `row`. */
|
|
49
|
+
key: string;
|
|
50
|
+
/** `danger` for an action whose intent is `destructive`, which is also how its question is drawn. */
|
|
51
|
+
mode?: "normal" | "danger";
|
|
52
|
+
/** A question before it runs, `%1` the record's identity -- for a press that is not answer enough. */
|
|
53
|
+
confirm?: {
|
|
54
|
+
title: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
okText?: string;
|
|
57
|
+
cancelText?: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The dialog's title from the record shown: `template` with `%1` once, the value of `field` (dotted for a
|
|
62
|
+
* nested one) standing there, announced on `recordTitle` after every read (`helpers/record-title.ts`).
|
|
63
|
+
* The sentence is the placement's own, already in the reader's language like the field labels.
|
|
64
|
+
*/
|
|
65
|
+
export type PhiRecordWidgetTitleFromRecord = {
|
|
66
|
+
template: string;
|
|
67
|
+
field: string;
|
|
68
|
+
};
|
|
37
69
|
/**
|
|
38
70
|
* **Which record to show arrives as a signal.** The Widget does not know the table it belongs to and
|
|
39
71
|
* does not read a store: a row action carries a row identity onto the bus, and whoever listens on that
|
|
@@ -45,5 +77,8 @@ export type PhiRecordWidgetConfig = {
|
|
|
45
77
|
/** The row action whose signal opens a record -- `view` in every first-party table so far. */
|
|
46
78
|
openActionKey: string;
|
|
47
79
|
presentation: PhiRecordWidgetPresentation;
|
|
80
|
+
/** What may be done to the record shown, each run when its key arrives on `action/activate`. */
|
|
81
|
+
actions: readonly PhiRecordWidgetAction[];
|
|
82
|
+
titleFromRecord: PhiRecordWidgetTitleFromRecord | null;
|
|
48
83
|
signalRoutes?: PhiSignalRouteSet | null;
|
|
49
84
|
};
|
|
@@ -5,7 +5,7 @@ export declare const PHI_CORE_SERVER_CAPABILITY: {
|
|
|
5
5
|
readonly ResourceLinksV1: "@phis/server/resource-links:v1";
|
|
6
6
|
readonly SupportV1: "@phis/server/support:v1";
|
|
7
7
|
};
|
|
8
|
-
export type { PhiCapabilityDescriptor, PhiCapabilityId, PhiCapabilityProvider, PhiCapabilityProviderId, PhiCapabilitySnapshot, PhiCapabilityState, } from "@phis/contracts/server-capabilities";
|
|
8
|
+
export type { PhiAddonMediaLimits, PhiCapabilityDescriptor, PhiCapabilityId, PhiCapabilityProvider, PhiCapabilityProviderId, PhiCapabilitySnapshot, PhiCapabilityState, } from "@phis/contracts/server-capabilities";
|
|
9
9
|
import type { PhiCapabilityId, PhiCapabilityProviderId, PhiCapabilityState } from "@phis/contracts/server-capabilities";
|
|
10
10
|
export type PhiRuntimeModuleServerBinding = {
|
|
11
11
|
providerId: PhiCapabilityProviderId;
|
package/types/table-widget.d.ts
CHANGED
|
@@ -51,6 +51,13 @@ export type PhiTableQuery = {
|
|
|
51
51
|
* same rows draws the same values and must mean the same thing by `datetime` as the table does.
|
|
52
52
|
*/
|
|
53
53
|
export type PhiTableValueRenderer = "text" | "email" | "date" | "datetime" | "badge" | "tags" | "link" | "code" | "json" | "switch" | "checkbox" | "icon"
|
|
54
|
+
/**
|
|
55
|
+
* A small picture from a Site-relative address the Provider answers ready to load -- an image variant
|
|
56
|
+
* the server built with its cache revision (phis-server `resolvePhiMediaVariantUrl`, the `icon`
|
|
57
|
+
* variant for a list), never an Asset id put together here. Drawn at a fixed square box, fitted whole,
|
|
58
|
+
* lazily; any other address draws nothing. Bound to a `string` field.
|
|
59
|
+
*/
|
|
60
|
+
| "image"
|
|
54
61
|
/**
|
|
55
62
|
* An amount of money, `{ currency, minor }` -- the payment contract's `PhisPaymentMoney`, with `minor`
|
|
56
63
|
* an integer string or a safe integer of minor units -- written in the reader's language with the
|
|
@@ -80,6 +87,12 @@ export type PhiTableColumnDefinition = {
|
|
|
80
87
|
* Control's node `iconFieldKey`.
|
|
81
88
|
*/
|
|
82
89
|
iconFieldKey?: string;
|
|
90
|
+
/**
|
|
91
|
+
* A picture field drawn ahead of this column's own value, as `iconFieldKey` draws a named icon: the
|
|
92
|
+
* declared `string` field holding the Site-relative address the `image` renderer draws -- a product's
|
|
93
|
+
* icon beside its title. It stands for the value beside it, so it is decorative (empty `alt`).
|
|
94
|
+
*/
|
|
95
|
+
imageFieldKey?: string;
|
|
83
96
|
/**
|
|
84
97
|
* An icon for the column heading itself, from the same icon vocabulary as everything else
|
|
85
98
|
* (`antd:info-circle`, `@phis/ui/widgets:table`).
|
|
@@ -658,6 +671,13 @@ export declare function readPhiTableQuery(value: unknown): PhiTableQuery | null;
|
|
|
658
671
|
export declare function readPhiTableFilters(value: unknown): PhiTableQuery["filters"] | null;
|
|
659
672
|
export declare function readPhiTableProviderQueryResult(value: unknown): PhiTableProviderQueryResult | null;
|
|
660
673
|
export declare function readPhiTableProviderMutationResult(value: unknown): PhiTableProviderMutationResult | null;
|
|
674
|
+
/**
|
|
675
|
+
* Whether a Provider action may be asked for as stated: declared by the resource, with the row or the
|
|
676
|
+
* selection its scope needs, and a value of the type it declares. The one check every Widget that runs a
|
|
677
|
+
* Provider action makes before the Provider Client is called -- the Table's Binding and the record
|
|
678
|
+
* Widget alike -- answered as the error the Widget shows, or null.
|
|
679
|
+
*/
|
|
680
|
+
export declare function checkPhiTableProviderActionRequest(resource: Pick<PhiTableProviderResourceDescriptor, "resourceKey" | "actions"> | null | undefined, request: Pick<PhiTableProviderActionMutationRequest, "actionKey" | "rowIdentity" | "selectedRowIdentities" | "actionValue">): PhiTableProviderError | null;
|
|
661
681
|
/**
|
|
662
682
|
* The choices a row offers for a field that declares `rowOptionsPath`, or null when the row offers none.
|
|
663
683
|
* A generic reader: an entry without a string value and a string label is dropped, not repaired.
|