@phis/ui 0.6.3 → 0.6.5
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/cms/phi-cms-layout-renderer.js +11 -2
- package/components/controls/phi-multi-select-control.js +4 -2
- package/components/controls/phi-options-provider.d.ts +1 -0
- package/components/controls/phi-options-provider.js +1 -0
- package/components/controls/phi-segmented-control.js +15 -1
- package/components/controls/phi-select-control.d.ts +21 -0
- package/components/controls/phi-select-control.js +2 -2
- package/components/controls/phi-status-dot-control.d.ts +15 -0
- package/components/controls/phi-status-dot-control.js +25 -0
- package/components/controls/phi-table-control.js +8 -1
- package/components/controls/phi-tree-control.js +5 -4
- package/components/controls/phi-tree-select-control.js +1 -0
- package/components/layouts/clients/phi-split-card-half.d.ts +4 -1
- package/components/layouts/clients/phi-split-card-half.js +2 -2
- package/components/layouts/clients/phi-split-card-layout-client.d.ts +6 -3
- package/components/layouts/clients/phi-split-card-layout-client.js +5 -3
- package/components/layouts/clients/phi-three-column-layout-client.d.ts +20 -1
- package/components/layouts/clients/phi-three-column-layout-client.js +31 -15
- package/components/layouts/layout-definitions.d.ts +96 -0
- package/components/layouts/layout-definitions.js +40 -2
- package/components/layouts/plugins/split-card-layout-plugin.js +1 -1
- package/components/layouts/plugins/three-column-layout-plugin.js +1 -1
- package/components/layouts/split-card-geometry.d.ts +9 -4
- package/components/layouts/split-card-geometry.js +29 -13
- package/components/media/media-folder-options.d.ts +10 -0
- package/components/media/media-folder-options.js +14 -0
- package/components/shell/phi-antd-icon.d.ts +1 -0
- package/components/shell/phi-antd-icon.js +3 -0
- package/components/widgets/inspector-field-row.js +4 -1
- package/components/widgets/label-sets/admin-users.d.ts +3 -0
- package/components/widgets/label-sets/admin-users.js +8 -2
- package/components/widgets/label-sets/gallery.js +2 -2
- package/components/widgets/label-sets/inspector.js +4 -0
- package/components/widgets/label-sets/observability-logs.js +2 -2
- package/components/widgets/label-sets/profile.js +2 -1
- package/components/widgets/label-types/gallery.d.ts +2 -3
- package/components/widgets/label-types/gallery.js +1 -4
- package/components/widgets/label-types/inspector.d.ts +4 -0
- package/components/widgets/label-types/inspector.js +2 -0
- package/components/widgets/shared/markdown-image-vocabulary.js +1 -1
- package/constants/cms-layout-proportions.d.ts +6 -0
- package/constants/cms-layout-proportions.js +17 -0
- package/constants/runtime-module-ownership.js +1 -0
- package/helpers/page-reference-tree.js +8 -0
- package/helpers/table-action-links.d.ts +11 -0
- package/helpers/table-action-links.js +14 -0
- package/helpers/table-action-row-link.d.ts +8 -0
- package/helpers/table-action-row-link.js +14 -0
- package/package.json +2 -2
- package/plugins/factories/widget-renderers.d.ts +7 -1
- package/plugins/factories/widget-renderers.js +12 -2
- package/plugins/runtime-modules/asset/authoring-widgets.js +2 -2
- package/plugins/runtime-modules/asset/data-providers.js +1 -1
- package/plugins/runtime-modules/asset/services/options.js +7 -11
- package/plugins/runtime-modules/asset/widgets/area-upload/plugin.js +0 -2
- package/plugins/runtime-modules/asset/widgets/asset-focal-rect/plugin.js +0 -2
- package/plugins/runtime-modules/asset/widgets/image-inspector/plugin.js +0 -2
- package/plugins/runtime-modules/asset/widgets/media-picker/plugin.js +0 -2
- package/plugins/runtime-modules/asset/widgets.js +4 -4
- package/plugins/runtime-modules/auth/authoring-widgets.js +4 -8
- package/plugins/runtime-modules/auth/services/installations-table.js +3 -1
- package/plugins/runtime-modules/auth/widgets/auth-workflow/plugin.js +0 -6
- package/plugins/runtime-modules/auth/widgets/logout/plugin.js +0 -2
- package/plugins/runtime-modules/auth/widgets/security/plugin.js +0 -2
- package/plugins/runtime-modules/auth/widgets.js +5 -3
- package/plugins/runtime-modules/avatar/authoring-widgets.js +2 -2
- package/plugins/runtime-modules/avatar/widgets/account-avatar/plugin.js +0 -2
- package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/plugin.js +0 -2
- package/plugins/runtime-modules/avatar/widgets.js +2 -2
- package/plugins/runtime-modules/builder/authoring-widgets.js +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-choice-cascader.d.ts +28 -0
- package/plugins/runtime-modules/builder/clients/inspector-choice-cascader.js +98 -0
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +27 -3
- package/plugins/runtime-modules/builder/clients/inspector-record-field-options.d.ts +17 -0
- package/plugins/runtime-modules/builder/clients/inspector-record-field-options.js +21 -0
- package/plugins/runtime-modules/builder/clients/inspector-translate-switch.d.ts +24 -0
- package/plugins/runtime-modules/builder/clients/inspector-translate-switch.js +29 -0
- package/plugins/runtime-modules/builder/clients/layout-inspector.d.ts +1 -1
- package/plugins/runtime-modules/builder/clients/layout-inspector.js +4 -2
- package/plugins/runtime-modules/builder/clients/widget-inspector.d.ts +1 -1
- package/plugins/runtime-modules/builder/clients/widget-inspector.js +6 -6
- package/plugins/runtime-modules/builder/plugin-meta-labels.js +17 -0
- package/plugins/runtime-modules/builder/render-root-node-scaffold.js +12 -2
- package/plugins/runtime-modules/builder/widgets/structure-region/plugin.js +0 -2
- package/plugins/runtime-modules/builder/widgets.js +3 -3
- package/plugins/runtime-modules/contracts.js +8 -4
- package/plugins/runtime-modules/core/authoring-widgets.js +2 -2
- package/plugins/runtime-modules/core/data-providers.d.ts +7 -3
- package/plugins/runtime-modules/core/data-providers.js +11 -1
- package/plugins/runtime-modules/core/definition.d.ts +7 -3
- package/plugins/runtime-modules/core/widgets/cascader/authoring.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/draft-status/client.d.ts +2 -1
- package/plugins/runtime-modules/core/widgets/draft-status/client.js +4 -3
- package/plugins/runtime-modules/core/widgets/gallery/authoring.js +6 -8
- package/plugins/runtime-modules/core/widgets/gallery/client.js +4 -0
- package/plugins/runtime-modules/core/widgets/gallery/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +5 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.js +8 -4
- package/plugins/runtime-modules/core/widgets/image/config.js +1 -1
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +11 -0
- package/plugins/runtime-modules/core/widgets/markdown/config.js +24 -22
- package/plugins/runtime-modules/core/widgets/simple-text/client.d.ts +9 -5
- package/plugins/runtime-modules/core/widgets/simple-text/client.js +5 -7
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +63 -4
- package/plugins/runtime-modules/core/widgets/simple-text/config.js +45 -11
- package/plugins/runtime-modules/core/widgets/simple-text/editor.js +2 -2
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.d.ts +13 -0
- package/plugins/runtime-modules/core/widgets/simple-text/plugin.js +23 -4
- package/plugins/runtime-modules/core/widgets/simple-text/server.d.ts +4 -2
- package/plugins/runtime-modules/core/widgets/simple-text/server.js +7 -6
- package/plugins/runtime-modules/core/widgets/table/client.js +4 -4
- package/plugins/runtime-modules/core/widgets/table/config.js +11 -3
- package/plugins/runtime-modules/core/widgets/table/plugin.js +21 -1
- package/plugins/runtime-modules/core/widgets/thread-conversation/plugin.js +0 -2
- package/plugins/runtime-modules/core/widgets/tree/config.js +2 -1
- package/plugins/runtime-modules/core/widgets/tree/plugin.js +16 -1
- package/plugins/runtime-modules/core/widgets.js +1 -1
- package/plugins/runtime-modules/editor/services/releases-table.js +4 -1
- package/plugins/runtime-modules/observability/data-providers.js +1 -1
- package/plugins/runtime-modules/observability/services/table.js +3 -1
- package/plugins/runtime-modules/theme/authoring-widgets.js +5 -5
- package/plugins/runtime-modules/theme/widgets/brand-controls/plugin.js +0 -5
- package/plugins/runtime-modules/theme/widgets.js +4 -4
- package/plugins/runtime-modules/user-management/addon-roles.d.ts +28 -7
- package/plugins/runtime-modules/user-management/addon-roles.js +42 -17
- package/plugins/runtime-modules/user-management/client-data-providers.js +6 -0
- package/plugins/runtime-modules/user-management/data-providers.js +11 -2
- package/plugins/runtime-modules/user-management/forms.js +40 -1
- package/plugins/runtime-modules/user-management/ids.d.ts +1 -0
- package/plugins/runtime-modules/user-management/ids.js +1 -0
- package/plugins/runtime-modules/user-management/services/options.d.ts +14 -3
- package/plugins/runtime-modules/user-management/services/options.js +52 -16
- package/plugins/runtime-modules/user-management/services/table.js +11 -25
- package/plugins/runtime-modules/user-management/services/users-query.d.ts +9 -0
- package/plugins/runtime-modules/user-management/services/users-query.js +29 -0
- package/plugins/runtime-modules/video/widgets/embed/plugin.js +0 -2
- package/plugins/runtime-modules/video/widgets.js +1 -1
- package/styles/layout.css +4 -4
- package/types/cms-config.d.ts +12 -4
- package/types/cms-config.js +3 -0
- package/types/cms-plugins.d.ts +26 -4
- package/types/core-widget-placements.d.ts +4 -4
- package/types/table-widget.d.ts +17 -1
- package/types/tree.d.ts +2 -0
- package/plugins/runtime-modules/asset/widgets/asset-focal-rect/authoring.d.ts +0 -2
- package/plugins/runtime-modules/asset/widgets/asset-focal-rect/authoring.js +0 -6
- package/plugins/runtime-modules/asset/widgets/image-inspector/authoring.d.ts +0 -2
- package/plugins/runtime-modules/asset/widgets/image-inspector/authoring.js +0 -6
- package/plugins/runtime-modules/auth/widgets/auth-methods/authoring.d.ts +0 -7
- package/plugins/runtime-modules/auth/widgets/auth-methods/authoring.js +0 -12
- package/plugins/runtime-modules/auth/widgets/auth-workflow/authoring.d.ts +0 -7
- package/plugins/runtime-modules/auth/widgets/auth-workflow/authoring.js +0 -12
- package/plugins/runtime-modules/auth/widgets/logout/authoring.d.ts +0 -3
- package/plugins/runtime-modules/auth/widgets/logout/authoring.js +0 -8
- package/plugins/runtime-modules/auth/widgets/security/authoring.d.ts +0 -3
- package/plugins/runtime-modules/auth/widgets/security/authoring.js +0 -8
- package/plugins/runtime-modules/avatar/widgets/account-avatar/authoring.d.ts +0 -2
- package/plugins/runtime-modules/avatar/widgets/account-avatar/authoring.js +0 -6
- package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/authoring.d.ts +0 -2
- package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/authoring.js +0 -6
- package/plugins/runtime-modules/builder/widgets/structure-region/internal-builder.d.ts +0 -22
- package/plugins/runtime-modules/builder/widgets/structure-region/internal-builder.js +0 -8
- package/plugins/runtime-modules/core/widgets/form-preview/authoring.d.ts +0 -10
- package/plugins/runtime-modules/core/widgets/form-preview/authoring.js +0 -15
- package/plugins/runtime-modules/core/widgets/thread-conversation/authoring.d.ts +0 -3
- package/plugins/runtime-modules/core/widgets/thread-conversation/authoring.js +0 -9
- package/plugins/runtime-modules/theme/widgets/brand-controls/authoring.d.ts +0 -76
- package/plugins/runtime-modules/theme/widgets/brand-controls/authoring.js +0 -30
|
@@ -4,8 +4,28 @@ import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
|
|
|
4
4
|
import { readPhiRuntimeTreeRenderMode } from "../../../render-mode";
|
|
5
5
|
import { PHI_TABLE_WIDGET_DEFINITION } from "./config";
|
|
6
6
|
import { PhiTableWidget } from "./server";
|
|
7
|
+
import { resolvePhiTableActionLinks } from "../../../../../helpers/table-action-links";
|
|
7
8
|
import { getPhiTableWidgetLabels } from "../../../../../components/widgets/label-sets/table";
|
|
8
|
-
|
|
9
|
+
/** The config with every action's link target resolved to the address it leads to now. */
|
|
10
|
+
function resolvePhiTableConfigLinks(config, links) {
|
|
11
|
+
const actions = config.features.actions;
|
|
12
|
+
if (!actions)
|
|
13
|
+
return config;
|
|
14
|
+
return {
|
|
15
|
+
...config,
|
|
16
|
+
features: {
|
|
17
|
+
...config.features,
|
|
18
|
+
actions: {
|
|
19
|
+
...actions,
|
|
20
|
+
toolbar: resolvePhiTableActionLinks(actions.toolbar, links),
|
|
21
|
+
row: resolvePhiTableActionLinks(actions.row, links),
|
|
22
|
+
bulk: resolvePhiTableActionLinks(actions.bulk, links),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async function PhiTableWidgetPluginServer({ widget, config: stored, runtime, links, }) {
|
|
28
|
+
const config = resolvePhiTableConfigLinks(stored, links);
|
|
9
29
|
const rt = phiRuntime(runtime);
|
|
10
30
|
const labels = await getPhiTableWidgetLabels({
|
|
11
31
|
apiBaseUrl: rt.apiBaseUrl,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { renderPhiWidgetPreviewPlaceholder } from "../../../../../plugins/factories/widget-renderers";
|
|
3
2
|
import { PHI_THREAD_CONVERSATION_WIDGET_DEFINITION } from "./config";
|
|
4
3
|
import { PhiThreadConversationWidget } from "./server";
|
|
5
4
|
export const PHI_THREAD_CONVERSATION_WIDGET_PLUGIN = {
|
|
6
5
|
...PHI_THREAD_CONVERSATION_WIDGET_DEFINITION,
|
|
7
6
|
render: ({ runtime, config }) => _jsx(PhiThreadConversationWidget, { runtime: runtime, config: config }),
|
|
8
|
-
renderPreview: ({ widget }) => renderPhiWidgetPreviewPlaceholder(widget),
|
|
9
7
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolvePhiCmsWidgetPluginKey } from "../../../../../constants/cms-widget-types";
|
|
2
|
+
import { readPhiLinkTarget } from "../../../../../types/references";
|
|
2
3
|
import { isPhiRuntimeDataProviderKey } from "../../../../../types/runtime-data-provider";
|
|
3
4
|
import { PHI_SIGNAL_VALUE_SCHEMAS, readPhiSignalRouteSet } from "../../../../../types/signals";
|
|
4
5
|
import { readPhiLengthValue } from "../../../../../types/length";
|
|
@@ -25,7 +26,7 @@ function readActions(value) {
|
|
|
25
26
|
icon: readString(entry.icon),
|
|
26
27
|
display: entry.display === "icon" || entry.display === "icon-label" ? entry.display : "label",
|
|
27
28
|
mode: entry.mode === "primary" || entry.mode === "danger" ? entry.mode : "normal",
|
|
28
|
-
|
|
29
|
+
linkTarget: readPhiLinkTarget(entry.linkTarget) ?? undefined,
|
|
29
30
|
hrefPath: readString(entry.hrefPath),
|
|
30
31
|
newTab: readBoolean(entry.newTab),
|
|
31
32
|
confirm: confirmTitle ? {
|
|
@@ -4,8 +4,23 @@ import { phiRuntime } from "../../../../../server-helpers/phi-runtime";
|
|
|
4
4
|
import { readPhiRuntimeTreeRenderMode } from "../../../render-mode";
|
|
5
5
|
import { PHI_TREE_WIDGET_DEFINITION } from "./config";
|
|
6
6
|
import { PhiTreeWidget } from "./server";
|
|
7
|
+
import { resolvePhiTableActionLinks } from "../../../../../helpers/table-action-links";
|
|
7
8
|
import { getPhiTreeWidgetLabels } from "../../../../../components/widgets/label-sets/tree";
|
|
8
|
-
async function PhiTreeWidgetPluginServer({ widget, config, runtime }) {
|
|
9
|
+
async function PhiTreeWidgetPluginServer({ widget, config: stored, runtime, links }) {
|
|
10
|
+
// Where each action's target leads, resolved here: a Page reference means nothing in a browser.
|
|
11
|
+
const actions = stored.features.actions;
|
|
12
|
+
const config = !actions ? stored : {
|
|
13
|
+
...stored,
|
|
14
|
+
features: {
|
|
15
|
+
...stored.features,
|
|
16
|
+
actions: {
|
|
17
|
+
...actions,
|
|
18
|
+
toolbar: resolvePhiTableActionLinks(actions.toolbar, links) ?? [],
|
|
19
|
+
node: resolvePhiTableActionLinks(actions.node, links) ?? [],
|
|
20
|
+
selection: resolvePhiTableActionLinks(actions.selection, links) ?? [],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
9
24
|
const rt = phiRuntime(runtime);
|
|
10
25
|
const labels = await getPhiTreeWidgetLabels({ apiBaseUrl: rt.apiBaseUrl, internalToken: rt.internalToken, locale: runtime.locale.current });
|
|
11
26
|
return _jsx(PhiTreeWidget, { config: config, labels: labels, renderMode: readPhiRuntimeTreeRenderMode(widget.config) });
|
|
@@ -395,7 +395,7 @@ export const PHI_RUNTIME_MODULE_WIDGETS = [
|
|
|
395
395
|
definePhiFirstPartyWidget({
|
|
396
396
|
definition: PHI_THREAD_CONVERSATION_WIDGET_DEFINITION,
|
|
397
397
|
ownerModuleId: PHI_CORE_RUNTIME_MODULE_ID,
|
|
398
|
-
renderPolicies: { runtime: "custom", preview: "
|
|
398
|
+
renderPolicies: { runtime: "custom", preview: "visualPlaceholder", authoring: "custom" },
|
|
399
399
|
loadRuntime: () => import("./widgets/thread-conversation/plugin").then((module) => module.PHI_THREAD_CONVERSATION_WIDGET_PLUGIN),
|
|
400
400
|
loadPreview: () => import("./widgets/thread-conversation/plugin").then((module) => module.PHI_THREAD_CONVERSATION_WIDGET_PLUGIN),
|
|
401
401
|
}),
|
|
@@ -7,6 +7,9 @@ import { PhiTableProviderClient, } from "../../../../components/widgets/client/s
|
|
|
7
7
|
import { readPhiTableProviderResponse, } from "../../../../components/widgets/client/shared/phi-table-provider-response";
|
|
8
8
|
import { PHI_EDITOR_RUNTIME_DATA_PROVIDER_DESCRIPTORS } from "../data-providers";
|
|
9
9
|
import { PHI_EDITOR_RELEASES_DATA_PROVIDER_KEY, PHI_EDITOR_RELEASES_RESOURCE_KEY } from "../ids";
|
|
10
|
+
// Its own descriptor by key, not by position: a Provider added to the list must not take its place.
|
|
11
|
+
const PHI_EDITOR_RELEASES_RESOURCES = PHI_EDITOR_RUNTIME_DATA_PROVIDER_DESCRIPTORS
|
|
12
|
+
.find((descriptor) => descriptor.key === PHI_EDITOR_RELEASES_DATA_PROVIDER_KEY)?.resources ?? [];
|
|
10
13
|
const RELEASES_API_PATH = "/api/site/editor/releases";
|
|
11
14
|
const RESPONSE_OPTIONS = { subject: "Releases" };
|
|
12
15
|
function readText(value) {
|
|
@@ -174,7 +177,7 @@ export function PhiEditorReleasesTableProviderClient({ children }) {
|
|
|
174
177
|
}, []);
|
|
175
178
|
const registration = useMemo(() => ({
|
|
176
179
|
key: PHI_EDITOR_RELEASES_DATA_PROVIDER_KEY,
|
|
177
|
-
resources:
|
|
180
|
+
resources: PHI_EDITOR_RELEASES_RESOURCES,
|
|
178
181
|
query,
|
|
179
182
|
mutate,
|
|
180
183
|
}), [mutate, query]);
|
|
@@ -17,7 +17,7 @@ export const PHI_OBSERVABILITY_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
|
|
|
17
17
|
{ key: "id", title: "ID", type: "string", required: true },
|
|
18
18
|
{ key: "ts", title: "Timestamp", type: "datetime" },
|
|
19
19
|
{ key: "level", title: "Level", type: "string" },
|
|
20
|
-
{ key: "service", title: "
|
|
20
|
+
{ key: "service", title: "Source", type: "string" },
|
|
21
21
|
{ key: "event", title: "Event", type: "string" },
|
|
22
22
|
{ key: "area", title: "Area", type: "string" },
|
|
23
23
|
{ key: "userId", title: "User ID", type: "string" },
|
|
@@ -63,7 +63,9 @@ async function readRecord({ resourceKey, rowIdentity, signal, }) {
|
|
|
63
63
|
}
|
|
64
64
|
return payload.record;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
// Its own descriptor by key, not by position: a Provider added to the list must not take its place.
|
|
67
|
+
const resources = PHI_OBSERVABILITY_RUNTIME_DATA_PROVIDER_DESCRIPTORS
|
|
68
|
+
.find((descriptor) => descriptor.key === PHI_OBSERVABILITY_RUNTIME_DATA_PROVIDER_KEYS.table)?.resources ?? [];
|
|
67
69
|
export const PhiObservabilityTableProviderClient = createPhiTableProviderClient({
|
|
68
70
|
key: PHI_OBSERVABILITY_RUNTIME_DATA_PROVIDER_KEYS.table,
|
|
69
71
|
resources,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_DEFINITION, PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_DEFINITION, PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_DEFINITION, PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_DEFINITION, PHI_BUILDER_BRAND_THEME_PREVIEW_WIDGET_DEFINITION, } from "./widgets/brand-controls/config";
|
|
3
3
|
import { createPhiAuthoringWidgetModule, definePhiAuthoringWidgetModuleLoader, } from "../client-authoring-widget-module";
|
|
4
4
|
export default createPhiAuthoringWidgetModule([
|
|
5
|
-
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_DEFINITION, () =>
|
|
6
|
-
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_DEFINITION, () =>
|
|
7
|
-
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_DEFINITION, () =>
|
|
8
|
-
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_DEFINITION, () =>
|
|
9
|
-
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_THEME_PREVIEW_WIDGET_DEFINITION, () =>
|
|
5
|
+
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_DEFINITION, () => Promise.resolve(PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_DEFINITION)),
|
|
6
|
+
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_DEFINITION, () => Promise.resolve(PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_DEFINITION)),
|
|
7
|
+
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_DEFINITION, () => Promise.resolve(PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_DEFINITION)),
|
|
8
|
+
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_DEFINITION, () => Promise.resolve(PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_DEFINITION)),
|
|
9
|
+
definePhiAuthoringWidgetModuleLoader(PHI_BUILDER_BRAND_THEME_PREVIEW_WIDGET_DEFINITION, () => Promise.resolve(PHI_BUILDER_BRAND_THEME_PREVIEW_WIDGET_DEFINITION)),
|
|
10
10
|
]);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { buildPhiWidgetLabelTranslatorOptions } from "../../../../../components/widgets/label-sets/runtime-options";
|
|
3
|
-
import { PhiWidgetPreviewFallback } from "../../../../../components/widgets/built-in/widget-preview";
|
|
4
3
|
import { PhiBuilderBrandBackgroundControlsWidgetClient, PhiBuilderBrandIdentityControlsWidgetClient, PhiBuilderBrandStyleControlsWidgetClient, PhiBuilderBrandThemeControlsWidgetClient, PhiBuilderBrandThemePreviewWidgetClient, } from "./client";
|
|
5
4
|
import { PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_DEFINITION, PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_DEFINITION, PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_DEFINITION, PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_DEFINITION, PHI_BUILDER_BRAND_THEME_PREVIEW_WIDGET_DEFINITION, } from "./config";
|
|
6
5
|
import { getPhiColorPickerLabels } from "../../../../../components/widgets/label-sets/color-picker";
|
|
@@ -9,7 +8,6 @@ import { PhiMediaPickerLabelsProvider } from "../../../../../components/media/ph
|
|
|
9
8
|
export const PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_PLUGIN = {
|
|
10
9
|
...PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_DEFINITION,
|
|
11
10
|
render: async ({ runtime, config }) => (_jsx(PhiBuilderBrandThemeControlsWidgetClient, { runtime: runtime, config: config, colorPickerLabels: await getPhiColorPickerLabels(buildPhiWidgetLabelTranslatorOptions(runtime)) })),
|
|
12
|
-
renderPreview: ({ widget }) => (_jsx(PhiWidgetPreviewFallback, { widget: widget, pluginTitle: "Builder Brand Theme Controls", summary: "Brand theme controls are rendered live in the builder." })),
|
|
13
11
|
};
|
|
14
12
|
export const PHI_BUILDER_BRAND_THEME_PREVIEW_WIDGET_PLUGIN = {
|
|
15
13
|
...PHI_BUILDER_BRAND_THEME_PREVIEW_WIDGET_DEFINITION,
|
|
@@ -19,17 +17,14 @@ export const PHI_BUILDER_BRAND_THEME_PREVIEW_WIDGET_PLUGIN = {
|
|
|
19
17
|
export const PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_PLUGIN = {
|
|
20
18
|
...PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_DEFINITION,
|
|
21
19
|
render: ({ runtime, config }) => _jsx(PhiBuilderBrandStyleControlsWidgetClient, { runtime: runtime, config: config }),
|
|
22
|
-
renderPreview: ({ widget }) => (_jsx(PhiWidgetPreviewFallback, { widget: widget, pluginTitle: "Builder Brand Style Controls", summary: "Brand style controls are rendered live in the builder." })),
|
|
23
20
|
};
|
|
24
21
|
export const PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_PLUGIN = {
|
|
25
22
|
...PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_DEFINITION,
|
|
26
23
|
// The picker the Background Control opens says its words in the reader's language.
|
|
27
24
|
render: async ({ runtime, config }) => (_jsx(PhiMediaPickerLabelsProvider, { labels: await getPhiMediaWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime)), children: _jsx(PhiBuilderBrandBackgroundControlsWidgetClient, { runtime: runtime, config: config }) })),
|
|
28
|
-
renderPreview: ({ widget }) => (_jsx(PhiWidgetPreviewFallback, { widget: widget, pluginTitle: "Builder Brand Background Controls", summary: "The Theme Root Background is authored live in the builder." })),
|
|
29
25
|
};
|
|
30
26
|
export const PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_PLUGIN = {
|
|
31
27
|
...PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_DEFINITION,
|
|
32
28
|
// The picker the Logo field opens says its words in the reader's language.
|
|
33
29
|
render: async ({ runtime, config }) => (_jsx(PhiMediaPickerLabelsProvider, { labels: await getPhiMediaWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime)), children: _jsx(PhiBuilderBrandIdentityControlsWidgetClient, { runtime: runtime, config: config }) })),
|
|
34
|
-
renderPreview: ({ widget }) => (_jsx(PhiWidgetPreviewFallback, { widget: widget, pluginTitle: "Builder Brand Identity Controls", summary: "The Logo and the Wordmark are authored live in the builder." })),
|
|
35
30
|
};
|
|
@@ -5,28 +5,28 @@ export const PHI_RUNTIME_MODULE_WIDGETS = [
|
|
|
5
5
|
definePhiFirstPartyWidget({
|
|
6
6
|
definition: PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_DEFINITION,
|
|
7
7
|
ownerModuleId: PHI_THEME_RUNTIME_MODULE_ID,
|
|
8
|
-
renderPolicies: { "runtime": "custom", "preview": "
|
|
8
|
+
renderPolicies: { "runtime": "custom", "preview": "visualPlaceholder", "authoring": "custom" },
|
|
9
9
|
loadRuntime: () => import("./widgets/brand-controls/plugin").then((module) => module.PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_PLUGIN),
|
|
10
10
|
loadPreview: () => import("./widgets/brand-controls/plugin").then((module) => module.PHI_BUILDER_BRAND_STYLE_CONTROLS_WIDGET_PLUGIN),
|
|
11
11
|
}),
|
|
12
12
|
definePhiFirstPartyWidget({
|
|
13
13
|
definition: PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_DEFINITION,
|
|
14
14
|
ownerModuleId: PHI_THEME_RUNTIME_MODULE_ID,
|
|
15
|
-
renderPolicies: { "runtime": "custom", "preview": "
|
|
15
|
+
renderPolicies: { "runtime": "custom", "preview": "visualPlaceholder", "authoring": "custom" },
|
|
16
16
|
loadRuntime: () => import("./widgets/brand-controls/plugin").then((module) => module.PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_PLUGIN),
|
|
17
17
|
loadPreview: () => import("./widgets/brand-controls/plugin").then((module) => module.PHI_BUILDER_BRAND_THEME_CONTROLS_WIDGET_PLUGIN),
|
|
18
18
|
}),
|
|
19
19
|
definePhiFirstPartyWidget({
|
|
20
20
|
definition: PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_DEFINITION,
|
|
21
21
|
ownerModuleId: PHI_THEME_RUNTIME_MODULE_ID,
|
|
22
|
-
renderPolicies: { "runtime": "custom", "preview": "
|
|
22
|
+
renderPolicies: { "runtime": "custom", "preview": "visualPlaceholder", "authoring": "custom" },
|
|
23
23
|
loadRuntime: () => import("./widgets/brand-controls/plugin").then((module) => module.PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_PLUGIN),
|
|
24
24
|
loadPreview: () => import("./widgets/brand-controls/plugin").then((module) => module.PHI_BUILDER_BRAND_BACKGROUND_CONTROLS_WIDGET_PLUGIN),
|
|
25
25
|
}),
|
|
26
26
|
definePhiFirstPartyWidget({
|
|
27
27
|
definition: PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_DEFINITION,
|
|
28
28
|
ownerModuleId: PHI_THEME_RUNTIME_MODULE_ID,
|
|
29
|
-
renderPolicies: { "runtime": "custom", "preview": "
|
|
29
|
+
renderPolicies: { "runtime": "custom", "preview": "visualPlaceholder", "authoring": "custom" },
|
|
30
30
|
loadRuntime: () => import("./widgets/brand-controls/plugin").then((module) => module.PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_PLUGIN),
|
|
31
31
|
loadPreview: () => import("./widgets/brand-controls/plugin").then((module) => module.PHI_BUILDER_BRAND_IDENTITY_CONTROLS_WIDGET_PLUGIN),
|
|
32
32
|
}),
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export type PhiAddonRole = {
|
|
2
2
|
name: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
/** Whether the acting person may hand this role out, as the Core decided it for this request. */
|
|
5
|
+
grantable: boolean;
|
|
3
6
|
};
|
|
4
7
|
export type PhiAddonRoleCatalogEntry = {
|
|
5
8
|
addonId: string;
|
|
@@ -23,13 +26,31 @@ export declare const PHI_USER_MANAGEMENT_ADDON_ALL_ROLES_TAG = "all";
|
|
|
23
26
|
* are not listed (they apply when the person is no longer one; the dialog shows them).
|
|
24
27
|
*/
|
|
25
28
|
export declare function buildPhiAddonRoleTags(row: Record<string, unknown>): string[];
|
|
26
|
-
/**
|
|
27
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The users Table filter's options: one per Add-on, never a single role -- choosing one finds whoever holds
|
|
31
|
+
* any of its roles (the Core's `addonId` filter). The label is the Add-on's title; the id is the description,
|
|
32
|
+
* left out while the title is the id itself, so the list does not say everything twice.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildPhiAddonFilterOptions(catalog: readonly PhiAddonRoleCatalogEntry[]): {
|
|
35
|
+
description?: string | undefined;
|
|
36
|
+
value: string;
|
|
37
|
+
label: string;
|
|
38
|
+
}[];
|
|
39
|
+
/**
|
|
40
|
+
* The edit form's Add-on role choices, under one heading per Add-on: every role the acting person may grant,
|
|
41
|
+
* and the ones the person edited holds that the actor may not grant, disabled.
|
|
42
|
+
*
|
|
43
|
+
* The save takes the whole list of roles the person is to hold afterwards and checks every difference to
|
|
44
|
+
* what is stored against the actor. A held role missing from the choices would be a value with no option,
|
|
45
|
+
* which the control lets anyone remove -- and the save would then ask to take back a role the actor has no
|
|
46
|
+
* standing over. As a disabled option it stays in the value as a tag nobody can remove, and the save sends it
|
|
47
|
+
* unchanged. `held` is null where the Core did not say what the person holds; every role the actor may not
|
|
48
|
+
* grant is listed disabled then, so whichever of them the person holds is kept the same way.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildPhiAddonRoleChoiceOptions(catalog: readonly PhiAddonRoleCatalogEntry[], held: readonly PhiAddonRoleAssignment[] | null): {
|
|
51
|
+
disabled?: boolean | undefined;
|
|
52
|
+
group: string;
|
|
53
|
+
description?: string | undefined;
|
|
28
54
|
value: string;
|
|
29
55
|
label: string;
|
|
30
56
|
}[];
|
|
31
|
-
/** The Core's `addonId` and optional `addonRole` filters from the one value the Table filter holds. */
|
|
32
|
-
export declare function parsePhiAddonRoleFilter(value: string): {
|
|
33
|
-
addonId: string;
|
|
34
|
-
addonRole: string | null;
|
|
35
|
-
} | null;
|
|
@@ -18,7 +18,8 @@ export function readPhiAddonRoleCatalog(payload) {
|
|
|
18
18
|
const name = readString(role.name);
|
|
19
19
|
if (!name || !ROLE_NAME.test(name))
|
|
20
20
|
return [];
|
|
21
|
-
|
|
21
|
+
const description = readString(role.description);
|
|
22
|
+
return [{ name, ...(description ? { description } : {}), grantable: role.grantable === true }];
|
|
22
23
|
});
|
|
23
24
|
return roles.length > 0 ? [{ addonId, title: readString(addon.title) ?? addonId, roles }] : [];
|
|
24
25
|
});
|
|
@@ -56,21 +57,45 @@ export function buildPhiAddonRoleTags(row) {
|
|
|
56
57
|
}
|
|
57
58
|
return [...byAddon].map(([addonId, roles]) => `${addonId}: ${roles.join(", ")}`);
|
|
58
59
|
}
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The users Table filter's options: one per Add-on, never a single role -- choosing one finds whoever holds
|
|
62
|
+
* any of its roles (the Core's `addonId` filter). The label is the Add-on's title; the id is the description,
|
|
63
|
+
* left out while the title is the id itself, so the list does not say everything twice.
|
|
64
|
+
*/
|
|
65
|
+
export function buildPhiAddonFilterOptions(catalog) {
|
|
66
|
+
return catalog.map((entry) => ({
|
|
67
|
+
value: entry.addonId,
|
|
68
|
+
label: entry.title,
|
|
69
|
+
...(entry.title === entry.addonId ? {} : { description: entry.addonId }),
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
/** One role as the user save names it: `"<addonId>:<role>"`, which the Core splits at the last colon. */
|
|
73
|
+
function formatPhiAddonRoleValue(addonId, role) {
|
|
74
|
+
return `${addonId}:${role}`;
|
|
65
75
|
}
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
/**
|
|
77
|
+
* The edit form's Add-on role choices, under one heading per Add-on: every role the acting person may grant,
|
|
78
|
+
* and the ones the person edited holds that the actor may not grant, disabled.
|
|
79
|
+
*
|
|
80
|
+
* The save takes the whole list of roles the person is to hold afterwards and checks every difference to
|
|
81
|
+
* what is stored against the actor. A held role missing from the choices would be a value with no option,
|
|
82
|
+
* which the control lets anyone remove -- and the save would then ask to take back a role the actor has no
|
|
83
|
+
* standing over. As a disabled option it stays in the value as a tag nobody can remove, and the save sends it
|
|
84
|
+
* unchanged. `held` is null where the Core did not say what the person holds; every role the actor may not
|
|
85
|
+
* grant is listed disabled then, so whichever of them the person holds is kept the same way.
|
|
86
|
+
*/
|
|
87
|
+
export function buildPhiAddonRoleChoiceOptions(catalog, held) {
|
|
88
|
+
const heldValues = held ? new Set(held.map(({ addonId, role }) => formatPhiAddonRoleValue(addonId, role))) : null;
|
|
89
|
+
return catalog.flatMap((entry) => entry.roles.flatMap((role) => {
|
|
90
|
+
const value = formatPhiAddonRoleValue(entry.addonId, role.name);
|
|
91
|
+
if (!role.grantable && heldValues && !heldValues.has(value))
|
|
92
|
+
return [];
|
|
93
|
+
return [{
|
|
94
|
+
value,
|
|
95
|
+
label: role.name,
|
|
96
|
+
...(role.description ? { description: role.description } : {}),
|
|
97
|
+
group: entry.title,
|
|
98
|
+
...(role.grantable ? {} : { disabled: true }),
|
|
99
|
+
}];
|
|
100
|
+
}));
|
|
76
101
|
}
|
|
@@ -8,6 +8,12 @@ export const PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS = [
|
|
|
8
8
|
loadLive: async () => (await import("../../../plugins/runtime-modules/user-management/services/options"))
|
|
9
9
|
.PhiUserManagementAddonRoleOptionsProviderClient,
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
key: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.addonRoleChoiceOptions,
|
|
13
|
+
ownerModuleId: PHI_USER_MANAGEMENT_RUNTIME_MODULE_ID,
|
|
14
|
+
loadLive: async () => (await import("../../../plugins/runtime-modules/user-management/services/options"))
|
|
15
|
+
.PhiUserManagementAddonRoleChoiceOptionsProviderClient,
|
|
16
|
+
},
|
|
11
17
|
{
|
|
12
18
|
key: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.table,
|
|
13
19
|
ownerModuleId: PHI_USER_MANAGEMENT_RUNTIME_MODULE_ID,
|
|
@@ -8,8 +8,17 @@ export const PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
|
|
|
8
8
|
kind: "options",
|
|
9
9
|
executionMode: "live",
|
|
10
10
|
authoringMode: "none",
|
|
11
|
-
title: "Add-
|
|
12
|
-
description: "The Add-ons enabled for the Site
|
|
11
|
+
title: "Add-ons with roles",
|
|
12
|
+
description: "The Add-ons enabled for the Site that declare roles, for filtering users by them.",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
key: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.addonRoleChoiceOptions,
|
|
16
|
+
ownerModuleId: PHI_USER_MANAGEMENT_RUNTIME_MODULE_ID,
|
|
17
|
+
kind: "options",
|
|
18
|
+
executionMode: "live",
|
|
19
|
+
authoringMode: "none",
|
|
20
|
+
title: "Add-on roles to grant",
|
|
21
|
+
description: "The Add-on roles the acting user may grant, and the ones the edited user holds, for assigning them.",
|
|
13
22
|
},
|
|
14
23
|
{
|
|
15
24
|
key: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.table,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createPhiFormLabelSetLoader } from "../../../components/forms/shared-form-loaders";
|
|
2
2
|
import { PHI_BASE_ROLE_OPTIONS } from "../../../constants/phi-base-role-metadata";
|
|
3
|
-
import { PHI_USER_MANAGEMENT_RUNTIME_MODULE_ID } from "../../../plugins/runtime-modules/user-management/ids";
|
|
3
|
+
import { PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS, PHI_USER_MANAGEMENT_RUNTIME_MODULE_ID, } from "../../../plugins/runtime-modules/user-management/ids";
|
|
4
4
|
import { createPhiFormId } from "../../../types/form-id";
|
|
5
5
|
import { PHI_SHARED_PACKAGE_NAME } from "../../../types/signals";
|
|
6
6
|
import { PHI_FORM_FIELD_PROVIDER_KEYS, PHI_FORM_VALIDATION_PROVIDER_KEYS, createPhiSharedFormProviderKey, } from "../../../components/forms/form-provider-contract";
|
|
@@ -31,6 +31,17 @@ const selfRoleCondition = {
|
|
|
31
31
|
operator: "truthy",
|
|
32
32
|
reason: "Your own roles cannot be changed here.",
|
|
33
33
|
};
|
|
34
|
+
/*
|
|
35
|
+
* A Site Admin holds every Add-on role whatever is stored, so choosing some says nothing. Read off the form's
|
|
36
|
+
* own Core roles rather than the record: whoever takes `admin` away in the same dialog may then choose.
|
|
37
|
+
*/
|
|
38
|
+
const siteAdminTargetCondition = {
|
|
39
|
+
source: "form",
|
|
40
|
+
valuePath: "roles",
|
|
41
|
+
operator: "contains",
|
|
42
|
+
value: "admin",
|
|
43
|
+
reason: "A Site Admin holds every Add-on role.",
|
|
44
|
+
};
|
|
34
45
|
const selfEnabledCondition = {
|
|
35
46
|
source: "controller",
|
|
36
47
|
controllerAddress,
|
|
@@ -111,7 +122,32 @@ function descriptor(formId, mode) {
|
|
|
111
122
|
? { match: "any", conditions: [readOnlyCondition, selfRoleCondition] }
|
|
112
123
|
: readOnlyCondition,
|
|
113
124
|
},
|
|
125
|
+
/*
|
|
126
|
+
* Edit only: the Core's create takes no Add-on roles. The value is the whole list the person is to hold
|
|
127
|
+
* afterwards; a held role the actor may not grant is a disabled option, so it stays in the value and is
|
|
128
|
+
* sent unchanged (`buildPhiAddonRoleChoiceOptions`).
|
|
129
|
+
*/
|
|
114
130
|
...(edit ? [
|
|
131
|
+
{
|
|
132
|
+
key: "addonRoles",
|
|
133
|
+
fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.multiSelect,
|
|
134
|
+
label: label("addonRoles", "Add-on roles"),
|
|
135
|
+
placeholder: label("addonRolesPlaceholder", "Choose Add-on roles"),
|
|
136
|
+
description: label("addonRolesHint", "A Site Admin holds every Add-on role. Your own Add-on roles cannot be changed here."),
|
|
137
|
+
optionsProvider: {
|
|
138
|
+
providerKey: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.addonRoleChoiceOptions,
|
|
139
|
+
/*
|
|
140
|
+
* Which roles the person holds decides which ones the actor may not grant are still listed. Required,
|
|
141
|
+
* so the catalog is asked once the record has filled the form, not once before it as well.
|
|
142
|
+
*/
|
|
143
|
+
dependencies: [{ param: "userId", source: "form", valuePath: "userId", required: true }],
|
|
144
|
+
},
|
|
145
|
+
initialValue: [],
|
|
146
|
+
disabledWhen: {
|
|
147
|
+
match: "any",
|
|
148
|
+
conditions: [readOnlyCondition, selfRoleCondition, siteAdminTargetCondition],
|
|
149
|
+
},
|
|
150
|
+
},
|
|
115
151
|
{
|
|
116
152
|
key: "enabled",
|
|
117
153
|
fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.switch,
|
|
@@ -145,6 +181,9 @@ const loadLabels = createPhiFormLabelSetLoader(() => import("../../../components
|
|
|
145
181
|
roles: labels.editor.roles,
|
|
146
182
|
rolesPlaceholder: labels.editor.rolesPlaceholder,
|
|
147
183
|
rolesHint: labels.editor.selfRoleHint,
|
|
184
|
+
addonRoles: labels.editor.addonRoles,
|
|
185
|
+
addonRolesPlaceholder: labels.editor.addonRolesPlaceholder,
|
|
186
|
+
addonRolesHint: labels.editor.addonRolesHint,
|
|
148
187
|
authOnlyHint: labels.editor.authOnlyHint,
|
|
149
188
|
createPasswordHint: labels.editor.createPasswordHint,
|
|
150
189
|
enabled: labels.columns.enabled,
|
|
@@ -11,4 +11,5 @@ export declare const PHI_USER_MANAGEMENT_RUNTIME_MODULE_IDENTITY: {
|
|
|
11
11
|
export declare const PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS: {
|
|
12
12
|
readonly table: `${string}/${string}`;
|
|
13
13
|
readonly addonRoleOptions: `${string}/${string}`;
|
|
14
|
+
readonly addonRoleChoiceOptions: `${string}/${string}`;
|
|
14
15
|
};
|
|
@@ -13,4 +13,5 @@ export const PHI_USER_MANAGEMENT_RUNTIME_MODULE_IDENTITY = {
|
|
|
13
13
|
export const PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS = {
|
|
14
14
|
table: createPhiSharedRuntimeDataProviderKey("tables", "user-management"),
|
|
15
15
|
addonRoleOptions: createPhiSharedRuntimeDataProviderKey("options", "user-management-addon-roles"),
|
|
16
|
+
addonRoleChoiceOptions: createPhiSharedRuntimeDataProviderKey("options", "user-management-addon-role-choices"),
|
|
16
17
|
};
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The Add-ons enabled for the Site
|
|
3
|
-
*
|
|
4
|
-
* list at all is settled by the users route itself.
|
|
2
|
+
* The Add-ons enabled for the Site that declare roles, as the users Table filter's options: one per Add-on,
|
|
3
|
+
* matching whoever holds any of its roles. The Core answers every signed-in caller
|
|
4
|
+
* (`GET /api/site/addon-roles`); who may see the users list at all is settled by the users route itself.
|
|
5
5
|
*/
|
|
6
6
|
export declare const PhiUserManagementAddonRoleOptionsProviderClient: import("react").ComponentType<{
|
|
7
7
|
children: import("react").ReactNode;
|
|
8
8
|
}>;
|
|
9
|
+
/**
|
|
10
|
+
* The Add-on roles the edit form offers one user (`buildPhiAddonRoleChoiceOptions`): the catalog with what
|
|
11
|
+
* the person holds, from `GET /api/site/addon-roles?userId=`, asked once per user the form is opened on.
|
|
12
|
+
*
|
|
13
|
+
* The Core refuses that question to an actor who may grant no role at all; such an actor is offered nothing,
|
|
14
|
+
* and the plain catalog lists every role disabled, which keeps whatever the person holds. So does an answer
|
|
15
|
+
* without a user to ask about.
|
|
16
|
+
*/
|
|
17
|
+
export declare const PhiUserManagementAddonRoleChoiceOptionsProviderClient: import("react").ComponentType<{
|
|
18
|
+
children: import("react").ReactNode;
|
|
19
|
+
}>;
|
|
@@ -1,25 +1,61 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createPhiControlOptionsProviderClient } from "../../../../components/controls/phi-options-provider";
|
|
3
|
-
import {
|
|
3
|
+
import { isPhiRecord } from "../../../../helpers/is-record";
|
|
4
|
+
import { buildPhiAddonFilterOptions, buildPhiAddonRoleChoiceOptions, readPhiAddonRoleAssignments, readPhiAddonRoleCatalog, } from "../addon-roles";
|
|
4
5
|
import { PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS } from "../ids";
|
|
6
|
+
const ADDON_ROLES_PATH = "/api/site/addon-roles";
|
|
7
|
+
async function fetchAddonRoles(query) {
|
|
8
|
+
return await fetch(`${ADDON_ROLES_PATH}${query}`, {
|
|
9
|
+
cache: "no-store",
|
|
10
|
+
credentials: "include",
|
|
11
|
+
headers: { accept: "application/json" },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async function readAddonRolesAnswer(response) {
|
|
15
|
+
const payload = await response.json().catch(() => null);
|
|
16
|
+
if (!response.ok)
|
|
17
|
+
throw new Error("Failed to load the Add-on roles.");
|
|
18
|
+
return payload;
|
|
19
|
+
}
|
|
5
20
|
/**
|
|
6
|
-
* The Add-ons enabled for the Site
|
|
7
|
-
*
|
|
8
|
-
* list at all is settled by the users route itself.
|
|
21
|
+
* The Add-ons enabled for the Site that declare roles, as the users Table filter's options: one per Add-on,
|
|
22
|
+
* matching whoever holds any of its roles. The Core answers every signed-in caller
|
|
23
|
+
* (`GET /api/site/addon-roles`); who may see the users list at all is settled by the users route itself.
|
|
9
24
|
*/
|
|
10
25
|
export const PhiUserManagementAddonRoleOptionsProviderClient = createPhiControlOptionsProviderClient({
|
|
11
26
|
key: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.addonRoleOptions,
|
|
12
|
-
load: async () =>
|
|
13
|
-
const response = await fetch("/api/site/addon-roles", {
|
|
14
|
-
cache: "no-store",
|
|
15
|
-
credentials: "include",
|
|
16
|
-
headers: { accept: "application/json" },
|
|
17
|
-
});
|
|
18
|
-
const payload = await response.json().catch(() => null);
|
|
19
|
-
if (!response.ok)
|
|
20
|
-
throw new Error("Failed to load the Add-on roles.");
|
|
21
|
-
return payload;
|
|
22
|
-
},
|
|
27
|
+
load: async () => await readAddonRolesAnswer(await fetchAddonRoles("")),
|
|
23
28
|
resolveLoadKey: () => "user-management-addon-roles",
|
|
24
|
-
resolve: (context) => ({ options:
|
|
29
|
+
resolve: (context) => ({ options: buildPhiAddonFilterOptions(readPhiAddonRoleCatalog(context.asyncData)) }),
|
|
30
|
+
});
|
|
31
|
+
function readUserId(value) {
|
|
32
|
+
const text = typeof value === "number" ? String(value) : typeof value === "string" ? value.trim() : "";
|
|
33
|
+
return /^[1-9][0-9]*$/u.test(text) ? text : null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The Add-on roles the edit form offers one user (`buildPhiAddonRoleChoiceOptions`): the catalog with what
|
|
37
|
+
* the person holds, from `GET /api/site/addon-roles?userId=`, asked once per user the form is opened on.
|
|
38
|
+
*
|
|
39
|
+
* The Core refuses that question to an actor who may grant no role at all; such an actor is offered nothing,
|
|
40
|
+
* and the plain catalog lists every role disabled, which keeps whatever the person holds. So does an answer
|
|
41
|
+
* without a user to ask about.
|
|
42
|
+
*/
|
|
43
|
+
export const PhiUserManagementAddonRoleChoiceOptionsProviderClient = createPhiControlOptionsProviderClient({
|
|
44
|
+
key: PHI_USER_MANAGEMENT_RUNTIME_DATA_PROVIDER_KEYS.addonRoleChoiceOptions,
|
|
45
|
+
load: async ({ dependencies }) => {
|
|
46
|
+
const userId = readUserId(dependencies.userId);
|
|
47
|
+
if (userId) {
|
|
48
|
+
const response = await fetchAddonRoles(`?${new URLSearchParams({ userId }).toString()}`);
|
|
49
|
+
if (response.status !== 403)
|
|
50
|
+
return await readAddonRolesAnswer(response);
|
|
51
|
+
}
|
|
52
|
+
return await readAddonRolesAnswer(await fetchAddonRoles(""));
|
|
53
|
+
},
|
|
54
|
+
resolveLoadKey: () => "user-management-addon-role-choices",
|
|
55
|
+
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
|
+
},
|
|
25
61
|
});
|