@phis/ui 0.7.5 → 0.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/controls/phi-form-control.d.ts +3 -1
- package/components/controls/phi-form-control.js +15 -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/extended-form-field-controls.d.ts +1 -1
- package/components/forms/extended-form-field-controls.js +23 -7
- 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-contract.d.ts +5 -0
- package/components/forms/form-provider-contract.js +9 -2
- package/components/forms/form-provider-registry.d.ts +14 -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/money-field-currency-key.d.ts +6 -0
- package/components/forms/money-field-currency-key.js +14 -0
- package/components/forms/money-field.d.ts +26 -3
- package/components/forms/money-field.js +54 -4
- 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/regions/presets/navigation-redirect.d.ts +4 -1
- package/components/regions/presets/navigation-redirect.js +6 -3
- 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 +54 -4
- 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/money-amount.d.ts +7 -0
- package/helpers/money-amount.js +15 -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/app/presets.js +3 -6
- package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +3 -6
- package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +4 -7
- 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/builder/controller/client.d.ts +5 -5
- package/plugins/runtime-modules/builder/controller/client.js +2 -1
- package/plugins/runtime-modules/builder/controller/definition.d.ts +4 -4
- package/plugins/runtime-modules/builder/controller/definition.js +7 -0
- package/plugins/runtime-modules/builder/controller/draft-command-controller.d.ts +3 -1
- package/plugins/runtime-modules/builder/controller/draft-command-controller.js +2 -1
- package/plugins/runtime-modules/builder/controller/draft-status-controller.js +44 -17
- package/plugins/runtime-modules/builder/controller/server-definition.d.ts +4 -4
- package/plugins/runtime-modules/builder/controller/workspace-controller.d.ts +3 -1
- package/plugins/runtime-modules/builder/controller/workspace-controller.js +8 -10
- package/plugins/runtime-modules/builder/developer-workspace-store.d.ts +10 -0
- package/plugins/runtime-modules/builder/developer-workspace-store.js +35 -1
- package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +6 -0
- package/plugins/runtime-modules/builder/offered-page-catalog.js +35 -6
- package/plugins/runtime-modules/builder/persistence.d.ts +4 -1
- package/plugins/runtime-modules/builder/persistence.js +10 -3
- 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/definition.d.ts +5 -0
- package/plugins/runtime-modules/core/form-providers.d.ts +5 -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/spacer/client.js +3 -3
- 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/phi-default-site-area-preset-tree.js +46 -39
- package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
- package/plugins/runtime-modules/preset-contracts/pub-area.js +1 -0
- package/plugins/runtime-modules/revisions/controller/client.js +48 -46
- package/plugins/runtime-modules/revisions/services/table.js +3 -1
- 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/styles/builder-scaffold.css +7 -1
- package/styles/layout-authoring-scaffold.css +27 -0
- 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,6 @@
|
|
|
1
1
|
import type { PhiMediaCollectionItem } from "../../../types/media";
|
|
2
2
|
import { type PhiMediaAssetFieldConfig } from "./media-asset-field";
|
|
3
|
+
import type { PhiAddonMediaLimits } from "../../../types/server-capabilities";
|
|
3
4
|
export type PhiMediaAssetsFieldConfig = Pick<PhiMediaAssetFieldConfig, "mediaType" | "folderPath"> & {
|
|
4
5
|
/**
|
|
5
6
|
* The most Assets the value may hold, from 1 to `PHI_MEDIA_ASSETS_FIELD_MOST` (the default): the field
|
|
@@ -13,6 +14,13 @@ export type PhiMediaAssetsFieldConfig = Pick<PhiMediaAssetFieldConfig, "mediaTyp
|
|
|
13
14
|
* `PHI_MEDIA_ASSETS_FIELD_MOST` is a `PhiConfigError` naming the field, never a default in its place.
|
|
14
15
|
*/
|
|
15
16
|
export declare function readPhiMediaAssetsFieldConfig(config: Readonly<Record<string, unknown>> | undefined): PhiMediaAssetsFieldConfig;
|
|
17
|
+
/**
|
|
18
|
+
* The field's config under the Media limits of the Add-on behind the Form: its own `max` stands where it
|
|
19
|
+
* is lower than the Add-on's `maxPerField`, and the Add-on's where the field's would be higher -- a field
|
|
20
|
+
* may hold fewer than the Add-on takes, never more. Everything that reads `max` (full, the refusal before
|
|
21
|
+
* a file is sent, the hold on a value beyond it, the sentence that says so) then reads the one it may hold.
|
|
22
|
+
*/
|
|
23
|
+
export declare function limitPhiMediaAssetsFieldConfig(config: PhiMediaAssetsFieldConfig, limits: PhiAddonMediaLimits | undefined): PhiMediaAssetsFieldConfig;
|
|
16
24
|
/**
|
|
17
25
|
* The Asset ids a Form value holds, in its order: a list's entries that are Asset ids (positive whole
|
|
18
26
|
* numbers, as `media-asset` reads its one), each once; anything that is not a list holds none.
|
|
@@ -16,6 +16,16 @@ export function readPhiMediaAssetsFieldConfig(config) {
|
|
|
16
16
|
: undefined) ?? PHI_MEDIA_ASSETS_FIELD_MOST,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The field's config under the Media limits of the Add-on behind the Form: its own `max` stands where it
|
|
21
|
+
* is lower than the Add-on's `maxPerField`, and the Add-on's where the field's would be higher -- a field
|
|
22
|
+
* may hold fewer than the Add-on takes, never more. Everything that reads `max` (full, the refusal before
|
|
23
|
+
* a file is sent, the hold on a value beyond it, the sentence that says so) then reads the one it may hold.
|
|
24
|
+
*/
|
|
25
|
+
export function limitPhiMediaAssetsFieldConfig(config, limits) {
|
|
26
|
+
const most = limits?.maxPerField;
|
|
27
|
+
return most != null && most < config.max ? { ...config, max: most } : config;
|
|
28
|
+
}
|
|
19
29
|
/**
|
|
20
30
|
* The Asset ids a Form value holds, in its order: a list's entries that are Asset ids (positive whole
|
|
21
31
|
* numbers, as `media-asset` reads its one), each once; anything that is not a list holds none.
|
|
@@ -20,6 +20,11 @@ import type { PhiFormFieldProviderProps } from "../../../components/forms/form-p
|
|
|
20
20
|
* offered, a file beyond it is refused before it is sent, and a value beyond it -- one that came in --
|
|
21
21
|
* holds the Form's submit with the sentence the field shows.
|
|
22
22
|
*
|
|
23
|
+
* The Media limits of the Add-on behind the Form (`mediaLimits`, FORMS.md) narrow that: its `maxPerField`
|
|
24
|
+
* is the most where `config.max` would be higher (`limitPhiMediaAssetsFieldConfig`), a file larger than its
|
|
25
|
+
* `maxFileBytes` is refused as too large before it is sent, and where its `kinds` leave out the field's kind
|
|
26
|
+
* every file is refused as of a type not allowed -- the upload's own refusals, in its upload words.
|
|
27
|
+
*
|
|
23
28
|
* The tiles are read in one request for the ids the field has no tile for yet (the Media list with `id`
|
|
24
29
|
* repeated, through the Media library's collection Provider), shown in the value's order; an id the list
|
|
25
30
|
* does not answer is an unavailable tile that can still be removed. A pick or an upload brings its tile.
|
|
@@ -20,7 +20,8 @@ import { usePhiIntlLocale, usePhiIntlTimeZone } from "../../../components/root/p
|
|
|
20
20
|
import { usePhiConfig } from "../../../components/root/phi-config-provider";
|
|
21
21
|
import { PHI_FORM_MEDIA_ASSETS_LABEL_KEYS, PHI_MEDIA_ASSETS_FIELD_MOST } from "./form-providers";
|
|
22
22
|
import { readPhiMediaFieldPickerLabels } from "./media-field-picker-labels";
|
|
23
|
-
import {
|
|
23
|
+
import { isPhiMediaFieldKindTaken, readPhiMediaFieldUploadAcceptance } from "./media-asset-field";
|
|
24
|
+
import { addPhiMediaAssetsFieldIds, limitPhiMediaAssetsFieldConfig, orderPhiMediaAssetsFieldTiles, readPhiMediaAssetsFieldConfig, readPhiMediaAssetsFieldValue, } from "./media-assets-field";
|
|
24
25
|
const DEFAULT_LABELS = {
|
|
25
26
|
remove: "Remove",
|
|
26
27
|
reorder: "Drag to reorder",
|
|
@@ -49,13 +50,18 @@ const TILE_MIN_WIDTH = 102;
|
|
|
49
50
|
* offered, a file beyond it is refused before it is sent, and a value beyond it -- one that came in --
|
|
50
51
|
* holds the Form's submit with the sentence the field shows.
|
|
51
52
|
*
|
|
53
|
+
* The Media limits of the Add-on behind the Form (`mediaLimits`, FORMS.md) narrow that: its `maxPerField`
|
|
54
|
+
* is the most where `config.max` would be higher (`limitPhiMediaAssetsFieldConfig`), a file larger than its
|
|
55
|
+
* `maxFileBytes` is refused as too large before it is sent, and where its `kinds` leave out the field's kind
|
|
56
|
+
* every file is refused as of a type not allowed -- the upload's own refusals, in its upload words.
|
|
57
|
+
*
|
|
52
58
|
* The tiles are read in one request for the ids the field has no tile for yet (the Media list with `id`
|
|
53
59
|
* repeated, through the Media library's collection Provider), shown in the value's order; an id the list
|
|
54
60
|
* does not answer is an unavailable tile that can still be removed. A pick or an upload brings its tile.
|
|
55
61
|
*/
|
|
56
|
-
export const PhiMediaAssetsFormControl = ({ field, value, labels, disabled, readOnly, onChange, formContext, }) => {
|
|
62
|
+
export const PhiMediaAssetsFormControl = ({ field, value, labels, disabled, readOnly, onChange, formContext, mediaLimits, }) => {
|
|
57
63
|
const { token } = usePhiConfig();
|
|
58
|
-
const config = useMemo(() => readPhiMediaAssetsFieldConfig(field.config), [field.config]);
|
|
64
|
+
const config = useMemo(() => limitPhiMediaAssetsFieldConfig(readPhiMediaAssetsFieldConfig(field.config), mediaLimits), [field.config, mediaLimits]);
|
|
59
65
|
const ids = readPhiMediaAssetsFieldValue(value);
|
|
60
66
|
const locked = disabled === true || readOnly === true;
|
|
61
67
|
const full = ids.length >= config.max;
|
|
@@ -156,8 +162,11 @@ export const PhiMediaAssetsFormControl = ({ field, value, labels, disabled, read
|
|
|
156
162
|
* would overfill it sends only what fits.
|
|
157
163
|
*/
|
|
158
164
|
const [uploadFolderPath, setUploadFolderPath] = useState(null);
|
|
159
|
-
const acceptance = useMemo(() => (
|
|
160
|
-
const
|
|
165
|
+
const acceptance = useMemo(() => readPhiMediaFieldUploadAcceptance(config.mediaType, config.max > 1, mediaLimits), [config.mediaType, config.max, mediaLimits]);
|
|
166
|
+
const kindTaken = isPhiMediaFieldKindTaken(config.mediaType, mediaLimits);
|
|
167
|
+
const uploadPanel = uploadFolderPath && !locked ? (_jsx(PhiAreaUploadBinding, { labels: mediaLabels.upload, config: uploadFolderPath.length > 0 ? { folderPath: uploadFolderPath.join(" / ") } : null, acceptance: acceptance, showFinished: false, siteSpaceOnly: true, collectionContext: { folders: [], folderId: null, folderPath: null, presentationFlags: null, query: {} }, onUploadingChange: setUploading, refuseFile: (_file, sending) => !kindTaken
|
|
168
|
+
? mediaLabels.upload.refusals.errorTypeNotAllowed
|
|
169
|
+
: readIdsNow().length + sending >= config.max ? tooMany : null, onAssetUploaded: (asset) => {
|
|
161
170
|
// Core does not know the field's kind, and a file the browser could not name reaches it unrefused.
|
|
162
171
|
if (asset.kind !== config.mediaType) {
|
|
163
172
|
setNotice(mediaLabels.upload.refusals.errorTypeNotAllowed);
|
|
@@ -166,7 +175,7 @@ export const PhiMediaAssetsFormControl = ({ field, value, labels, disabled, read
|
|
|
166
175
|
add([asset]);
|
|
167
176
|
} })) : null;
|
|
168
177
|
const shown = orderPhiMediaAssetsFieldTiles(ids, tiles, unavailableName);
|
|
169
|
-
const toolbar = locked ? null : (_jsxs(PhiToolbarControl, { compact: true,
|
|
178
|
+
const toolbar = locked ? null : (_jsxs(PhiToolbarControl, { compact: true, children: [_jsx(PhiButtonControl, { label: mediaLabels.upload.uploadToggleLabel, type: uploadFolderPath ? "primary" : "default", disabled: full && !uploadFolderPath, onClick: () => setUploadFolderPath((current) => current ? null : resolveFolderPath()) }), _jsx(PhiMediaPickerControl, { ...picker, disabled: full })] }));
|
|
170
179
|
// The Collection's own drag handles; the order dropped is the value's new order.
|
|
171
180
|
const reorder = locked || ids.length < 2 ? null : {
|
|
172
181
|
itemKeys: ids,
|
|
@@ -344,7 +344,7 @@ async function loadLabels(context) {
|
|
|
344
344
|
totpRoles: labels.totp.roles,
|
|
345
345
|
totpRolesHint: labels.totp.rolesHint,
|
|
346
346
|
role_admin: labels.roles.admin,
|
|
347
|
-
|
|
347
|
+
role_maintainer: labels.roles.maintainer,
|
|
348
348
|
role_builder: labels.roles.builder,
|
|
349
349
|
role_author: labels.roles.author,
|
|
350
350
|
role_publisher: labels.roles.publisher,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PhiBuilderRuntimeControllerConfig, type PhiBuilderRuntimeControllerPreload } from "./definition";
|
|
2
2
|
export declare const PHI_BUILDER_RUNTIME_CONTROLLER_PLUGIN: {
|
|
3
|
-
renderController: ({ preloadData, config }: import("../../../../types").PhiRuntimeControllerRenderArgs<PhiBuilderRuntimeControllerConfig, PhiBuilderRuntimeControllerPreload>) => import("react").FunctionComponentElement<import("./workspace-controller").PhiDeveloperBuilderWorkspaceControllerProps>;
|
|
3
|
+
renderController: ({ preloadData, config, runtime }: import("../../../../types").PhiRuntimeControllerRenderArgs<PhiBuilderRuntimeControllerConfig, PhiBuilderRuntimeControllerPreload>) => import("react").FunctionComponentElement<import("./workspace-controller").PhiDeveloperBuilderWorkspaceControllerProps>;
|
|
4
4
|
kind: "controller";
|
|
5
5
|
pluginKey: string;
|
|
6
6
|
key: string;
|
|
@@ -55,14 +55,14 @@ export declare const PHI_BUILDER_RUNTIME_CONTROLLER_PLUGIN: {
|
|
|
55
55
|
id: string;
|
|
56
56
|
channel: string;
|
|
57
57
|
action: "change";
|
|
58
|
-
valueType: "
|
|
59
|
-
valueSchema
|
|
58
|
+
valueType: "json";
|
|
59
|
+
valueSchema: `${string}/signals/${string}`;
|
|
60
60
|
} | {
|
|
61
61
|
id: string;
|
|
62
62
|
channel: string;
|
|
63
63
|
action: "change";
|
|
64
|
-
valueType: "
|
|
65
|
-
valueSchema
|
|
64
|
+
valueType: "string";
|
|
65
|
+
valueSchema?: undefined;
|
|
66
66
|
} | {
|
|
67
67
|
id: string;
|
|
68
68
|
channel: string;
|
|
@@ -5,7 +5,7 @@ import { PhiDeveloperBuilderWorkspaceControllerMount } from "./mount";
|
|
|
5
5
|
import { PHI_BUILDER_RUNTIME_CONTROLLER_DEFINITION, } from "./definition";
|
|
6
6
|
export const PHI_BUILDER_RUNTIME_CONTROLLER_PLUGIN = {
|
|
7
7
|
...PHI_BUILDER_RUNTIME_CONTROLLER_DEFINITION,
|
|
8
|
-
renderController: ({ preloadData, config }) => {
|
|
8
|
+
renderController: ({ preloadData, config, runtime }) => {
|
|
9
9
|
if (!preloadData?.shellPresetDraftsByArea ||
|
|
10
10
|
!preloadData.runtimeModuleDefinitions ||
|
|
11
11
|
!preloadData.runtimeModuleIdsByArea ||
|
|
@@ -25,6 +25,7 @@ export const PHI_BUILDER_RUNTIME_CONTROLLER_PLUGIN = {
|
|
|
25
25
|
throw new Error("Builder runtime controller requires server preload data.");
|
|
26
26
|
}
|
|
27
27
|
return createElement(PhiDeveloperBuilderWorkspaceControllerMount, {
|
|
28
|
+
viewer: runtime.viewer,
|
|
28
29
|
signalRoutes: config.signalRoutes,
|
|
29
30
|
shellPresetDraftsByArea: preloadData.shellPresetDraftsByArea,
|
|
30
31
|
runtimeModuleDefinitions: preloadData.runtimeModuleDefinitions,
|
|
@@ -105,14 +105,14 @@ export declare const PHI_BUILDER_RUNTIME_CONTROLLER_DEFINITION: {
|
|
|
105
105
|
id: string;
|
|
106
106
|
channel: string;
|
|
107
107
|
action: "change";
|
|
108
|
-
valueType: "
|
|
109
|
-
valueSchema
|
|
108
|
+
valueType: "json";
|
|
109
|
+
valueSchema: `${string}/signals/${string}`;
|
|
110
110
|
} | {
|
|
111
111
|
id: string;
|
|
112
112
|
channel: string;
|
|
113
113
|
action: "change";
|
|
114
|
-
valueType: "
|
|
115
|
-
valueSchema
|
|
114
|
+
valueType: "string";
|
|
115
|
+
valueSchema?: undefined;
|
|
116
116
|
} | {
|
|
117
117
|
id: string;
|
|
118
118
|
channel: string;
|
|
@@ -150,6 +150,13 @@ export const PHI_BUILDER_RUNTIME_CONTROLLER_DEFINITION = {
|
|
|
150
150
|
action: "activate",
|
|
151
151
|
valueType: "none",
|
|
152
152
|
},
|
|
153
|
+
{
|
|
154
|
+
id: "revisionDraftStatus",
|
|
155
|
+
channel: "draftStatus",
|
|
156
|
+
action: "change",
|
|
157
|
+
valueType: "json",
|
|
158
|
+
valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.revisionsDraftStatus,
|
|
159
|
+
},
|
|
153
160
|
{
|
|
154
161
|
id: "builderMode",
|
|
155
162
|
channel: "builderMode",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { PhiAccessViewer } from "../../../../types/access";
|
|
1
2
|
import { type PhiHistoryLabels } from "../../../../components/widgets/label-types/history";
|
|
2
3
|
import type { PhiBuilderSavedHistoryHead } from "./draft-status-controller";
|
|
3
4
|
import type { PhiDeveloperBuilderArea, PhiDeveloperBuilderWorkspaceState } from "../developer-workspace-types";
|
|
4
5
|
export type PhiDeveloperBuilderToolbarCommand = "save" | "preview" | "publish" | "undo" | "redo" | "reset";
|
|
5
|
-
export declare function usePhiBuilderDraftCommandController({ effectiveArea, effectiveNavKey, effectivePageKey, pathname, captureHistoryHead, reportSaved, hasUnsavedChanges, state, historyLabels, }: {
|
|
6
|
+
export declare function usePhiBuilderDraftCommandController({ effectiveArea, effectiveNavKey, effectivePageKey, pathname, captureHistoryHead, reportSaved, hasUnsavedChanges, state, viewer, historyLabels, }: {
|
|
6
7
|
effectiveArea: PhiDeveloperBuilderArea;
|
|
7
8
|
effectiveNavKey: string;
|
|
8
9
|
effectivePageKey: string;
|
|
@@ -14,6 +15,7 @@ export declare function usePhiBuilderDraftCommandController({ effectiveArea, eff
|
|
|
14
15
|
/** Whether the workspace on screen holds edits no stored revision has. */
|
|
15
16
|
hasUnsavedChanges: boolean;
|
|
16
17
|
state: PhiDeveloperBuilderWorkspaceState;
|
|
18
|
+
viewer: PhiAccessViewer;
|
|
17
19
|
/** What an undo or redo says it moved, in the author's language. */
|
|
18
20
|
historyLabels: PhiHistoryLabels;
|
|
19
21
|
}): {
|
|
@@ -19,7 +19,7 @@ import { usePhiBuilderModuleMetas } from "../plugin-meta-store";
|
|
|
19
19
|
import { setPhiWorkspaceModuleSelection } from "../workspace-catalog-actions";
|
|
20
20
|
import { applyPhiBuilderNavigationFolderTargets, refreshPhiBuilderNavigationFolderAddresses, } from "../navigation-folder-address";
|
|
21
21
|
import { createPhiBuilderNavigationPathContext } from "../navigation-path-context";
|
|
22
|
-
export function usePhiBuilderDraftCommandController({ effectiveArea, effectiveNavKey, effectivePageKey, pathname, captureHistoryHead, reportSaved, hasUnsavedChanges, state, historyLabels, }) {
|
|
22
|
+
export function usePhiBuilderDraftCommandController({ effectiveArea, effectiveNavKey, effectivePageKey, pathname, captureHistoryHead, reportSaved, hasUnsavedChanges, state, viewer, historyLabels, }) {
|
|
23
23
|
/*
|
|
24
24
|
* Every one of these is a command from a toolbar somewhere else, so there is nothing on screen to
|
|
25
25
|
* hang a Popconfirm on. Drawn as a Dialog by this Controller rather than asked of Ant Design's
|
|
@@ -258,6 +258,7 @@ export function usePhiBuilderDraftCommandController({ effectiveArea, effectiveNa
|
|
|
258
258
|
* before it opens, and which of the two it shows.
|
|
259
259
|
*/
|
|
260
260
|
const result = await previewPhiDeveloperBuilderDraft(state, workspaceKind, {
|
|
261
|
+
viewer,
|
|
261
262
|
pathname,
|
|
262
263
|
scope: previewScope,
|
|
263
264
|
});
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { PHI_SIGNAL_VALUE_SCHEMAS } from "../../../../types/signals";
|
|
4
|
+
import { readPhiDraftStatusSignalValue } from "../../../../types/draft-status";
|
|
5
|
+
import { isPhiBuilderAreaKey } from "../../../../constants/cms-areas";
|
|
6
|
+
import { isPhiRecord } from "../../../../helpers/is-record";
|
|
4
7
|
import { usePhiSignalDispatcher, usePhiSignalListener } from "../../../../components/runtime/runtime-signal-bus";
|
|
5
8
|
import { resolvePhiBuilderCmsStoragePath } from "../../../../helpers/cms-paths";
|
|
6
9
|
import { resolvePhiBuilderActivePageCatalog, resolvePhiBuilderPagePresetSource, } from "../../../../helpers/cms-page-catalog";
|
|
7
10
|
import { createPhiBuilderControllerAddress } from "../controller/address";
|
|
8
11
|
import { createPhiBuilderHistoryContext, phiBuilderHistory } from "../history";
|
|
12
|
+
import { clearPhiBuilderDraftAllocation, getPhiBuilderDraftContextGeneration, invalidatePhiBuilderDraftContext, } from "../developer-workspace-store";
|
|
13
|
+
import { createPhiBuilderDraftAllocationKey } from "../draft-allocation-key";
|
|
9
14
|
const PHI_BUILDER_NO_DRAFT_HISTORY_CONTEXT = "draft-status:none";
|
|
10
15
|
function resolveTarget(workspace, area, pageKey, navKey, state) {
|
|
11
16
|
if (workspace === "navigation") {
|
|
@@ -87,17 +92,20 @@ export function usePhiBuilderDraftStatusController({ commandWorkspace, effective
|
|
|
87
92
|
const targetUrl = target?.url ?? null;
|
|
88
93
|
const subject = target?.subject ?? null;
|
|
89
94
|
const historyContext = target?.historyContext ?? null;
|
|
95
|
+
const requestKey = targetUrl === null || historyContext === null
|
|
96
|
+
? null
|
|
97
|
+
: `${targetUrl}:${getPhiBuilderDraftContextGeneration(historyContext)}`;
|
|
90
98
|
const [stored, setStored] = useState(null);
|
|
91
99
|
/*
|
|
92
100
|
* The history head each target was last saved or first read at. The status is read again whenever the
|
|
93
101
|
* target changes -- an Area switched away from and back -- and taking the head at that moment called
|
|
94
102
|
* every edit made before it saved: back on an Area with an unsaved edit, the badge said "Published".
|
|
95
|
-
* A target keeps
|
|
103
|
+
* A target keeps its saved head until a revision action replaces that editing context.
|
|
96
104
|
*/
|
|
97
105
|
const savedHeadsRef = useRef(new Map());
|
|
98
106
|
const historyHead = phiBuilderHistory.useHead(historyContext ?? PHI_BUILDER_NO_DRAFT_HISTORY_CONTEXT);
|
|
99
107
|
useEffect(() => {
|
|
100
|
-
if (targetUrl === null) {
|
|
108
|
+
if (targetUrl === null || requestKey === null || historyContext === null) {
|
|
101
109
|
return;
|
|
102
110
|
}
|
|
103
111
|
let cancelled = false;
|
|
@@ -105,16 +113,11 @@ export function usePhiBuilderDraftStatusController({ commandWorkspace, effective
|
|
|
105
113
|
if (cancelled) {
|
|
106
114
|
return;
|
|
107
115
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
savedHeadsRef.current.set(targetUrl, historyContext === null ? null : phiBuilderHistory.getHead(historyContext));
|
|
114
|
-
}
|
|
115
|
-
return savedHeadsRef.current.get(targetUrl);
|
|
116
|
-
})(),
|
|
117
|
-
});
|
|
116
|
+
const saved = savedHeadsRef.current.get(targetUrl);
|
|
117
|
+
const savedHead = saved?.requestKey === requestKey ? saved.head
|
|
118
|
+
: saved ? null : phiBuilderHistory.getHead(historyContext);
|
|
119
|
+
savedHeadsRef.current.set(targetUrl, { requestKey, head: savedHead });
|
|
120
|
+
setStored({ requestKey, ...next, savedHead });
|
|
118
121
|
};
|
|
119
122
|
void fetch(targetUrl, { method: "GET", cache: "no-store" })
|
|
120
123
|
.then(async (response) => {
|
|
@@ -140,8 +143,8 @@ export function usePhiBuilderDraftStatusController({ commandWorkspace, effective
|
|
|
140
143
|
return () => {
|
|
141
144
|
cancelled = true;
|
|
142
145
|
};
|
|
143
|
-
}, [historyContext, targetUrl]);
|
|
144
|
-
const current = stored === null || stored.requestKey !==
|
|
146
|
+
}, [historyContext, requestKey, targetUrl]);
|
|
147
|
+
const current = stored === null || stored.requestKey !== requestKey || subject === null
|
|
145
148
|
? null
|
|
146
149
|
: stored.status === "error"
|
|
147
150
|
? { status: "error", revisionId: null, subject, error: stored.error }
|
|
@@ -169,6 +172,30 @@ export function usePhiBuilderDraftStatusController({ commandWorkspace, effective
|
|
|
169
172
|
}
|
|
170
173
|
}, [emitTo, serialized]);
|
|
171
174
|
usePhiSignalListener((signal) => {
|
|
175
|
+
if (signal.scope === "area" &&
|
|
176
|
+
signal.channel === "draftStatus" &&
|
|
177
|
+
signal.action === "change" &&
|
|
178
|
+
signal.valueSchema === PHI_SIGNAL_VALUE_SCHEMAS.revisionsDraftStatus &&
|
|
179
|
+
signal.receiver === "broadcast" &&
|
|
180
|
+
signal.sender !== createPhiBuilderControllerAddress() &&
|
|
181
|
+
isPhiRecord(signal.value)) {
|
|
182
|
+
// Revisions names the exact draft it replaced. Ordinary status messages describe the canvas.
|
|
183
|
+
const { area, pageKey, areaModules } = signal.value;
|
|
184
|
+
const status = readPhiDraftStatusSignalValue(signal.value)?.status;
|
|
185
|
+
if (!isPhiBuilderAreaKey(area) || (status !== "draft" && status !== "published")) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (areaModules === true) {
|
|
189
|
+
clearPhiBuilderDraftAllocation(createPhiBuilderDraftAllocationKey(area, "", "modules"));
|
|
190
|
+
}
|
|
191
|
+
else if (typeof pageKey === "string") {
|
|
192
|
+
invalidatePhiBuilderDraftContext({ workspace: "pages", area, pageKey });
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
invalidatePhiBuilderDraftContext({ workspace: "structure", area });
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
172
199
|
if (signal.scope !== "area" ||
|
|
173
200
|
signal.channel !== "draftStatus" ||
|
|
174
201
|
signal.action !== "activate" ||
|
|
@@ -192,12 +219,12 @@ export function usePhiBuilderDraftStatusController({ commandWorkspace, effective
|
|
|
192
219
|
}), [historyContext]);
|
|
193
220
|
/** A save or publish of the workspace on screen: the state it stored, and the head it was taken at. */
|
|
194
221
|
function reportSaved(status, revisionId, savedAt) {
|
|
195
|
-
if (targetUrl === null) {
|
|
222
|
+
if (targetUrl === null || requestKey === null) {
|
|
196
223
|
return;
|
|
197
224
|
}
|
|
198
|
-
savedHeadsRef.current.set(targetUrl, savedAt.head);
|
|
225
|
+
savedHeadsRef.current.set(targetUrl, { requestKey, head: savedAt.head });
|
|
199
226
|
setStored({
|
|
200
|
-
requestKey
|
|
227
|
+
requestKey,
|
|
201
228
|
status,
|
|
202
229
|
revisionId,
|
|
203
230
|
error: null,
|
|
@@ -84,14 +84,14 @@ export declare const PHI_BUILDER_RUNTIME_CONTROLLER_SERVER_DEFINITION: {
|
|
|
84
84
|
id: string;
|
|
85
85
|
channel: string;
|
|
86
86
|
action: "change";
|
|
87
|
-
valueType: "
|
|
88
|
-
valueSchema
|
|
87
|
+
valueType: "json";
|
|
88
|
+
valueSchema: `${string}/signals/${string}`;
|
|
89
89
|
} | {
|
|
90
90
|
id: string;
|
|
91
91
|
channel: string;
|
|
92
92
|
action: "change";
|
|
93
|
-
valueType: "
|
|
94
|
-
valueSchema
|
|
93
|
+
valueType: "string";
|
|
94
|
+
valueSchema?: undefined;
|
|
95
95
|
} | {
|
|
96
96
|
id: string;
|
|
97
97
|
channel: string;
|
|
@@ -5,9 +5,11 @@ import type { PhiAreaRootRoute, PhiAreaMeta } from "../../../../helpers/cms-area
|
|
|
5
5
|
import type { PhiWorkspaceCatalogState } from "../../../../components/workspace/catalog-state";
|
|
6
6
|
import { type PhiBuilderPageMetaPresentationLabels } from "../controller/definition";
|
|
7
7
|
import type { PhiCmsTreeControllerSettings } from "../../../../types/cms";
|
|
8
|
+
import type { PhiAccessViewer } from "../../../../types/access";
|
|
8
9
|
import { type PhiHistoryLabels } from "../../../../components/widgets/label-types/history";
|
|
9
10
|
export type { PhiBuilderPageRegionKey, PhiBuilderRegionKey, PhiBuilderShellRegionKey, } from "../region-keys";
|
|
10
11
|
export type PhiDeveloperBuilderWorkspaceControllerProps = {
|
|
12
|
+
viewer: PhiAccessViewer;
|
|
11
13
|
shellPresetDraftsByArea?: Record<string, Record<string, PhiDeveloperBuilderRegionDraft>>;
|
|
12
14
|
runtimeModuleDefinitions?: readonly PhiRuntimeModuleDefinition[];
|
|
13
15
|
runtimeModuleIdsByArea?: Record<string, PhiRuntimeModuleId[]>;
|
|
@@ -27,4 +29,4 @@ export type PhiDeveloperBuilderWorkspaceControllerProps = {
|
|
|
27
29
|
historyLabels: PhiHistoryLabels;
|
|
28
30
|
signalRoutes?: PhiSignalRouteSet | null;
|
|
29
31
|
};
|
|
30
|
-
export declare function PhiDeveloperBuilderWorkspaceController({ shellPresetDraftsByArea, runtimeModuleDefinitions, runtimeModuleIdsByArea, modulePresetPagesByArea, areaPresetSourcesByArea, areaShellsByArea, navigationSurfacesByArea, unresolvedModuleIdsByArea, serverUnavailableModules, publicRouteClaims, publicRoutePaths, areaRootRoutesByArea, areaMetaByArea, areaControllerSettingsByArea, pageMetaLabels, historyLabels, signalRoutes, }: PhiDeveloperBuilderWorkspaceControllerProps): import("react").JSX.Element;
|
|
32
|
+
export declare function PhiDeveloperBuilderWorkspaceController({ viewer, shellPresetDraftsByArea, runtimeModuleDefinitions, runtimeModuleIdsByArea, modulePresetPagesByArea, areaPresetSourcesByArea, areaShellsByArea, navigationSurfacesByArea, unresolvedModuleIdsByArea, serverUnavailableModules, publicRouteClaims, publicRoutePaths, areaRootRoutesByArea, areaMetaByArea, areaControllerSettingsByArea, pageMetaLabels, historyLabels, signalRoutes, }: PhiDeveloperBuilderWorkspaceControllerProps): import("react").JSX.Element;
|
|
@@ -130,7 +130,7 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
130
130
|
const effectsWorkflowCorrelationRef = useRef(null);
|
|
131
131
|
const initializedEffectsCorrelationRef = useRef(null);
|
|
132
132
|
const effectsFormSubmissionRef = useRef(null);
|
|
133
|
-
const { shellPresetDraftsByArea = {}, runtimeModuleDefinitions = [], runtimeModuleIdsByArea = {}, modulePresetPagesByArea = EMPTY_MODULE_PRESET_PAGES_BY_AREA, areaPresetSourcesByArea = {}, areaShellsByArea = EMPTY_AREA_SHELLS, navigationSurfacesByArea = {}, unresolvedModuleIdsByArea = EMPTY_RUNTIME_MODULE_IDS_BY_AREA, serverUnavailableModules = EMPTY_SERVER_UNAVAILABLE_MODULES, publicRouteClaims = EMPTY_PUBLIC_ROUTE_CLAIMS, publicRoutePaths = EMPTY_PUBLIC_ROUTE_PATHS, areaRootRoutesByArea = EMPTY_AREA_ROOT_ROUTES, areaMetaByArea = EMPTY_AREA_META, areaControllerSettingsByArea = EMPTY_AREA_CONTROLLER_SETTINGS, pageMetaLabels = PHI_BUILDER_PAGE_META_DEFAULT_PRESENTATION_LABELS, historyLabels, signalRoutes = null, } = options;
|
|
133
|
+
const { viewer, shellPresetDraftsByArea = {}, runtimeModuleDefinitions = [], runtimeModuleIdsByArea = {}, modulePresetPagesByArea = EMPTY_MODULE_PRESET_PAGES_BY_AREA, areaPresetSourcesByArea = {}, areaShellsByArea = EMPTY_AREA_SHELLS, navigationSurfacesByArea = {}, unresolvedModuleIdsByArea = EMPTY_RUNTIME_MODULE_IDS_BY_AREA, serverUnavailableModules = EMPTY_SERVER_UNAVAILABLE_MODULES, publicRouteClaims = EMPTY_PUBLIC_ROUTE_CLAIMS, publicRoutePaths = EMPTY_PUBLIC_ROUTE_PATHS, areaRootRoutesByArea = EMPTY_AREA_ROOT_ROUTES, areaMetaByArea = EMPTY_AREA_META, areaControllerSettingsByArea = EMPTY_AREA_CONTROLLER_SETTINGS, pageMetaLabels = PHI_BUILDER_PAGE_META_DEFAULT_PRESENTATION_LABELS, historyLabels, signalRoutes = null, } = options;
|
|
134
134
|
/*
|
|
135
135
|
* One declared output, delivered through every route written for it.
|
|
136
136
|
*
|
|
@@ -187,6 +187,7 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
187
187
|
hasUnsavedChanges,
|
|
188
188
|
reportSaved,
|
|
189
189
|
state,
|
|
190
|
+
viewer,
|
|
190
191
|
historyLabels,
|
|
191
192
|
});
|
|
192
193
|
const currentRuntimeModuleIdsByArea = state.runtimeModuleIdsByArea ?? EMPTY_RUNTIME_MODULE_IDS_BY_AREA;
|
|
@@ -211,24 +212,20 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
211
212
|
const publicRouteClaimsPreloadKey = useMemo(() => JSON.stringify(publicRouteClaims), [publicRouteClaims]);
|
|
212
213
|
const serverUnavailableModulesPreloadKey = useMemo(() => JSON.stringify(serverUnavailableModules), [serverUnavailableModules]);
|
|
213
214
|
const publicRoutePathsPreloadKey = useMemo(() => JSON.stringify(publicRoutePaths), [publicRoutePaths]);
|
|
214
|
-
const areaRootRoutesPreloadKey = useMemo(() => JSON.stringify(areaRootRoutesByArea), [areaRootRoutesByArea]);
|
|
215
215
|
/*
|
|
216
216
|
* The Areas' root routes, handed to every workspace rather than to /shells alone.
|
|
217
217
|
*
|
|
218
218
|
* It is a baseline and not a draft: /pages reads it to leave `/` out of its page selector while the
|
|
219
|
-
* root forwards
|
|
219
|
+
* root forwards. A save can update the client baseline between preloads, so a fresh server answer
|
|
220
|
+
* must be applied even when its content matches the answer the Controller received before that save.
|
|
220
221
|
*/
|
|
221
222
|
useEffect(() => {
|
|
222
223
|
setPhiDeveloperBuilderAreaRootRoutes(areaRootRoutesByArea);
|
|
223
|
-
|
|
224
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
225
|
-
}, [areaRootRoutesPreloadKey]);
|
|
224
|
+
}, [areaRootRoutesByArea]);
|
|
226
225
|
// What the Areas said about being found, read from the same revision and set the same way.
|
|
227
|
-
const areaMetaPreloadKey = useMemo(() => JSON.stringify(areaMetaByArea), [areaMetaByArea]);
|
|
228
226
|
useEffect(() => {
|
|
229
227
|
setPhiDeveloperBuilderAreaMetaBaseline(areaMetaByArea);
|
|
230
|
-
|
|
231
|
-
}, [areaMetaPreloadKey]);
|
|
228
|
+
}, [areaMetaByArea]);
|
|
232
229
|
// What each Shell tells its Controllers, carried into every save that states the Shell whole.
|
|
233
230
|
const areaControllerSettingsPreloadKey = useMemo(() => JSON.stringify(areaControllerSettingsByArea), [areaControllerSettingsByArea]);
|
|
234
231
|
useEffect(() => {
|
|
@@ -1444,8 +1441,9 @@ function usePhiDeveloperBuilderWorkspaceController(options) {
|
|
|
1444
1441
|
*/
|
|
1445
1442
|
return _jsxs(_Fragment, { children: [pageMetaDialog, confirmDialog] });
|
|
1446
1443
|
}
|
|
1447
|
-
export function PhiDeveloperBuilderWorkspaceController({ shellPresetDraftsByArea = {}, runtimeModuleDefinitions = [], runtimeModuleIdsByArea = {}, modulePresetPagesByArea = EMPTY_MODULE_PRESET_PAGES_BY_AREA, areaPresetSourcesByArea = {}, areaShellsByArea = EMPTY_AREA_SHELLS, navigationSurfacesByArea = {}, unresolvedModuleIdsByArea = EMPTY_RUNTIME_MODULE_IDS_BY_AREA, serverUnavailableModules = EMPTY_SERVER_UNAVAILABLE_MODULES, publicRouteClaims = EMPTY_PUBLIC_ROUTE_CLAIMS, publicRoutePaths = EMPTY_PUBLIC_ROUTE_PATHS, areaRootRoutesByArea = EMPTY_AREA_ROOT_ROUTES, areaMetaByArea = EMPTY_AREA_META, areaControllerSettingsByArea = EMPTY_AREA_CONTROLLER_SETTINGS, pageMetaLabels = PHI_BUILDER_PAGE_META_DEFAULT_PRESENTATION_LABELS, historyLabels, signalRoutes = null, }) {
|
|
1444
|
+
export function PhiDeveloperBuilderWorkspaceController({ viewer, shellPresetDraftsByArea = {}, runtimeModuleDefinitions = [], runtimeModuleIdsByArea = {}, modulePresetPagesByArea = EMPTY_MODULE_PRESET_PAGES_BY_AREA, areaPresetSourcesByArea = {}, areaShellsByArea = EMPTY_AREA_SHELLS, navigationSurfacesByArea = {}, unresolvedModuleIdsByArea = EMPTY_RUNTIME_MODULE_IDS_BY_AREA, serverUnavailableModules = EMPTY_SERVER_UNAVAILABLE_MODULES, publicRouteClaims = EMPTY_PUBLIC_ROUTE_CLAIMS, publicRoutePaths = EMPTY_PUBLIC_ROUTE_PATHS, areaRootRoutesByArea = EMPTY_AREA_ROOT_ROUTES, areaMetaByArea = EMPTY_AREA_META, areaControllerSettingsByArea = EMPTY_AREA_CONTROLLER_SETTINGS, pageMetaLabels = PHI_BUILDER_PAGE_META_DEFAULT_PRESENTATION_LABELS, historyLabels, signalRoutes = null, }) {
|
|
1448
1445
|
const controller = usePhiDeveloperBuilderWorkspaceController({
|
|
1446
|
+
viewer,
|
|
1449
1447
|
shellPresetDraftsByArea,
|
|
1450
1448
|
runtimeModuleDefinitions,
|
|
1451
1449
|
runtimeModuleIdsByArea,
|
|
@@ -55,6 +55,7 @@ export type PhiDeveloperBuilderNodeSelection = {
|
|
|
55
55
|
openWiring?: boolean;
|
|
56
56
|
};
|
|
57
57
|
export declare function selectPhiDeveloperBuilderNode(selection: PhiDeveloperBuilderNodeSelection): void;
|
|
58
|
+
export declare function getPhiBuilderDraftContextGeneration(context: string): number;
|
|
58
59
|
export declare function patchPhiDeveloperBuilderState(next: Partial<Pick<PhiDeveloperBuilderState, "pickerWidgetCategoryFilters">>): void;
|
|
59
60
|
type PhiBuilderRegionDraftMutationOptions = {
|
|
60
61
|
history?: PhiBuilderHistoryRecording | null;
|
|
@@ -199,6 +200,15 @@ export declare function resetPhiBuilderSignalWiringSession(): void;
|
|
|
199
200
|
*/
|
|
200
201
|
export declare function storePhiBuilderDraftAllocation(allocationKey: string, saved: PhiDeveloperBuilderDraftAllocation): void;
|
|
201
202
|
export declare function clearPhiBuilderDraftAllocation(allocationKey: string): void;
|
|
203
|
+
/** A successful revision action supersedes the canvas and undo history of just that draft. */
|
|
204
|
+
export declare function invalidatePhiBuilderDraftContext(scope: {
|
|
205
|
+
workspace: "structure";
|
|
206
|
+
area: PhiDeveloperBuilderArea;
|
|
207
|
+
} | {
|
|
208
|
+
workspace: "pages";
|
|
209
|
+
area: PhiDeveloperBuilderArea;
|
|
210
|
+
pageKey: string;
|
|
211
|
+
}): void;
|
|
202
212
|
/** Takes the next node sequence of a Draft, answering the allocation it was taken from. */
|
|
203
213
|
export declare function takePhiBuilderDraftNodeSequence(allocationKey: string): PhiDeveloperBuilderDraftAllocation;
|
|
204
214
|
/**
|
|
@@ -6,7 +6,9 @@ import { createPhiSignalCorrelationId } from "../../../components/runtime/runtim
|
|
|
6
6
|
import { useRef, useSyncExternalStore } from "react";
|
|
7
7
|
import { createPhiPluginStateStore } from "../../../components/state/plugin-state-store";
|
|
8
8
|
import { phiWorkspaceCatalogStore, } from "../../../components/workspace/catalog-store";
|
|
9
|
-
import { phiBuilderHistory } from "./history";
|
|
9
|
+
import { createPhiBuilderHistoryContext, phiBuilderHistory } from "./history";
|
|
10
|
+
import { createPhiBuilderDraftAllocationKey } from "./draft-allocation-key";
|
|
11
|
+
import { getPhiBuilderPageDraftKey, getPhiBuilderRegionDraftKey, PHI_BUILDER_PAGE_REGION_KEYS, PHI_BUILDER_SHELL_REGION_KEYS, } from "./region-keys";
|
|
10
12
|
import { openPhiWorkspacePage, restorePhiWorkspaceCatalog, setPhiWorkspacePageKey, } from "./workspace-catalog-actions";
|
|
11
13
|
export function normalizePhiDeveloperBuilderArea(scopeKey) {
|
|
12
14
|
return isPhiBuilderAreaKey(scopeKey) ? scopeKey : "public";
|
|
@@ -204,6 +206,10 @@ export function selectPhiDeveloperBuilderNode(selection) {
|
|
|
204
206
|
}));
|
|
205
207
|
}
|
|
206
208
|
const builderRegionDraftStore = createPhiPluginStateStore("@phis/ui/developer-region-drafts", () => ({}));
|
|
209
|
+
const builderDraftContextGenerations = new Map();
|
|
210
|
+
export function getPhiBuilderDraftContextGeneration(context) {
|
|
211
|
+
return builderDraftContextGenerations.get(context) ?? 0;
|
|
212
|
+
}
|
|
207
213
|
export function patchPhiDeveloperBuilderState(next) {
|
|
208
214
|
builderWorkspaceStore.patch(PHI_WORKSPACE_CATALOG_SCOPE, (current) => ({
|
|
209
215
|
...current,
|
|
@@ -813,6 +819,34 @@ export function clearPhiBuilderDraftAllocation(allocationKey) {
|
|
|
813
819
|
return { ...current, draftAllocations };
|
|
814
820
|
});
|
|
815
821
|
}
|
|
822
|
+
/** A successful revision action supersedes the canvas and undo history of just that draft. */
|
|
823
|
+
export function invalidatePhiBuilderDraftContext(scope) {
|
|
824
|
+
const { area, workspace } = scope;
|
|
825
|
+
const context = createPhiBuilderHistoryContext(scope);
|
|
826
|
+
builderDraftContextGenerations.set(context, getPhiBuilderDraftContextGeneration(context) + 1);
|
|
827
|
+
const pageKey = workspace === "pages" ? scope.pageKey : null;
|
|
828
|
+
const regions = workspace === "pages" ? PHI_BUILDER_PAGE_REGION_KEYS : PHI_BUILDER_SHELL_REGION_KEYS;
|
|
829
|
+
restorePhiDeveloperRegionDrafts(Object.fromEntries(regions.map((region) => [getPhiBuilderRegionDraftKey(area, region, pageKey), null])));
|
|
830
|
+
if (pageKey === null) {
|
|
831
|
+
setPhiDeveloperBuilderAreaRootRoute(area, undefined);
|
|
832
|
+
restorePhiDeveloperBuilderAreaMeta(area, undefined);
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
const metaKey = getPhiBuilderPageDraftKey(area, "page_meta", pageKey);
|
|
836
|
+
const deleteKey = getPhiBuilderPageDraftKey(area, "page_delete", pageKey);
|
|
837
|
+
builderWorkspaceStore.patch(PHI_WORKSPACE_CATALOG_SCOPE, (current) => {
|
|
838
|
+
const pageMetaDrafts = { ...current.pageMetaDrafts };
|
|
839
|
+
const deletedPageDrafts = { ...current.deletedPageDrafts };
|
|
840
|
+
const pageControllerSettings = { ...current.pageControllerSettings };
|
|
841
|
+
delete pageMetaDrafts[metaKey];
|
|
842
|
+
delete deletedPageDrafts[deleteKey];
|
|
843
|
+
delete pageControllerSettings[metaKey];
|
|
844
|
+
return { ...current, pageMetaDrafts, deletedPageDrafts, pageControllerSettings };
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
clearPhiBuilderDraftAllocation(createPhiBuilderDraftAllocationKey(area, pageKey ?? "", workspace === "pages" ? "page" : "area"));
|
|
848
|
+
phiBuilderHistory.clear(context);
|
|
849
|
+
}
|
|
816
850
|
/** Takes the next node sequence of a Draft, answering the allocation it was taken from. */
|
|
817
851
|
export function takePhiBuilderDraftNodeSequence(allocationKey) {
|
|
818
852
|
const allocation = builderWorkspaceStore.getSnapshot(PHI_WORKSPACE_CATALOG_SCOPE).draftAllocations[allocationKey];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type PhiBuilderPageCatalogArea, type PhiPresetPageNode } from "../../../helpers/cms-page-catalog";
|
|
2
|
+
import { type PhiAccessViewer } from "../../../types/access";
|
|
2
3
|
import type { PhiDeveloperBuilderWorkspaceState } from "./developer-workspace-types";
|
|
3
4
|
/**
|
|
4
5
|
* The part of the workspace this reads, named rather than taken whole.
|
|
@@ -61,6 +62,11 @@ export declare function resolvePhiBuilderOfferedPageKey(state: PhiBuilderOffered
|
|
|
61
62
|
pages: PhiPresetPageNode[];
|
|
62
63
|
pageKey: string | null;
|
|
63
64
|
};
|
|
65
|
+
/** The shell is drawn on the Page its Area leads to, below the landing at `/`. */
|
|
66
|
+
export declare function resolvePhiBuilderShellPreviewPage(state: PhiBuilderOfferedCatalogState, area: PhiBuilderPageCatalogArea, viewer: PhiAccessViewer): {
|
|
67
|
+
pages: PhiPresetPageNode[];
|
|
68
|
+
pageKey: string | null;
|
|
69
|
+
};
|
|
64
70
|
/**
|
|
65
71
|
* Whether the open Page is a root the Builder has taken over to construct itself.
|
|
66
72
|
*
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolvePhiBuilderAreaAsCmsArea } from "../../../constants/cms-areas";
|
|
3
|
+
import { isPhiCmsErrorPagePath } from "../../../constants/cms-error-pages";
|
|
3
4
|
import { choosePhiAreaRootApplicant, resolvePhiAreaLandingSelection, } from "../../../helpers/cms-area-config";
|
|
4
|
-
import { findPhiBuilderPageKeyFromStoragePath, normalizePhiBuilderCmsCatalogPath, resolvePhiBuilderActivePageCatalog, resolvePhiBuilderActivePageKey, resolvePhiBuilderRequestedPageKey, resolvePhiBuilderPageKeyFromCatalogPath, } from "../../../helpers/cms-page-catalog";
|
|
5
|
+
import { findPhiBuilderPageKeyFromStoragePath, findPhiPageNodePath, normalizePhiBuilderCmsCatalogPath, resolvePhiBuilderActivePageCatalog, resolvePhiBuilderActivePageKey, resolvePhiBuilderRequestedPageKey, resolvePhiBuilderPageKeyFromCatalogPath, } from "../../../helpers/cms-page-catalog";
|
|
5
6
|
import { findFirstPhiCmsNavigationLinkPath } from "../../../components/regions/presets/navigation-redirect";
|
|
7
|
+
import { canPhiViewerAccess } from "../../../types/access";
|
|
6
8
|
import { resolvePhiRuntimeAreaDefinition } from "../area-definitions";
|
|
7
9
|
import { resolvePhiAreaRootRouteNavKey } from "../area-root-route";
|
|
8
10
|
import { listPhiAlwaysActiveRuntimeModuleIds } from "../settings";
|
|
@@ -210,17 +212,44 @@ export function resolvePhiBuilderOfferedPageKey(state, area, requestedPageKey) {
|
|
|
210
212
|
if (requested) {
|
|
211
213
|
return { pages, pageKey: requested };
|
|
212
214
|
}
|
|
213
|
-
const rootRoute = readPhiBuilderStoredAreaRootRoute(state, area);
|
|
214
|
-
const forwardTargetKey = rootRoute?.mode === "redirect"
|
|
215
|
-
? findPageKeyByReference(pages, rootRoute.targetLinkTarget.reference)
|
|
216
|
-
: null;
|
|
217
215
|
return {
|
|
218
216
|
pages,
|
|
219
|
-
pageKey:
|
|
217
|
+
pageKey: findAreaForwardTargetPageKey(state, area, pages)
|
|
220
218
|
?? findAreaNavigationEntryPageKey(state, area, pages)
|
|
221
219
|
?? resolvePhiBuilderActivePageKey(null, pages),
|
|
222
220
|
};
|
|
223
221
|
}
|
|
222
|
+
function findAreaForwardTargetPageKey(state, area, pages) {
|
|
223
|
+
const rootRoute = readPhiBuilderStoredAreaRootRoute(state, area);
|
|
224
|
+
return rootRoute?.mode === "redirect"
|
|
225
|
+
? findPageKeyByReference(pages, rootRoute.targetLinkTarget.reference)
|
|
226
|
+
: null;
|
|
227
|
+
}
|
|
228
|
+
/** The shell is drawn on the Page its Area leads to, below the landing at `/`. */
|
|
229
|
+
export function resolvePhiBuilderShellPreviewPage(state, area, viewer) {
|
|
230
|
+
const pages = resolvePhiBuilderOfferedPageCatalog(state, area);
|
|
231
|
+
const isPreviewablePage = (key) => {
|
|
232
|
+
const page = key ? findPhiPageNodePath(pages, key)?.at(-1) : null;
|
|
233
|
+
if (!page?.storagePath || page.tombstoned || page.routeParameter) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
const path = normalizePhiBuilderCmsCatalogPath(page.storagePath);
|
|
237
|
+
return path !== "/" && !isPhiCmsErrorPagePath(path);
|
|
238
|
+
};
|
|
239
|
+
const forwardTargetKey = findAreaForwardTargetPageKey(state, area, pages);
|
|
240
|
+
if (isPreviewablePage(forwardTargetKey)) {
|
|
241
|
+
return { pages, pageKey: forwardTargetKey };
|
|
242
|
+
}
|
|
243
|
+
// Public has its Home entry in the header. Staff and App Area roots follow their own sidebar.
|
|
244
|
+
const navKey = area === "public" ? "public:header" : resolvePhiAreaRootRouteNavKey(resolvePhiBuilderAreaAsCmsArea(area));
|
|
245
|
+
const surface = state.navigationSurfacesByArea[area]?.find((candidate) => candidate.navKey === navKey);
|
|
246
|
+
const findPageKey = (path) => findPhiBuilderPageKeyFromStoragePath(area, path, pages);
|
|
247
|
+
const path = findFirstPhiCmsNavigationLinkPath(surface?.items ?? [], "/", {
|
|
248
|
+
isVisible: (item) => canPhiViewerAccess(viewer, item.accessPolicy),
|
|
249
|
+
acceptsPath: (candidate) => isPreviewablePage(findPageKey(candidate)),
|
|
250
|
+
});
|
|
251
|
+
return { pages, pageKey: path ? findPageKey(path) : null };
|
|
252
|
+
}
|
|
224
253
|
/**
|
|
225
254
|
* Where a root that forwards on its own actually lands.
|
|
226
255
|
*
|