@phis/ui 0.4.21 → 0.4.23
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 +1 -1
- package/components/controls/phi-brand-control.d.ts +10 -2
- package/components/controls/phi-brand-control.js +12 -8
- package/components/controls/phi-cascader-control.js +6 -1
- package/components/controls/phi-geometry-control.d.ts +33 -1
- package/components/controls/phi-geometry-control.js +87 -29
- package/components/controls/phi-series-chart-control.js +4 -2
- package/components/forms/form-provider-contract.d.ts +1 -0
- package/components/forms/form-provider-contract.js +1 -0
- package/components/forms/upload-form-control.js +1 -0
- package/components/layouts/clients/phi-flex-layout-client.js +23 -5
- package/components/layouts/clients/phi-grid-layout-client.js +20 -10
- package/components/layouts/clients/phi-layout-anchored-overlay.d.ts +2 -0
- package/components/layouts/clients/phi-layout-anchored-overlay.js +9 -2
- package/components/layouts/clients/phi-three-column-layout-client.js +7 -4
- package/components/layouts/layout-definitions.d.ts +16 -16
- package/components/layouts/layout-definitions.js +8 -8
- package/components/layouts/phi-base-layout.js +13 -9
- package/components/layouts/phi-layout-contract.d.ts +12 -2
- package/components/layouts/phi-layout-contract.js +30 -7
- package/components/layouts/phi-masonry-layout.d.ts +6 -0
- package/components/layouts/phi-masonry-layout.js +13 -3
- package/components/layouts/plugins/masonry-layout-plugin.js +2 -1
- package/components/media/asset-collection-runtime.d.ts +1 -6
- package/components/media/asset-collection-runtime.js +2 -93
- package/components/media/label-sets/media.js +12 -0
- package/components/media/media-folder-lock.d.ts +19 -0
- package/components/media/media-folder-lock.js +40 -0
- package/components/media/media-folder-options.d.ts +14 -2
- package/components/media/media-folder-options.js +17 -5
- package/components/media/media-widget-labels.d.ts +9 -0
- package/components/media/media-widget-labels.js +6 -0
- package/components/media/phi-area-upload-widget.js +1 -0
- package/components/media/phi-asset-folder-control.d.ts +14 -1
- package/components/media/phi-asset-folder-control.js +11 -4
- package/components/media/phi-image-preview-store.d.ts +0 -4
- package/components/media/phi-image-preview-store.js +0 -10
- package/components/media/phi-media-picker-binding.d.ts +7 -2
- package/components/media/phi-media-upload.d.ts +2 -0
- package/components/media/phi-media-upload.js +3 -0
- package/components/regions/clients/cms-region-container-client.d.ts +3 -1
- package/components/regions/clients/cms-region-container-client.js +4 -3
- package/components/regions/phi-cms-region-container.d.ts +3 -1
- package/components/regions/phi-cms-region-container.js +3 -2
- package/components/regions/phi-cms-region-shell.d.ts +9 -1
- package/components/regions/phi-cms-region-shell.js +3 -1
- package/components/regions/phi-cms-region-static.d.ts +3 -1
- package/components/regions/phi-cms-region-static.js +3 -2
- package/components/regions/presets/navigation-redirect.d.ts +2 -2
- package/components/regions/presets/navigation-redirect.js +5 -3
- package/components/shell/phi-antd-icon.d.ts +2 -0
- package/components/shell/phi-antd-icon.js +6 -0
- package/components/widgets/label-sets/geometry.js +10 -0
- package/components/widgets/label-types/geometry.d.ts +7 -0
- package/components/widgets/label-types/geometry.js +6 -0
- package/components/widgets/shared/markdown-render.js +30 -135
- package/components/widgets/shared/markdown-translation-unit.d.ts +62 -0
- package/components/widgets/shared/markdown-translation-unit.js +211 -0
- package/helpers/block-geometry-profiles.d.ts +67 -0
- package/helpers/block-geometry-profiles.js +105 -0
- package/helpers/cms-navigation-catalog.js +4 -2
- package/helpers/renderable-block-effects.js +16 -0
- package/package.json +1 -1
- package/plugins/runtime/phi-slot-child-frame-view.js +14 -4
- package/plugins/runtime/phi-slot-child-viewport-effects-observer.js +42 -2
- package/plugins/runtime/slot-size-policy.d.ts +15 -0
- package/plugins/runtime/slot-size-policy.js +29 -0
- package/plugins/runtime-modules/asset/data-providers.js +3 -0
- package/plugins/runtime-modules/asset/services/collection.js +34 -0
- package/plugins/runtime-modules/asset/services/options.js +19 -2
- package/plugins/runtime-modules/asset/trees/phi-default-builder-media-page-tree.js +9 -0
- package/plugins/runtime-modules/auth/trees/phi-auth-runtime-page-tree.js +21 -17
- package/plugins/runtime-modules/avatar/widgets/account-avatar-picker/client.js +2 -0
- package/plugins/runtime-modules/builder/clients/region-inspector.js +1 -1
- package/plugins/runtime-modules/builder/render-root-node-preview.server.js +2 -1
- package/plugins/runtime-modules/builder/services/navigation-table.js +3 -2
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +7 -1
- package/plugins/runtime-modules/builder/widgets/structure-region/built-in.js +8 -2
- package/plugins/runtime-modules/core/messaging/data-providers.js +23 -0
- package/plugins/runtime-modules/core/messaging/labels.d.ts +2 -0
- package/plugins/runtime-modules/core/messaging/labels.js +8 -0
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.d.ts +32 -0
- package/plugins/runtime-modules/core/messaging/thread-inbox-table.js +31 -16
- package/plugins/runtime-modules/core/widgets/brand/client.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/brand/client.js +2 -1
- package/plugins/runtime-modules/core/widgets/brand/plugin.js +23 -2
- package/plugins/runtime-modules/core/widgets/brand/server.d.ts +2 -2
- package/plugins/runtime-modules/core/widgets/brand/server.js +2 -1
- package/plugins/runtime-modules/core/widgets/card/server.js +7 -4
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +52 -6
- package/plugins/runtime-modules/core/widgets/gallery/plugin.js +3 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.js +12 -2
- package/plugins/runtime-modules/core/widgets/image/server.js +28 -5
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +8 -2
- package/plugins/runtime-modules/descriptor-compiler.js +45 -2
- package/plugins/runtime-modules/public/trees/phi-default-pub-welcome-page-tree.js +8 -14
- package/plugins/runtime-modules/search/widgets/search-box/client.d.ts +2 -1
- package/plugins/runtime-modules/search/widgets/search-box/client.js +28 -6
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +19 -2
- package/plugins/runtime-modules/threads/labels.d.ts +6 -0
- package/plugins/runtime-modules/threads/labels.js +16 -0
- package/plugins/runtime-modules/threads/trees/phi-default-threads-page-tree.js +24 -1
- package/styles/layout.css +101 -0
- package/styles/root.css +2 -1
- package/types/cms-config.d.ts +5 -1
- package/types/cms-config.js +1 -0
- package/types/cms-module-descriptors.d.ts +17 -0
- package/types/renderable-block.d.ts +5 -0
- package/types/site-theme.d.ts +9 -1
- package/types.d.ts +1 -1
|
@@ -8,6 +8,7 @@ import { getPhiBuilderRegionDraftKey } from "./region-keys";
|
|
|
8
8
|
import { normalizePhiBuilderRootNodeDraft, readPhiBuilderRootNodeDraft, } from "./root-node-normalization";
|
|
9
9
|
import { resolvePhiRenderableBlockGeometry } from "../../../types/renderable-block-geometry";
|
|
10
10
|
import { resolvePhiRootScaffoldProperties } from "./builder-geometry";
|
|
11
|
+
import { phiBlockGeometryQueriesRoom, phiSlotContainerAttributes, } from "../../../helpers/block-geometry-profiles";
|
|
11
12
|
import { buildPhiBuilderRootNodeRenderableTree } from "./root-node-renderable-tree";
|
|
12
13
|
import { normalizePhiPaddingWidgetConfig } from "../../../types/cms-config";
|
|
13
14
|
import { resolvePhiPaddingStyle } from "../../../components/layouts/phi-layout-contract";
|
|
@@ -150,7 +151,7 @@ async function PhiBuilderRootNodeServerPreview({ rootNode, runtime, regionType =
|
|
|
150
151
|
: undefined, className: "phi-cms-region-shell phi-cms-region-shell--fill", style: {
|
|
151
152
|
width: "100%",
|
|
152
153
|
height: "100%",
|
|
153
|
-
}, children: _jsx("div", { className: "phi-cms-region-shell__content", style: regionPaddingStyle, children: _jsx(PhiSlotChildFrame, { className: "phi-builder-root-scaffold__slot", kind: rootSlotChildKind, blockId: rootNode.id ?? null, explicitInlineSize: rootGeometry.explicitInline, explicitBlockSize: rootGeometry.explicitBlock, style: resolvePhiRootScaffoldProperties(rootGeometry), children: _jsx(PhiCmsLayoutRenderer, { tree: {
|
|
154
|
+
}, children: _jsx("div", { className: "phi-cms-region-shell__content", ...phiSlotContainerAttributes(phiBlockGeometryQueriesRoom(rootGeometry)), style: regionPaddingStyle, children: _jsx(PhiSlotChildFrame, { className: "phi-builder-root-scaffold__slot", kind: rootSlotChildKind, blockId: rootNode.id ?? null, explicitInlineSize: rootGeometry.explicitInline, explicitBlockSize: rootGeometry.explicitBlock, style: resolvePhiRootScaffoldProperties(rootGeometry), children: _jsx(PhiCmsLayoutRenderer, { tree: {
|
|
154
155
|
...previewTree,
|
|
155
156
|
regions: previewTree.regions.map((region) => ({
|
|
156
157
|
...region,
|
|
@@ -81,7 +81,8 @@ function flattenNavigationRows(items, moduleTitles, paths, parentId = null, hidd
|
|
|
81
81
|
hidden: item.hidden,
|
|
82
82
|
hiddenByAncestor,
|
|
83
83
|
external: item.external === true,
|
|
84
|
-
|
|
84
|
+
// A Module entry's new-tab choice is the Module's: an item override carries no `newTab`.
|
|
85
|
+
newTabEditable: item.kind === "link" && item.source === "custom",
|
|
85
86
|
newTab: item.newTab === true,
|
|
86
87
|
}, ...flattenNavigationRows(item.children, moduleTitles, paths, item.id, hiddenByAncestor || item.hidden)];
|
|
87
88
|
});
|
|
@@ -415,7 +416,7 @@ export function PhiBuilderNavigationTableProviderClient({ children }) {
|
|
|
415
416
|
patch.icon = request.proposedValue || null;
|
|
416
417
|
}
|
|
417
418
|
else if (request.fieldKey === "newTab" && typeof request.proposedValue === "boolean" &&
|
|
418
|
-
item.kind === "link")
|
|
419
|
+
item.kind === "link" && item.source === "custom")
|
|
419
420
|
patch.newTab = request.proposedValue;
|
|
420
421
|
else
|
|
421
422
|
return { status: "rejected", invalidation: "none", errorCode: "field-readonly", message: "Navigation field cannot be changed." };
|
|
@@ -469,6 +469,11 @@ export async function buildPhiDefaultBuilderAreaPresetTree({ page, runtime, }) {
|
|
|
469
469
|
paddingTop: 0,
|
|
470
470
|
},
|
|
471
471
|
}),
|
|
472
|
+
/*
|
|
473
|
+
* A Shell Region's root, not a Page column: the Page-column rule (THIRD_PARTY_MODULES.md, 6b) and
|
|
474
|
+
* the base scaffold govern the `content` Region only. The Builder's footer ships empty, and the
|
|
475
|
+
* Content Layout is the neutral one-slot frame an author fills from the Shells canvas.
|
|
476
|
+
*/
|
|
472
477
|
nodes.layout({
|
|
473
478
|
typeKey: "content",
|
|
474
479
|
id: SYNTHETIC_DEV_LAYOUT_IDS.layoutFooterMain,
|
|
@@ -951,7 +956,8 @@ async function buildPhiDefaultBuilderPagePresetTemplateTree({ page, runtime, pre
|
|
|
951
956
|
},
|
|
952
957
|
}
|
|
953
958
|
: {
|
|
954
|
-
|
|
959
|
+
creationPreset: { layoutKind: "verticalflex", preset: "panel" },
|
|
960
|
+
typeKey: "flex-vertical",
|
|
955
961
|
id: SYNTHETIC_DEV_LAYOUT_IDS.layoutContent,
|
|
956
962
|
siteId: page.siteId,
|
|
957
963
|
parentLayoutNodeId: null,
|
|
@@ -13,6 +13,7 @@ import { combinePhiBoxShadows, resolvePhiShadow } from "../../../../../helpers/l
|
|
|
13
13
|
import { readPhiCmsInstanceId } from "../../../../../types/cms-instance-id";
|
|
14
14
|
import { normalizePhiPaddingWidgetConfig } from "../../../../../types/cms-config";
|
|
15
15
|
import { readPhiRenderableBlockLength, resolvePhiRenderableBlockGeometry, } from "../../../../../types/renderable-block-geometry";
|
|
16
|
+
import { phiBlockGeometryQueriesRoom, phiSlotContainerAttributes, } from "../../../../../helpers/block-geometry-profiles";
|
|
16
17
|
import { extractPhiStructureNode as extractStructureNode, swapPhiStructureWidgetsAcrossTrees, swapPhiStructureWidgetsInTree, } from "../../../../../helpers/structure-widget-swap";
|
|
17
18
|
import { createPhiSignalAddress, } from "../../../../../types/signals";
|
|
18
19
|
import { resolvePhiShellRegionTypography, resolvePhiShellRegionZIndex } from "../../../../../helpers/shell-region-style";
|
|
@@ -423,6 +424,11 @@ export function PhiStructureRegionScaffold({ config, serverPreview, structureDra
|
|
|
423
424
|
: undefined;
|
|
424
425
|
const rootNode = effectiveDraft?.rootNode ?? null;
|
|
425
426
|
const rootNodeId = rootNode?.id ?? null;
|
|
427
|
+
/*
|
|
428
|
+
* The Region slot is the room a profiled root Layout is offered on the Canvas, as the Region's content
|
|
429
|
+
* wrapper is on the page (LAYOUTING.md, "Block geometry per profile").
|
|
430
|
+
*/
|
|
431
|
+
const rootSlotContainerAttributes = phiSlotContainerAttributes(phiBlockGeometryQueriesRoom(resolvePhiRenderableBlockGeometry(rootNode?.config)));
|
|
426
432
|
const rootNodeKind = rootNode ? "layout" : null;
|
|
427
433
|
const rootNodeTypeKey = rootNode?.widgetType ?? "";
|
|
428
434
|
const rootNodeChildLayouts = readPhiBuilderRegionRootChildLayouts(effectiveDraft);
|
|
@@ -1200,7 +1206,7 @@ export function PhiStructureRegionScaffold({ config, serverPreview, structureDra
|
|
|
1200
1206
|
: shouldStretchAvailableHeight
|
|
1201
1207
|
? "100%"
|
|
1202
1208
|
: undefined;
|
|
1203
|
-
return (_jsx("div", { "data-phi-region-slot": config.regionKey, [PHI_VISUAL_ANCHOR_PART_ATTRIBUTE]: config.regionKey, className: joinPhiClassNames("phi-builder-structure-region__slot", regionToneClassName), "data-phi-builder-region-mode": "preview", "data-phi-builder-region-has-root-node": hasRootNode ? "true" : "false", "data-phi-builder-region-selected": "false", "data-phi-builder-region-picking": "false", style: {
|
|
1209
|
+
return (_jsx("div", { "data-phi-region-slot": config.regionKey, [PHI_VISUAL_ANCHOR_PART_ATTRIBUTE]: config.regionKey, className: joinPhiClassNames("phi-builder-structure-region__slot", regionToneClassName), ...rootSlotContainerAttributes, "data-phi-builder-region-mode": "preview", "data-phi-builder-region-has-root-node": hasRootNode ? "true" : "false", "data-phi-builder-region-selected": "false", "data-phi-builder-region-picking": "false", style: {
|
|
1204
1210
|
width: slotWidth,
|
|
1205
1211
|
minWidth: slotMinWidth,
|
|
1206
1212
|
maxWidth: slotMaxWidth,
|
|
@@ -1264,7 +1270,7 @@ export function PhiStructureRegionScaffold({ config, serverPreview, structureDra
|
|
|
1264
1270
|
event.preventDefault();
|
|
1265
1271
|
selectRegion();
|
|
1266
1272
|
}
|
|
1267
|
-
}, children: [isPreviewMode ? null : (_jsxs(PhiFlexControl, { vertical: true, gap: 0, style: { minWidth: 0, width: "100%" }, children: [_jsxs(PhiFlexControl, { align: "center", gap: 6, wrap: false, style: { minWidth: 0, width: "100%", whiteSpace: "nowrap" }, children: [_jsx(PhiTypographyControl, { strong: true, style: { minWidth: 0, whiteSpace: "nowrap" }, children: config.title }), _jsxs(PhiTypographyControl, { type: "secondary", style: { minWidth: 0, whiteSpace: "nowrap" }, children: ["\u00B7 ", config.regionKey] })] }), config.subtitle ? (_jsx(PhiTypographyControl, { type: "secondary", style: { display: "block", whiteSpace: "normal", overflowWrap: "anywhere" }, children: config.subtitle })) : null] })), renderRegionPicker(_jsx("div", { ref: setRootDropNodeRef, "data-phi-region-slot": config.regionKey, className: joinPhiClassNames("phi-builder-structure-region__slot", regionToneClassName), "data-phi-builder-region-mode": "editor", "data-phi-structure-drop-state": rootDropAccepted
|
|
1273
|
+
}, children: [isPreviewMode ? null : (_jsxs(PhiFlexControl, { vertical: true, gap: 0, style: { minWidth: 0, width: "100%" }, children: [_jsxs(PhiFlexControl, { align: "center", gap: 6, wrap: false, style: { minWidth: 0, width: "100%", whiteSpace: "nowrap" }, children: [_jsx(PhiTypographyControl, { strong: true, style: { minWidth: 0, whiteSpace: "nowrap" }, children: config.title }), _jsxs(PhiTypographyControl, { type: "secondary", style: { minWidth: 0, whiteSpace: "nowrap" }, children: ["\u00B7 ", config.regionKey] })] }), config.subtitle ? (_jsx(PhiTypographyControl, { type: "secondary", style: { display: "block", whiteSpace: "normal", overflowWrap: "anywhere" }, children: config.subtitle })) : null] })), renderRegionPicker(_jsx("div", { ref: setRootDropNodeRef, "data-phi-region-slot": config.regionKey, className: joinPhiClassNames("phi-builder-structure-region__slot", regionToneClassName), ...rootSlotContainerAttributes, "data-phi-builder-region-mode": "editor", "data-phi-structure-drop-state": rootDropAccepted
|
|
1268
1274
|
? "accepted"
|
|
1269
1275
|
: rootDropIsOver
|
|
1270
1276
|
? "rejected"
|
|
@@ -70,8 +70,11 @@ export const PHI_CORE_MESSAGING_DATA_PROVIDER_DESCRIPTORS = [
|
|
|
70
70
|
{ value: "unread", label: "New" },
|
|
71
71
|
{ value: "open", label: "Open" },
|
|
72
72
|
{ value: "archived", label: "Archived" },
|
|
73
|
+
{ value: "locked", label: "Locked" },
|
|
73
74
|
] },
|
|
74
75
|
{ key: "archived", title: "Archived", type: "boolean" },
|
|
76
|
+
// `PhisThreadFlag.Locked`, read off the row's flags: Core takes no new message into it.
|
|
77
|
+
{ key: "locked", title: "Locked", type: "boolean" },
|
|
75
78
|
{ key: "unread", title: "Unread", type: "boolean" },
|
|
76
79
|
{ key: "latestMessageAt", title: "Last activity", type: "datetime" },
|
|
77
80
|
{ key: "updatedAt", title: "Changed", type: "datetime" },
|
|
@@ -113,6 +116,26 @@ export const PHI_CORE_MESSAGING_DATA_PROVIDER_DESCRIPTORS = [
|
|
|
113
116
|
intent: "write",
|
|
114
117
|
visibleWhen: { source: "row", valuePath: "archived", operator: "truthy" },
|
|
115
118
|
},
|
|
119
|
+
/*
|
|
120
|
+
* The lock is not the archive: a locked conversation stays where it is and stays readable, it
|
|
121
|
+
* only takes nothing new. It asks first for the same reason archiving does -- it reaches
|
|
122
|
+
* everybody in it -- and unlocking, the way back, asks nothing.
|
|
123
|
+
*/
|
|
124
|
+
{
|
|
125
|
+
key: "lock",
|
|
126
|
+
title: "Lock",
|
|
127
|
+
scope: "row",
|
|
128
|
+
intent: "write",
|
|
129
|
+
confirmation: "required",
|
|
130
|
+
visibleWhen: { source: "row", valuePath: "locked", operator: "falsy" },
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
key: "unlock",
|
|
134
|
+
title: "Unlock",
|
|
135
|
+
scope: "row",
|
|
136
|
+
intent: "write",
|
|
137
|
+
visibleWhen: { source: "row", valuePath: "locked", operator: "truthy" },
|
|
138
|
+
},
|
|
116
139
|
],
|
|
117
140
|
},
|
|
118
141
|
],
|
|
@@ -28,6 +28,8 @@ export declare function getPhiThreadConversationLabels(options: PhiGlobalTransla
|
|
|
28
28
|
subjectFallback: string;
|
|
29
29
|
olderLabel: string;
|
|
30
30
|
archivedLabel: string;
|
|
31
|
+
lockedLabel: string;
|
|
32
|
+
lockedText: string;
|
|
31
33
|
replyLabel: string;
|
|
32
34
|
participantsLabel: string;
|
|
33
35
|
internalLabel: string;
|
|
@@ -19,6 +19,12 @@ const PHI_THREAD_CONVERSATION_LABEL_SET = definePhiRuntimeModuleLabelSet(PHI_COR
|
|
|
19
19
|
subject_fallback: "Conversation",
|
|
20
20
|
older_label: "Show earlier messages",
|
|
21
21
|
archived_label: "Archived",
|
|
22
|
+
locked_label: "Locked",
|
|
23
|
+
/*
|
|
24
|
+
* Where the Reply would have been. A locked conversation takes no new message from anybody, so the
|
|
25
|
+
* way to write one is not offered at all rather than offered and then refused.
|
|
26
|
+
*/
|
|
27
|
+
locked_text: definePhiMessageLabel("This conversation is locked. Nobody can write in it until it is unlocked."),
|
|
22
28
|
/* The action in the conversation's heading that opens a reply. */
|
|
23
29
|
reply_label: "Reply",
|
|
24
30
|
/* Before the names of who is in it, beneath a heading that is the subject. */
|
|
@@ -128,6 +134,8 @@ export async function getPhiThreadConversationLabels(options) {
|
|
|
128
134
|
subjectFallback: labels.subject_fallback,
|
|
129
135
|
olderLabel: labels.older_label,
|
|
130
136
|
archivedLabel: labels.archived_label,
|
|
137
|
+
lockedLabel: labels.locked_label,
|
|
138
|
+
lockedText: labels.locked_text,
|
|
131
139
|
replyLabel: labels.reply_label,
|
|
132
140
|
participantsLabel: labels.participants_label,
|
|
133
141
|
internalLabel: labels.internal_label,
|
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a cell shows and what a condition reads, neither of which is a flag.
|
|
3
|
+
*
|
|
4
|
+
* `state` is the name a badge draws and `archived` and `locked` the answers a row action asks for; the
|
|
5
|
+
* enum values are strings because that is what an enum column and a condition compare against. The
|
|
6
|
+
* status itself stays on the row, because the filter above is written against what the route takes.
|
|
7
|
+
*
|
|
8
|
+
* One badge, so one state wins: archived over everything, then unread -- a message waiting to be read is
|
|
9
|
+
* what the reader acts on, and a lock is read in the conversation once it is open -- then locked.
|
|
10
|
+
*/
|
|
11
|
+
export declare function readPhiThreadInboxRow(row: Record<string, unknown>): {
|
|
12
|
+
kind: string;
|
|
13
|
+
status: string;
|
|
14
|
+
archived: boolean;
|
|
15
|
+
locked: boolean;
|
|
16
|
+
state: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* What a row action writes, in the shape `PATCH /api/site/threads/{id}` takes it: archiving and reopening
|
|
20
|
+
* change the status, locking and unlocking the lock. Both are one row everybody in the conversation
|
|
21
|
+
* shares, and Core decides who may change them.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readPhiThreadInboxActionBody(actionKey: string): {
|
|
24
|
+
status: 1;
|
|
25
|
+
locked?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
status: 0;
|
|
28
|
+
locked?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
locked: boolean;
|
|
31
|
+
status?: undefined;
|
|
32
|
+
} | null;
|
|
1
33
|
export declare const PhiThreadTableProviderClient: import("react").ComponentType<{
|
|
2
34
|
children: import("react").ReactNode;
|
|
3
35
|
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { PhisThreadStatus } from "../../../../constants/threads";
|
|
2
|
+
import { PhisThreadFlag, PhisThreadStatus } from "../../../../constants/threads";
|
|
3
3
|
import { buildPhiTablePageParams, createPhiTableProviderRequestInit, readPhiTableRows, } from "../../../../components/widgets/client/shared/phi-table-provider-request";
|
|
4
4
|
import { PhiTableProviderError, } from "../../../../types/table-widget";
|
|
5
5
|
import { createPhiTableProviderClient } from "../../../../components/widgets/client/shared/phi-table-provider";
|
|
@@ -39,18 +39,23 @@ function buildThreadQuery(query) {
|
|
|
39
39
|
/**
|
|
40
40
|
* What a cell shows and what a condition reads, neither of which is a flag.
|
|
41
41
|
*
|
|
42
|
-
* `state` is the name a badge draws and `archived` the
|
|
43
|
-
* are strings because that is what an enum column and a condition compare against. The
|
|
44
|
-
* stays on the row, because the filter above is written against what the route takes.
|
|
42
|
+
* `state` is the name a badge draws and `archived` and `locked` the answers a row action asks for; the
|
|
43
|
+
* enum values are strings because that is what an enum column and a condition compare against. The
|
|
44
|
+
* status itself stays on the row, because the filter above is written against what the route takes.
|
|
45
|
+
*
|
|
46
|
+
* One badge, so one state wins: archived over everything, then unread -- a message waiting to be read is
|
|
47
|
+
* what the reader acts on, and a lock is read in the conversation once it is open -- then locked.
|
|
45
48
|
*/
|
|
46
|
-
function
|
|
49
|
+
export function readPhiThreadInboxRow(row) {
|
|
47
50
|
const archived = row.status === PhisThreadStatus.Archived;
|
|
51
|
+
const locked = typeof row.flags === "number" && (row.flags & PhisThreadFlag.Locked) !== 0;
|
|
48
52
|
return {
|
|
49
53
|
...row,
|
|
50
54
|
kind: String(row.kind),
|
|
51
55
|
status: String(row.status),
|
|
52
56
|
archived,
|
|
53
|
-
|
|
57
|
+
locked,
|
|
58
|
+
state: archived ? "archived" : row.unread === true ? "unread" : locked ? "locked" : "open",
|
|
54
59
|
};
|
|
55
60
|
}
|
|
56
61
|
async function queryThreadTable({ resourceKey, query, signal, }) {
|
|
@@ -58,7 +63,7 @@ async function queryThreadTable({ resourceKey, query, signal, }) {
|
|
|
58
63
|
throw new PhiTableProviderError("resource-not-found", `Unknown conversation resource "${resourceKey}".`);
|
|
59
64
|
}
|
|
60
65
|
const payload = await readPhiTableProviderResponse(await fetch(`${API_PATH}?${buildThreadQuery(query).toString()}`, createPhiTableProviderRequestInit(signal)), RESPONSE_OPTIONS);
|
|
61
|
-
const rows = readPhiTableRows(payload?.rows).map(
|
|
66
|
+
const rows = readPhiTableRows(payload?.rows).map(readPhiThreadInboxRow);
|
|
62
67
|
return {
|
|
63
68
|
rows,
|
|
64
69
|
total: typeof payload?.total === "number" ? payload.total : undefined,
|
|
@@ -76,7 +81,21 @@ function readThreadId(value) {
|
|
|
76
81
|
return threadId;
|
|
77
82
|
}
|
|
78
83
|
/**
|
|
79
|
-
*
|
|
84
|
+
* What a row action writes, in the shape `PATCH /api/site/threads/{id}` takes it: archiving and reopening
|
|
85
|
+
* change the status, locking and unlocking the lock. Both are one row everybody in the conversation
|
|
86
|
+
* shares, and Core decides who may change them.
|
|
87
|
+
*/
|
|
88
|
+
export function readPhiThreadInboxActionBody(actionKey) {
|
|
89
|
+
switch (actionKey) {
|
|
90
|
+
case "archive": return { status: PhisThreadStatus.Archived };
|
|
91
|
+
case "reopen": return { status: PhisThreadStatus.Open };
|
|
92
|
+
case "lock": return { locked: true };
|
|
93
|
+
case "unlock": return { locked: false };
|
|
94
|
+
default: return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A status or lock change, and then the listing again.
|
|
80
99
|
*
|
|
81
100
|
* The answer to a PATCH is the new status and nothing else, but what changed on screen is the row's
|
|
82
101
|
* place in an order kept by last activity -- so the view is reloaded rather than the cell patched. A
|
|
@@ -87,14 +106,10 @@ async function mutateThreadTable(request) {
|
|
|
87
106
|
throw new PhiTableProviderError("invalid-resource", `Unknown conversation resource "${request.resourceKey}".`);
|
|
88
107
|
}
|
|
89
108
|
if (request.kind !== "action") {
|
|
90
|
-
throw new PhiTableProviderError("mutation-not-supported", "A conversation is not edited in a cell; archiving and
|
|
109
|
+
throw new PhiTableProviderError("mutation-not-supported", "A conversation is not edited in a cell; archiving, reopening, locking and unlocking are actions.");
|
|
91
110
|
}
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
: request.actionKey === "reopen"
|
|
95
|
-
? PhisThreadStatus.Open
|
|
96
|
-
: null;
|
|
97
|
-
if (status == null) {
|
|
111
|
+
const body = readPhiThreadInboxActionBody(request.actionKey);
|
|
112
|
+
if (body == null) {
|
|
98
113
|
throw new PhiTableProviderError("action-not-supported", `Unsupported conversation action "${request.actionKey}".`);
|
|
99
114
|
}
|
|
100
115
|
const init = createPhiTableProviderRequestInit(request.signal);
|
|
@@ -102,7 +117,7 @@ async function mutateThreadTable(request) {
|
|
|
102
117
|
...init,
|
|
103
118
|
method: "PATCH",
|
|
104
119
|
headers: { ...init.headers, "content-type": "application/json" },
|
|
105
|
-
body: JSON.stringify(
|
|
120
|
+
body: JSON.stringify(body),
|
|
106
121
|
}), RESPONSE_OPTIONS);
|
|
107
122
|
return { status: "accepted", invalidation: "view" };
|
|
108
123
|
}
|
|
@@ -17,6 +17,8 @@ export type PhiBrandWidgetClientProps = PhiClientBlockBaseProps<PhiNoLabels, Phi
|
|
|
17
17
|
*/
|
|
18
18
|
home?: PhiBrandWidgetHome;
|
|
19
19
|
interactive?: boolean;
|
|
20
|
+
/** The Logo's description in the page's language, translated on the Server. */
|
|
21
|
+
logoAlt?: string;
|
|
20
22
|
};
|
|
21
23
|
/** A ready address, and whether it leaves the Site -- the shape `resolvePhiLinkHref` answers. */
|
|
22
24
|
export type PhiBrandWidgetHome = {
|
|
@@ -31,4 +33,4 @@ export type PhiBrandWidgetHome = {
|
|
|
31
33
|
* because the Theme workspace preview shows the same Brand without being in a frame and without
|
|
32
34
|
* leading anywhere.
|
|
33
35
|
*/
|
|
34
|
-
export declare function PhiBrandWidgetClient({ config, home, fallbackTitle, interactive, }: PhiBrandWidgetClientProps): import("react").JSX.Element | null;
|
|
36
|
+
export declare function PhiBrandWidgetClient({ config, home, fallbackTitle, interactive, logoAlt, }: PhiBrandWidgetClientProps): import("react").JSX.Element | null;
|
|
@@ -19,7 +19,7 @@ export const PHI_BRAND_LINE_FALLBACK_ICONS = {
|
|
|
19
19
|
* because the Theme workspace preview shows the same Brand without being in a frame and without
|
|
20
20
|
* leading anywhere.
|
|
21
21
|
*/
|
|
22
|
-
export function PhiBrandWidgetClient({ config, home, fallbackTitle, interactive = true, }) {
|
|
22
|
+
export function PhiBrandWidgetClient({ config, home, fallbackTitle, interactive = true, logoAlt, }) {
|
|
23
23
|
const brand = usePhiSiteBrand();
|
|
24
24
|
// The Theme's mode, not the Widget's: one picks the Logo's picture, the other what is drawn at all.
|
|
25
25
|
const { fonts, token, mode: themeMode } = usePhiConfig();
|
|
@@ -49,6 +49,7 @@ export function PhiBrandWidgetClient({ config, home, fallbackTitle, interactive
|
|
|
49
49
|
mode: themeMode,
|
|
50
50
|
fallbackTitle,
|
|
51
51
|
shows: config?.mode ?? "lockup",
|
|
52
|
+
logoAlt,
|
|
52
53
|
};
|
|
53
54
|
if (phiBrandControlIsEmpty(presentation)) {
|
|
54
55
|
return null;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
3
|
+
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
4
|
+
import { tr, trForLocale, trGlobal, trGlobalForLocale } from "../../../../../server-helpers/translate";
|
|
2
5
|
import { resolvePhiBrandWordmarkText } from "../../../../../helpers/brand-wordmark";
|
|
3
6
|
import { resolvePhiBrandWidgetHome } from "./home";
|
|
4
7
|
import { PhiBrandWidget } from "./server";
|
|
@@ -12,9 +15,27 @@ import { PHI_BRAND_WIDGET_DEFINITION, PHI_BRAND_WIDGET_PLUGIN_TYPE, } from "./co
|
|
|
12
15
|
* while the Site's own changed underneath it. `resolvePhiBrandWordmarkText` is the same order the rest
|
|
13
16
|
* of the frame reads it in: the Theme's Wordmark, then the Site's name, then its key.
|
|
14
17
|
*/
|
|
18
|
+
/** The Logo's default description: the platform's words, from the global store. */
|
|
19
|
+
const PHI_BRAND_LOGO_ALT_DEFAULT = "Brand logo";
|
|
20
|
+
/*
|
|
21
|
+
* What a screen reader says for the Logo, in the page's language like every other word on it. The
|
|
22
|
+
* Theme's own text is the Site's and is translated in the Site's store; where the Theme says nothing,
|
|
23
|
+
* the default is the platform's. A Widget marked not to translate keeps the Theme's text as written.
|
|
24
|
+
*/
|
|
25
|
+
async function translatePhiBrandLogoAlt(runtime, widget) {
|
|
26
|
+
const own = runtime.site.theme?.brand?.logoAlt?.trim();
|
|
27
|
+
if (hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate)) {
|
|
28
|
+
return own || undefined;
|
|
29
|
+
}
|
|
30
|
+
const locale = runtime.locale.current;
|
|
31
|
+
if (own) {
|
|
32
|
+
return locale ? trForLocale(locale, own) : tr(own);
|
|
33
|
+
}
|
|
34
|
+
return locale ? trGlobalForLocale(locale, PHI_BRAND_LOGO_ALT_DEFAULT) : trGlobal(PHI_BRAND_LOGO_ALT_DEFAULT);
|
|
35
|
+
}
|
|
15
36
|
export const PHI_BRAND_WIDGET_PLUGIN = {
|
|
16
37
|
...PHI_BRAND_WIDGET_DEFINITION,
|
|
17
|
-
render: ({ widget, config, runtime, links }) => (_jsx(PhiBrandWidget, { fallbackTitle: resolvePhiBrandWordmarkText(runtime), home: resolvePhiBrandWidgetHome(runtime, links), mode: config.mode, fontFamily: config.fontFamily, fontSize: config.fontSize }, `widget-${widget.id}`)),
|
|
18
|
-
renderPreview: ({ widget, config, runtime, links }) => (_jsx(PhiBrandWidget, { fallbackTitle: resolvePhiBrandWordmarkText(runtime), home: resolvePhiBrandWidgetHome(runtime, links), mode: config.mode, fontFamily: config.fontFamily, fontSize: config.fontSize, interactive: false }, `widget-${widget.id}`)),
|
|
38
|
+
render: async ({ widget, config, runtime, links }) => (_jsx(PhiBrandWidget, { fallbackTitle: resolvePhiBrandWordmarkText(runtime), home: resolvePhiBrandWidgetHome(runtime, links), logoAlt: await translatePhiBrandLogoAlt(runtime, widget), mode: config.mode, fontFamily: config.fontFamily, fontSize: config.fontSize }, `widget-${widget.id}`)),
|
|
39
|
+
renderPreview: async ({ widget, config, runtime, links }) => (_jsx(PhiBrandWidget, { fallbackTitle: resolvePhiBrandWordmarkText(runtime), home: resolvePhiBrandWidgetHome(runtime, links), logoAlt: await translatePhiBrandLogoAlt(runtime, widget), mode: config.mode, fontFamily: config.fontFamily, fontSize: config.fontSize, interactive: false }, `widget-${widget.id}`)),
|
|
19
40
|
};
|
|
20
41
|
export { PHI_BRAND_WIDGET_PLUGIN_TYPE };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PhiBrandWidgetClientProps, PhiBrandWidgetConfig } from "./client";
|
|
2
|
-
export type PhiBrandWidgetProps = Pick<PhiBrandWidgetClientProps, "fallbackTitle" | "interactive" | "home"> & PhiBrandWidgetConfig;
|
|
3
|
-
export declare function PhiBrandWidget({ fallbackTitle, interactive, home, mode, fontFamily, fontSize, }: PhiBrandWidgetProps): import("react").JSX.Element;
|
|
2
|
+
export type PhiBrandWidgetProps = Pick<PhiBrandWidgetClientProps, "fallbackTitle" | "interactive" | "home" | "logoAlt"> & PhiBrandWidgetConfig;
|
|
3
|
+
export declare function PhiBrandWidget({ fallbackTitle, interactive, home, logoAlt, mode, fontFamily, fontSize, }: PhiBrandWidgetProps): import("react").JSX.Element;
|
|
@@ -5,12 +5,13 @@ import { PhiRuntimeModuleRenderClientHost } from "../../../../../components/runt
|
|
|
5
5
|
* The Brand itself is not read here. It comes from the root on the Client (`usePhiSiteBrand`), which
|
|
6
6
|
* holds it with the Theme Set's Logo folded in and follows a live Theme draft.
|
|
7
7
|
*/
|
|
8
|
-
export function PhiBrandWidget({ fallbackTitle, interactive, home, mode, fontFamily, fontSize, }) {
|
|
8
|
+
export function PhiBrandWidget({ fallbackTitle, interactive, home, logoAlt, mode, fontFamily, fontSize, }) {
|
|
9
9
|
const config = { mode, fontFamily, fontSize };
|
|
10
10
|
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Brand, componentProps: {
|
|
11
11
|
config,
|
|
12
12
|
fallbackTitle,
|
|
13
13
|
home,
|
|
14
14
|
interactive,
|
|
15
|
+
...(logoAlt ? { logoAlt } : {}),
|
|
15
16
|
} }));
|
|
16
17
|
}
|
|
@@ -20,6 +20,10 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
|
|
|
20
20
|
const defaultLabels = actionEnabled ? await getPhiCardWidgetLabelsForRuntime(runtime) : null;
|
|
21
21
|
const ownActionLabel = labels.actionLabel ?? config?.actionLabel;
|
|
22
22
|
const plan = config?.body === "plan";
|
|
23
|
+
// Resolved before the words, because the picture's description is one of them.
|
|
24
|
+
const resolvedAsset = config?.sourceKind === "asset" && typeof config.assetId === "number"
|
|
25
|
+
? await resolvePhiPublicAssetReference({ runtime, assetId: config.assetId }).catch(() => null)
|
|
26
|
+
: null;
|
|
23
27
|
const textEntries = [
|
|
24
28
|
["eyebrow", labels.eyebrow ?? config?.eyebrow],
|
|
25
29
|
["title", labels.title ?? config?.title],
|
|
@@ -29,6 +33,8 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
|
|
|
29
33
|
["badge", labels.badge ?? config?.badge],
|
|
30
34
|
["pricePeriod", plan ? labels.pricePeriod ?? config?.pricePeriod : undefined],
|
|
31
35
|
["pricePeriodYearly", plan ? labels.pricePeriodYearly ?? config?.pricePeriodYearly : undefined],
|
|
36
|
+
// What a screen reader says for the picture, in the page's language like every other word here.
|
|
37
|
+
["alt", (config?.alt ?? resolvedAsset?.altText ?? "").trim() || undefined],
|
|
32
38
|
];
|
|
33
39
|
/*
|
|
34
40
|
* A plan's features, masked as every list entry is: their values stand as `%1` onwards and never reach
|
|
@@ -55,9 +61,6 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
|
|
|
55
61
|
* lose its title's translation with it.
|
|
56
62
|
*/
|
|
57
63
|
const value = config?.value;
|
|
58
|
-
const resolvedAsset = config?.sourceKind === "asset" && typeof config.assetId === "number"
|
|
59
|
-
? await resolvePhiPublicAssetReference({ runtime, assetId: config.assetId }).catch(() => null)
|
|
60
|
-
: null;
|
|
61
64
|
const presentation = resolvePhiImagePresentation({
|
|
62
65
|
sourceKind: config?.sourceKind,
|
|
63
66
|
assetId: resolvedAsset?.id,
|
|
@@ -88,7 +91,7 @@ export async function PhiCardWidget({ labels, config, runtime, links, translate,
|
|
|
88
91
|
...(config?.imageOpacity == null ? {} : { opacity: config.imageOpacity / 100 }),
|
|
89
92
|
...(config?.imageOverlay ? { overlay: config.imageOverlay } : {}),
|
|
90
93
|
source: config?.sourceKind === "asset" ? "asset" : "url",
|
|
91
|
-
alt: (
|
|
94
|
+
alt: translatedByKey.get("alt") ?? "",
|
|
92
95
|
blurDataUrl: resolvedAsset?.blurDataUrl ?? null,
|
|
93
96
|
/*
|
|
94
97
|
* Only a public Asset resolves here, so the optimiser takes every variant, and every original
|
|
@@ -27,6 +27,7 @@ import { PHI_ASSET_CONTROLLER_STORE_KEY } from "../../../../../components/media/
|
|
|
27
27
|
import { applyPhiAssetCollectionData } from "../../../../../components/media/asset-collection-runtime";
|
|
28
28
|
import { readPhiMediaAssetTiles, readPhiMediaFolders } from "../../../../../components/media/phi-image-preview-data";
|
|
29
29
|
import { PhiAssetFolderControl } from "../../../../../components/media/phi-asset-folder-control";
|
|
30
|
+
import { isPhiMediaFolderIdLocked, isPhiMediaFolderLockedError, } from "../../../../../components/media/media-folder-lock";
|
|
30
31
|
import { PhiAreaUploadBinding } from "../../../../../components/media/phi-area-upload-widget";
|
|
31
32
|
import { PHI_MEDIA_WIDGET_DEFAULT_LABELS } from "../../../../../components/media/media-widget-labels";
|
|
32
33
|
import { setPhiImagePreviewSelection, usePhiImagePreviewStore } from "../../../../../components/media/phi-image-preview-store";
|
|
@@ -109,6 +110,7 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
|
|
|
109
110
|
* dropped in a `finally`, so a refusal clears it as surely as a success does.
|
|
110
111
|
*/
|
|
111
112
|
const [deletingAssetIds, setDeletingAssetIds] = useState([]);
|
|
113
|
+
const [folderLockPending, setFolderLockPending] = useState(false);
|
|
112
114
|
const spaceSelectionAllowed = usePhiMediaSpaceSelectionAllowed();
|
|
113
115
|
const activeSpaceAddress = typeof query.filters?.spaceId === "string" && query.filters.spaceId
|
|
114
116
|
? query.filters.spaceId
|
|
@@ -126,8 +128,15 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
|
|
|
126
128
|
...(features.actions?.toolbar ?? []),
|
|
127
129
|
...(features.filters ?? []).flatMap((filter) => filter.actions ?? []),
|
|
128
130
|
];
|
|
129
|
-
const unsupportedAction = configuredActions.find((action) => action.key !== "upload" && action.key !== "createFolder");
|
|
130
|
-
const folderOptions = useMemo(() => buildPhiMediaFolderCascaderOptions(state.folders), [state.folders]);
|
|
131
|
+
const unsupportedAction = configuredActions.find((action) => action.key !== "upload" && action.key !== "createFolder" && action.key !== "lockFolder");
|
|
132
|
+
const folderOptions = useMemo(() => buildPhiMediaFolderCascaderOptions(state.folders, { lockedLabel: labels.tool.folderLockedLabel }), [labels.tool.folderLockedLabel, state.folders]);
|
|
133
|
+
/*
|
|
134
|
+
* The Folder the listing is filtered to, locked: Core refuses a new Folder in it, an upload into it and
|
|
135
|
+
* a delete from it, so none of the three is offered while it is chosen. An Asset's own delete reads its
|
|
136
|
+
* own Folder, because a listing without a Folder filter shows Assets from many.
|
|
137
|
+
*/
|
|
138
|
+
const currentFolder = state.folderId == null ? null : state.folders.find((folder) => folder.id === state.folderId) ?? null;
|
|
139
|
+
const currentFolderLocked = isPhiMediaFolderIdLocked(state.folders, state.folderId);
|
|
131
140
|
const folderValue = useMemo(() => buildPhiMediaFolderValueById(state.folders, state.folderId), [state.folderId, state.folders]);
|
|
132
141
|
const selectionSignals = usePhiControlSignalController({
|
|
133
142
|
key: "assetSelection",
|
|
@@ -151,6 +160,36 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
|
|
|
151
160
|
? `Asset collection filter "${unsupportedFilter.key}" is not supported.`
|
|
152
161
|
: `Asset collection action "${unsupportedAction?.key ?? "unknown"}" is not supported.` }));
|
|
153
162
|
}
|
|
163
|
+
function readActionFailure(error, fallback) {
|
|
164
|
+
if (isPhiMediaFolderLockedError(error))
|
|
165
|
+
return labels.tool.folderLockedText;
|
|
166
|
+
return error instanceof Error ? error.message : fallback;
|
|
167
|
+
}
|
|
168
|
+
async function toggleFolderLock() {
|
|
169
|
+
if (!currentFolder || folderLockPending)
|
|
170
|
+
return;
|
|
171
|
+
setFolderLockPending(true);
|
|
172
|
+
try {
|
|
173
|
+
const data = await binding.activate({
|
|
174
|
+
actionKey: currentFolderLocked ? "unlockFolder" : "lockFolder",
|
|
175
|
+
itemKey: currentFolder.id,
|
|
176
|
+
item: { flags: currentFolder.flags },
|
|
177
|
+
query,
|
|
178
|
+
});
|
|
179
|
+
if (data.error)
|
|
180
|
+
throw new Error(data.error);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
showMessage({
|
|
184
|
+
level: "error",
|
|
185
|
+
content: isPhiMediaFolderLockedError(error) ? labels.tool.folderLockedText : labels.tool.folderLockFailedText,
|
|
186
|
+
durationSeconds: 2.8,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
setFolderLockPending(false);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
154
193
|
async function deleteAsset(asset) {
|
|
155
194
|
setDeletingAssetIds((current) => current.includes(asset.id) ? current : [...current, asset.id]);
|
|
156
195
|
try {
|
|
@@ -166,7 +205,7 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
|
|
|
166
205
|
catch (error) {
|
|
167
206
|
showMessage({
|
|
168
207
|
level: "error",
|
|
169
|
-
content: error
|
|
208
|
+
content: readActionFailure(error, labels.grid.deleteFailedText),
|
|
170
209
|
durationSeconds: 2.8,
|
|
171
210
|
});
|
|
172
211
|
}
|
|
@@ -227,7 +266,14 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
|
|
|
227
266
|
}
|
|
228
267
|
if (filter.key === "folderId" && filter.control === "cascader") {
|
|
229
268
|
const createAction = filter.actions?.find((action) => action.key === "createFolder");
|
|
230
|
-
|
|
269
|
+
const lockAction = filter.actions?.find((action) => action.key === "lockFolder");
|
|
270
|
+
return (_jsx(PhiAssetFolderControl, { value: folderValue, options: folderOptions, placeholder: filter.placeholder ?? labels.tool.folderLabel, allowClear: true, showCreate: Boolean(createAction), createLabel: createAction?.label ?? labels.tool.createFolderLabel, createDisabled: currentFolderLocked, lock: lockAction && currentFolder ? {
|
|
271
|
+
locked: currentFolderLocked,
|
|
272
|
+
lockLabel: labels.tool.lockFolderLabel,
|
|
273
|
+
unlockLabel: labels.tool.unlockFolderLabel,
|
|
274
|
+
pending: folderLockPending,
|
|
275
|
+
onToggle: () => { void toggleFolderLock(); },
|
|
276
|
+
} : null, size: controlSize, style: { ...style, minWidth: style.minWidth ?? 140 }, onCreate: () => actionSignals.emitCapability("actionActivate", {
|
|
231
277
|
actionKey: "createFolder",
|
|
232
278
|
query,
|
|
233
279
|
}), onChange: (value) => binding.setQuery((current) => ({
|
|
@@ -244,7 +290,7 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
|
|
|
244
290
|
const toolbar = selfContained && ((features.actions?.toolbar?.length ?? 0) > 0 || features.tools.reset || features.tools.reload) ? (_jsxs(PhiToolbarControl, { compact: true, size: controlSize, children: [(features.actions?.toolbar ?? []).map((action) => {
|
|
245
291
|
const display = action.display ?? "icon";
|
|
246
292
|
const label = action.label ?? (action.key === "upload" ? labels.tool.uploadToggleLabel : action.key);
|
|
247
|
-
return (_jsx(PhiButtonControl, { label: display === "icon" ? undefined : label, ariaLabel: label, tooltip: action.description, icon: display === "label" || !action.icon ? undefined : resolvePhiButtonIcon(action.icon), type: action.mode === "primary" ? "primary" : "default", danger: action.mode === "danger", size: controlSize, onClick: action.key === "upload" ? () => binding.setOpenPanelKey(state.uploadPanelOpen ? null : "upload") : undefined }, action.key));
|
|
293
|
+
return (_jsx(PhiButtonControl, { label: display === "icon" ? undefined : label, ariaLabel: label, tooltip: action.description, icon: display === "label" || !action.icon ? undefined : resolvePhiButtonIcon(action.icon), type: action.mode === "primary" ? "primary" : "default", danger: action.mode === "danger", size: controlSize, disabled: action.key === "upload" && currentFolderLocked, onClick: action.key === "upload" ? () => binding.setOpenPanelKey(state.uploadPanelOpen ? null : "upload") : undefined }, action.key));
|
|
248
294
|
}), features.tools.reset ? (_jsx(PhiButtonControl, { ariaLabel: labels.tool.resetLabel, tooltip: labels.tool.resetLabel, icon: resolvePhiButtonIcon("antd:rollback-outlined"), size: controlSize, onClick: () => binding.setQuery({
|
|
249
295
|
...(config.initialQuery ?? {}),
|
|
250
296
|
page: config.initialQuery?.page ?? 1,
|
|
@@ -264,7 +310,7 @@ export function PhiAssetCollectionViewBinding({ config, binding, labels: rawLabe
|
|
|
264
310
|
* Only what an action left behind reaches this: a failed read of the source ends the Collection
|
|
265
311
|
* View before this renderer is drawn. A refusal is the acting person's to read, live or not.
|
|
266
312
|
*/
|
|
267
|
-
diagnostics: state.error ? _jsx(PhiAlertControl, { level: "error", showIcon: true, title: state.error }) : null, body: body, items: state.assets.map((asset) => (_jsx(PhiMediaAssetTileControl, { asset: asset, minColumnWidth: minColumnWidth, selected: state.selectedAssetId === asset.id, mode: mode, deleting: deletingAssetIds.includes(asset.id), onSelect: selectAsset, onDelete: (nextAsset) => { void deleteAsset(nextAsset); }, deleteLabel: labels.grid.deleteLabel, showTypeLabel: true, showDeleteAction:
|
|
313
|
+
diagnostics: state.error ? (_jsx(PhiAlertControl, { level: "error", showIcon: true, title: state.error })) : currentFolderLocked ? (_jsx(PhiAlertControl, { level: "info", showIcon: true, title: labels.tool.folderLockedText })) : null, body: body, items: state.assets.map((asset) => (_jsx(PhiMediaAssetTileControl, { asset: asset, minColumnWidth: minColumnWidth, selected: state.selectedAssetId === asset.id, mode: mode, deleting: deletingAssetIds.includes(asset.id), onSelect: selectAsset, onDelete: (nextAsset) => { void deleteAsset(nextAsset); }, deleteLabel: labels.grid.deleteLabel, showTypeLabel: true, showDeleteAction: !isPhiMediaFolderIdLocked(state.folders, asset.folderId), showDimensions: true, showIdLabel: true }, asset.id))), mode: mode, gap: gap, minColumnWidth: minColumnWidth, pagination: features.pagination?.enabled === false ? null : {
|
|
268
314
|
page: state.page,
|
|
269
315
|
pageSize: state.pageSize,
|
|
270
316
|
total: state.pagination?.total ?? 0,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { definePhiPassiveWidgetRenderers } from "../../../../../plugins/factories/widget-renderers";
|
|
3
|
+
import { PhiCmsFlags } from "../../../../../constants/phi-cms";
|
|
4
|
+
import { hasPhiFlag } from "../../../../../helpers/flags";
|
|
3
5
|
import { PHI_GALLERY_WIDGET_DEFINITION, } from "./config";
|
|
4
6
|
import { PhiGalleryWidgetServer } from "./server";
|
|
5
7
|
export const PHI_GALLERY_WIDGET_PLUGIN = {
|
|
6
8
|
...PHI_GALLERY_WIDGET_DEFINITION,
|
|
7
|
-
...definePhiPassiveWidgetRenderers(({ widget, runtime, registry, config }) => (_jsx(PhiGalleryWidgetServer, { runtime: runtime, registry: registry, config: config, widgetId: widget.id }, `widget-${widget.id}`))),
|
|
9
|
+
...definePhiPassiveWidgetRenderers(({ widget, runtime, registry, config }) => (_jsx(PhiGalleryWidgetServer, { runtime: runtime, registry: registry, config: config, widgetId: widget.id, translate: !hasPhiFlag(widget.flags, PhiCmsFlags.NoTranslate) }, `widget-${widget.id}`))),
|
|
8
10
|
};
|
|
@@ -9,6 +9,8 @@ export type PhiGalleryWidgetServerProps = {
|
|
|
9
9
|
registry?: Pick<PhiCmsRuntimeRenderRegistry, "recordProviderLoadersByKey">;
|
|
10
10
|
config: PhiCmsGalleryWidgetConfig;
|
|
11
11
|
widgetId?: PhiCmsInstanceId | null;
|
|
12
|
+
/** Whether the pictures' descriptions go through the Site's translation; off where the Widget says so. */
|
|
13
|
+
translate?: boolean;
|
|
12
14
|
};
|
|
13
15
|
/**
|
|
14
16
|
* The pictures come from the record the binding names -- a Folder, read while the page is drawn -- so
|
|
@@ -16,4 +18,4 @@ export type PhiGalleryWidgetServerProps = {
|
|
|
16
18
|
* another shape is somebody else's Provider bound here by mistake. Either failure is the author's to
|
|
17
19
|
* read and is nothing on a live page, rather than an empty gallery anywhere.
|
|
18
20
|
*/
|
|
19
|
-
export declare function PhiGalleryWidgetServer({ runtime, registry, config, widgetId }: PhiGalleryWidgetServerProps): Promise<import("react").JSX.Element | null>;
|
|
21
|
+
export declare function PhiGalleryWidgetServer({ runtime, registry, config, widgetId, translate }: PhiGalleryWidgetServerProps): Promise<import("react").JSX.Element | null>;
|
|
@@ -5,6 +5,7 @@ import { getPhiGalleryWidgetLabels } from "../../../../../components/widgets/lab
|
|
|
5
5
|
import { PhiWidgetFailureServer } from "../../../../../components/widgets/shared/widget-failure.server";
|
|
6
6
|
import { PhiCmsWidgetType } from "../../../../../constants/cms-widget-types";
|
|
7
7
|
import { resolvePhiRecordSource } from "../../../../../server-helpers/record-source";
|
|
8
|
+
import { trBulk, trBulkForLocale } from "../../../../../server-helpers/translate";
|
|
8
9
|
import { readPhiRuntimeTreeRenderMode } from "../../../render-mode";
|
|
9
10
|
import { buildPhiWidgetLabelTranslatorOptions } from "../../../../../components/widgets/label-sets/runtime-options";
|
|
10
11
|
function isPublicAssetReference(value) {
|
|
@@ -18,7 +19,7 @@ function isPublicAssetReference(value) {
|
|
|
18
19
|
* another shape is somebody else's Provider bound here by mistake. Either failure is the author's to
|
|
19
20
|
* read and is nothing on a live page, rather than an empty gallery anywhere.
|
|
20
21
|
*/
|
|
21
|
-
export async function PhiGalleryWidgetServer({ runtime, registry, config, widgetId }) {
|
|
22
|
+
export async function PhiGalleryWidgetServer({ runtime, registry, config, widgetId, translate = true }) {
|
|
22
23
|
const labels = await getPhiGalleryWidgetLabels(buildPhiWidgetLabelTranslatorOptions(runtime));
|
|
23
24
|
const renderMode = readPhiRuntimeTreeRenderMode(config);
|
|
24
25
|
const result = registry && config.source
|
|
@@ -36,5 +37,14 @@ export async function PhiGalleryWidgetServer({ runtime, registry, config, widget
|
|
|
36
37
|
if (!images || images.length === 0) {
|
|
37
38
|
return null;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
/*
|
|
41
|
+
* Each picture's description from the Media library, in the page's language: the Library's text is
|
|
42
|
+
* the Site's and is translated in the Site's store, in one round trip for the whole gallery.
|
|
43
|
+
*/
|
|
44
|
+
const altTexts = images.map((image) => (image.altText ?? "").trim());
|
|
45
|
+
const translatedAlts = translate && altTexts.some(Boolean)
|
|
46
|
+
? await (runtime.locale.current ? trBulkForLocale(runtime.locale.current, altTexts) : trBulk(altTexts))
|
|
47
|
+
: altTexts;
|
|
48
|
+
const translatedImages = images.map((image, index) => (translatedAlts[index] ? { ...image, altText: translatedAlts[index] } : image));
|
|
49
|
+
return (_jsx(PhiRuntimeModuleRenderClientHost, { type: PhiCmsWidgetType.Gallery, componentProps: { config, images: translatedImages, labels } }));
|
|
40
50
|
}
|