@phis/ui 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +9 -2
  2. package/components/controls/phi-table-control.js +3 -3
  3. package/components/media/media-upload-flow.d.ts +62 -5
  4. package/components/media/media-upload-flow.js +62 -24
  5. package/components/media/phi-area-upload-widget.d.ts +44 -1
  6. package/components/media/phi-area-upload-widget.js +32 -7
  7. package/components/media/phi-media-upload.d.ts +10 -3
  8. package/components/media/phi-media-upload.js +11 -8
  9. package/components/shell/phi-widget-icon.js +1 -0
  10. package/components/widgets/client/html-editor-link-node.d.ts +12 -0
  11. package/components/widgets/client/html-editor-link-node.js +60 -0
  12. package/components/widgets/client/html-editor.js +10 -6
  13. package/components/widgets/client/shared/phi-collection-view-binding.js +33 -26
  14. package/constants/cms-widget-types.d.ts +1 -0
  15. package/constants/cms-widget-types.js +3 -0
  16. package/constants/runtime-module-ownership.js +1 -0
  17. package/gateway/site-proxy.d.ts +12 -0
  18. package/gateway/site-proxy.js +20 -0
  19. package/net/phi-next-proxy.d.ts +7 -0
  20. package/net/phi-next-proxy.js +1 -1
  21. package/package.json +27 -14
  22. package/plugins/runtime-modules/area-contributions/admin.d.ts +1 -1
  23. package/plugins/runtime-modules/area-contributions/admin.js +2 -0
  24. package/plugins/runtime-modules/avatar/addresses.d.ts +1 -1
  25. package/plugins/runtime-modules/cdn/authoring-widgets.d.ts +3 -0
  26. package/plugins/runtime-modules/cdn/authoring-widgets.js +7 -0
  27. package/plugins/runtime-modules/cdn/authoring.d.ts +1 -0
  28. package/plugins/runtime-modules/cdn/authoring.js +8 -0
  29. package/plugins/runtime-modules/cdn/bytes.d.ts +5 -0
  30. package/plugins/runtime-modules/cdn/bytes.js +17 -0
  31. package/plugins/runtime-modules/cdn/client-data-providers.d.ts +7 -0
  32. package/plugins/runtime-modules/cdn/client-data-providers.js +9 -0
  33. package/plugins/runtime-modules/cdn/data-providers.d.ts +134 -0
  34. package/plugins/runtime-modules/cdn/data-providers.js +117 -0
  35. package/plugins/runtime-modules/cdn/definition.d.ts +140 -0
  36. package/plugins/runtime-modules/cdn/definition.js +23 -0
  37. package/plugins/runtime-modules/cdn/ids.d.ts +18 -0
  38. package/plugins/runtime-modules/cdn/ids.js +20 -0
  39. package/plugins/runtime-modules/cdn/module.d.ts +131 -0
  40. package/plugins/runtime-modules/cdn/module.js +4 -0
  41. package/plugins/runtime-modules/cdn/platform.d.ts +25 -0
  42. package/plugins/runtime-modules/cdn/platform.js +73 -0
  43. package/plugins/runtime-modules/cdn/presets.d.ts +2 -0
  44. package/plugins/runtime-modules/cdn/presets.js +20 -0
  45. package/plugins/runtime-modules/cdn/server.d.ts +1 -0
  46. package/plugins/runtime-modules/cdn/server.js +14 -0
  47. package/plugins/runtime-modules/cdn/services/table.d.ts +11 -0
  48. package/plugins/runtime-modules/cdn/services/table.js +296 -0
  49. package/plugins/runtime-modules/cdn/services/upload.d.ts +20 -0
  50. package/plugins/runtime-modules/cdn/services/upload.js +146 -0
  51. package/plugins/runtime-modules/cdn/table-params.d.ts +10 -0
  52. package/plugins/runtime-modules/cdn/table-params.js +10 -0
  53. package/plugins/runtime-modules/cdn/trees/admin-cdn-label-set.d.ts +95 -0
  54. package/plugins/runtime-modules/cdn/trees/admin-cdn-label-set.js +156 -0
  55. package/plugins/runtime-modules/cdn/trees/phi-default-admin-cdn-page-tree.d.ts +18 -0
  56. package/plugins/runtime-modules/cdn/trees/phi-default-admin-cdn-page-tree.js +479 -0
  57. package/plugins/runtime-modules/cdn/widgets/upload/client.d.ts +12 -0
  58. package/plugins/runtime-modules/cdn/widgets/upload/client.js +138 -0
  59. package/plugins/runtime-modules/cdn/widgets/upload/config.d.ts +29 -0
  60. package/plugins/runtime-modules/cdn/widgets/upload/config.js +43 -0
  61. package/plugins/runtime-modules/cdn/widgets/upload/label-types.d.ts +24 -0
  62. package/plugins/runtime-modules/cdn/widgets/upload/label-types.js +1 -0
  63. package/plugins/runtime-modules/cdn/widgets/upload/labels.d.ts +4 -0
  64. package/plugins/runtime-modules/cdn/widgets/upload/labels.js +72 -0
  65. package/plugins/runtime-modules/cdn/widgets/upload/plugin.d.ts +3 -0
  66. package/plugins/runtime-modules/cdn/widgets/upload/plugin.js +7 -0
  67. package/plugins/runtime-modules/cdn/widgets/upload/server.d.ts +8 -0
  68. package/plugins/runtime-modules/cdn/widgets/upload/server.js +17 -0
  69. package/plugins/runtime-modules/cdn/widgets.d.ts +2 -0
  70. package/plugins/runtime-modules/cdn/widgets.js +13 -0
  71. package/plugins/runtime-modules/client-authoring-providers/admin.d.ts +1 -1
  72. package/plugins/runtime-modules/client-authoring-providers/admin.js +6 -0
  73. package/plugins/runtime-modules/client-manifests/admin.js +11 -1
  74. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +1 -1
  75. package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.js +3 -1
  76. package/plugins/runtime-modules/core/widgets/table/client.js +6 -4
  77. package/types/table-widget.d.ts +2 -2
@@ -0,0 +1,156 @@
1
+ import "server-only";
2
+ import { PHI_TR_CTX_WEB_UI_LABEL } from "../../../../gateway/tr";
3
+ import { definePhiRuntimeModuleLabelSet, definePhiMessageLabel, getPhiLabelSet } from "../../../../gateway/label-set";
4
+ import { PHI_CDN_ADMIN_PAGE_PRESET_KEY, PHI_CDN_RUNTIME_MODULE_IDENTITY } from "../ids";
5
+ /** The words of the Admin page `CDN`, in English, the Module's source language. */
6
+ const PHI_ADMIN_CDN_PAGE_LABEL_SET = definePhiRuntimeModuleLabelSet(PHI_CDN_RUNTIME_MODULE_IDENTITY, {
7
+ key: `preset:${PHI_CDN_ADMIN_PAGE_PRESET_KEY}`,
8
+ ctx: PHI_TR_CTX_WEB_UI_LABEL,
9
+ labels: {
10
+ page_title: "CDN",
11
+ page_description: definePhiMessageLabel("Files published once under the Site's name and served from its CDN host."),
12
+ table_label: "CDN files",
13
+ column_name: "Name",
14
+ column_version: "Version",
15
+ column_file: "File",
16
+ column_size: "Size",
17
+ column_storage: "Storage",
18
+ column_storage_hint: definePhiMessageLabel("Copy: the CDN serves the bytes. Link: the source keeps them, and the Site sends visitors there."),
19
+ column_platform: "Platform",
20
+ column_sha256: "SHA-256",
21
+ column_sha256_hint: definePhiMessageLabel("Shortened here; copying the cell copies the whole checksum."),
22
+ column_state: "State",
23
+ column_origin: "Origin",
24
+ column_published: "Published",
25
+ storage_cdn: "Copy",
26
+ storage_link: "Link",
27
+ state_offered: "Offered",
28
+ state_withdrawn: "Withdrawn",
29
+ state_deleted: "Deleted",
30
+ origin_cli: "CLI",
31
+ origin_upload: "Upload",
32
+ origin_addon: "Add-on",
33
+ filter_state: "State",
34
+ filter_state_all: "All",
35
+ search_placeholder: "Search names and files",
36
+ empty_title: definePhiMessageLabel("No files published yet."),
37
+ empty_text: definePhiMessageLabel("Upload a file, or publish one with phis cdn publish."),
38
+ no_cdn: definePhiMessageLabel("This Site has no CDN yet. The operator attaches one on the server with phis cdn attach; then its files are listed here."),
39
+ footer: definePhiMessageLabel("%1 files of %2 total"),
40
+ action_upload: "Upload",
41
+ action_check: "Check",
42
+ action_view: "Details",
43
+ action_copy: "Copy address",
44
+ action_withdraw: "Withdraw",
45
+ action_delete: "Delete",
46
+ copied: definePhiMessageLabel("Address copied."),
47
+ copy_failed: definePhiMessageLabel("The browser did not allow copying the address."),
48
+ confirm_cancel: "Cancel",
49
+ withdraw_title: definePhiMessageLabel("Withdraw this file?"),
50
+ withdraw_text: definePhiMessageLabel("It is no longer offered: download pages stop listing it. The key stays taken, so nothing else can be published under it."),
51
+ withdraw_ok: "Withdraw",
52
+ delete_title: definePhiMessageLabel("Delete this file?"),
53
+ delete_text: definePhiMessageLabel("It is withdrawn and its bytes are removed from the CDN bucket. The key stays taken: no other file can ever be published under it. A cache may still serve the file until its copy expires."),
54
+ delete_link_note: definePhiMessageLabel("For a linked file no bytes are deleted: the source keeps them, and the entry is only withdrawn."),
55
+ delete_ok: "Delete",
56
+ upload_title: "Upload a file",
57
+ detail_title: "File details",
58
+ detail_key: "Key",
59
+ detail_url: "Address",
60
+ detail_source_url: "Source address",
61
+ detail_content_type: "Content type",
62
+ detail_size_bytes: "Size in bytes",
63
+ detail_addon: "Add-on",
64
+ detail_actor: "Uploaded by (user id)",
65
+ check_title: "Check bucket and catalogue",
66
+ check_table_label: "Check findings",
67
+ check_column_key: "Key",
68
+ check_column_finding: "Finding",
69
+ check_column_size: "Size in the bucket",
70
+ check_column_recorded: "Size recorded",
71
+ check_column_reason: "Why it cannot be adopted",
72
+ finding_unrecorded: "Not in the catalogue",
73
+ finding_missing: "Missing from the bucket",
74
+ finding_size_mismatch: "Size differs",
75
+ action_adopt: "Adopt",
76
+ check_empty: definePhiMessageLabel("Nothing to report."),
77
+ check_footer: definePhiMessageLabel("%1 objects in the bucket, %2 copied files in the catalogue."),
78
+ check_footer_consistent: definePhiMessageLabel("Bucket and catalogue agree: %1 objects, %2 copied files."),
79
+ },
80
+ });
81
+ export async function getPhiAdminCdnPageLabels(options) {
82
+ const labels = await getPhiLabelSet(options, PHI_ADMIN_CDN_PAGE_LABEL_SET);
83
+ return {
84
+ pageTitle: labels.page_title,
85
+ pageDescription: labels.page_description,
86
+ tableLabel: labels.table_label,
87
+ columns: {
88
+ name: labels.column_name,
89
+ version: labels.column_version,
90
+ file: labels.column_file,
91
+ size: labels.column_size,
92
+ storage: labels.column_storage,
93
+ storageHint: labels.column_storage_hint,
94
+ platform: labels.column_platform,
95
+ sha256: labels.column_sha256,
96
+ sha256Hint: labels.column_sha256_hint,
97
+ state: labels.column_state,
98
+ origin: labels.column_origin,
99
+ published: labels.column_published,
100
+ },
101
+ storage: { cdn: labels.storage_cdn, link: labels.storage_link },
102
+ states: { offered: labels.state_offered, withdrawn: labels.state_withdrawn, deleted: labels.state_deleted },
103
+ origins: { cli: labels.origin_cli, upload: labels.origin_upload, addon: labels.origin_addon },
104
+ filterState: labels.filter_state,
105
+ filterStateAll: labels.filter_state_all,
106
+ searchPlaceholder: labels.search_placeholder,
107
+ emptyTitle: labels.empty_title,
108
+ emptyText: labels.empty_text,
109
+ noCdn: labels.no_cdn,
110
+ footer: labels.footer,
111
+ actions: {
112
+ upload: labels.action_upload,
113
+ check: labels.action_check,
114
+ view: labels.action_view,
115
+ copy: labels.action_copy,
116
+ withdraw: labels.action_withdraw,
117
+ delete: labels.action_delete,
118
+ adopt: labels.action_adopt,
119
+ },
120
+ copied: labels.copied,
121
+ copyFailed: labels.copy_failed,
122
+ confirmCancel: labels.confirm_cancel,
123
+ withdraw: { title: labels.withdraw_title, text: labels.withdraw_text, ok: labels.withdraw_ok },
124
+ delete: { title: labels.delete_title, text: labels.delete_text, linkNote: labels.delete_link_note, ok: labels.delete_ok },
125
+ uploadTitle: labels.upload_title,
126
+ detail: {
127
+ title: labels.detail_title,
128
+ key: labels.detail_key,
129
+ url: labels.detail_url,
130
+ sourceUrl: labels.detail_source_url,
131
+ contentType: labels.detail_content_type,
132
+ sizeBytes: labels.detail_size_bytes,
133
+ addon: labels.detail_addon,
134
+ actor: labels.detail_actor,
135
+ },
136
+ check: {
137
+ title: labels.check_title,
138
+ tableLabel: labels.check_table_label,
139
+ columns: {
140
+ key: labels.check_column_key,
141
+ finding: labels.check_column_finding,
142
+ size: labels.check_column_size,
143
+ recorded: labels.check_column_recorded,
144
+ reason: labels.check_column_reason,
145
+ },
146
+ findings: {
147
+ unrecorded: labels.finding_unrecorded,
148
+ missing: labels.finding_missing,
149
+ "size-mismatch": labels.finding_size_mismatch,
150
+ },
151
+ empty: labels.check_empty,
152
+ footer: labels.check_footer,
153
+ footerConsistent: labels.check_footer_consistent,
154
+ },
155
+ };
156
+ }
@@ -0,0 +1,18 @@
1
+ import type { PhiCmsPageNode, PhiResolvedCmsPageTree } from "../../../../types/cms";
2
+ import type { PhiBlockRuntime } from "../../../../types";
3
+ /**
4
+ * The Admin page `CDN`: the catalogue as one Table, and three dialogs its actions open.
5
+ *
6
+ * - Upload (toolbar): the Module's upload Widget, which tells the Table to read again once a file is
7
+ * published.
8
+ * - Check (toolbar): a second Table on the same Provider, the `check` resource, which runs the check when
9
+ * the dialog opens (`remount`) and adopts what it can, row by row.
10
+ * - Details (row): the `record` Widget on the row, with the addresses in full.
11
+ *
12
+ * Copy address, Withdraw and Delete are the Provider's row actions; the two that change anything ask
13
+ * first. What any of them may do is Core's to decide, and Core refuses what a reader may not.
14
+ */
15
+ export declare function buildPhiDefaultAdminCdnPageTree({ page, runtime, }: {
16
+ page: PhiCmsPageNode;
17
+ runtime: PhiBlockRuntime;
18
+ }): Promise<PhiResolvedCmsPageTree>;
@@ -0,0 +1,479 @@
1
+ import { createPhiPresetCmsInstanceIdMap } from "../../../../types/cms-instance-id";
2
+ import { PHI_CDN_ADMIN_PAGE_PRESET_KEY, PHI_CDN_RUNTIME_DATA_PROVIDER_KEYS, PHI_CDN_RUNTIME_MODULE_ID, PHI_CDN_TABLE_RESOURCE_KEYS, } from "../ids";
3
+ import { PHI_CMS_DEFAULT_SLOT_INDEX } from "../../../../constants/cms-layout-types";
4
+ import { PhiCmsFlags, PhiCmsPageType } from "../../../../constants/phi-cms";
5
+ import { createPhiCmsPresetNodes } from "../../../../helpers/cms-preset-nodes";
6
+ import { buildPhiBasePageContentScaffold, PHI_BASE_PAGE_LAYOUT_NODE_ID } from "../../../../components/regions/presets/phi-base-page-layout";
7
+ import { createPhiSignalAddress, PHI_SIGNAL_VALUE_SCHEMAS } from "../../../../types/signals";
8
+ import { PHI_DIALOG_BODY_CONFIG, PHI_DIALOG_WIDTH_SINGLE_COLUMN } from "../../../../helpers/cms-dialog";
9
+ import { buildPhiWidgetLabelTranslatorOptions } from "../../../../components/widgets/label-sets/runtime-options";
10
+ import { getPhiAdminCdnPageLabels } from "./admin-cdn-label-set";
11
+ import { getPhiCdnUploadWidgetLabels } from "../widgets/upload/labels";
12
+ import { PHI_CDN_TABLE_PARAM_KEYS } from "../table-params";
13
+ const SYNTHETIC_ADMIN_CDN_REGION_IDS = {
14
+ regionContent: -443,
15
+ };
16
+ const PRESET = {
17
+ domain: "page",
18
+ ownerModuleId: PHI_CDN_RUNTIME_MODULE_ID,
19
+ presetKey: PHI_CDN_ADMIN_PAGE_PRESET_KEY,
20
+ };
21
+ const LAYOUT_IDS = createPhiPresetCmsInstanceIdMap(PRESET, ["layoutDetail", "layoutUpload", "layoutCheck"]);
22
+ const OVERLAY_IDS = createPhiPresetCmsInstanceIdMap(PRESET, ["overlayDetail", "overlayUpload", "overlayCheck"]);
23
+ const WIDGET_IDS = createPhiPresetCmsInstanceIdMap(PRESET, ["widgetTable", "widgetDetail", "widgetUpload", "widgetCheck"]);
24
+ /** The Table's announcement of one of its actions, to one receiver that decides by the action's key. */
25
+ function tableActionRoute(routeKey, receiverId) {
26
+ return {
27
+ routeKey,
28
+ capabilityId: "actionActivate",
29
+ scope: "page",
30
+ channel: "action",
31
+ action: "activate",
32
+ valueType: "json",
33
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
34
+ receiver: createPhiSignalAddress("cms", receiverId),
35
+ };
36
+ }
37
+ /**
38
+ * The Admin page `CDN`: the catalogue as one Table, and three dialogs its actions open.
39
+ *
40
+ * - Upload (toolbar): the Module's upload Widget, which tells the Table to read again once a file is
41
+ * published.
42
+ * - Check (toolbar): a second Table on the same Provider, the `check` resource, which runs the check when
43
+ * the dialog opens (`remount`) and adopts what it can, row by row.
44
+ * - Details (row): the `record` Widget on the row, with the addresses in full.
45
+ *
46
+ * Copy address, Withdraw and Delete are the Provider's row actions; the two that change anything ask
47
+ * first. What any of them may do is Core's to decide, and Core refuses what a reader may not.
48
+ */
49
+ export async function buildPhiDefaultAdminCdnPageTree({ page, runtime, }) {
50
+ const translator = buildPhiWidgetLabelTranslatorOptions(runtime);
51
+ const [labels, uploadLabels] = await Promise.all([
52
+ getPhiAdminCdnPageLabels(translator),
53
+ getPhiCdnUploadWidgetLabels(translator),
54
+ ]);
55
+ const tableAddress = createPhiSignalAddress("cms", WIDGET_IDS.widgetTable);
56
+ const platformNames = { ...uploadLabels.osNames, ...uploadLabels.archNames };
57
+ const stateColors = { offered: "success", withdrawn: "warning", deleted: "error" };
58
+ const storageColors = { cdn: "default", link: "processing" };
59
+ const originNames = { cli: labels.origins.cli, upload: labels.origins.upload, addon: labels.origins.addon };
60
+ const source = {
61
+ providerKey: PHI_CDN_RUNTIME_DATA_PROVIDER_KEYS.table,
62
+ resourceKey: PHI_CDN_TABLE_RESOURCE_KEYS.files,
63
+ params: {
64
+ [PHI_CDN_TABLE_PARAM_KEYS.noCdnText]: labels.noCdn,
65
+ [PHI_CDN_TABLE_PARAM_KEYS.copiedText]: labels.copied,
66
+ [PHI_CDN_TABLE_PARAM_KEYS.copyFailedText]: labels.copyFailed,
67
+ },
68
+ };
69
+ const scaffold = buildPhiBasePageContentScaffold({
70
+ page,
71
+ regionId: SYNTHETIC_ADMIN_CDN_REGION_IDS.regionContent,
72
+ });
73
+ const nodes = createPhiCmsPresetNodes(page);
74
+ const upload = nodes.dialog({
75
+ id: OVERLAY_IDS.overlayUpload,
76
+ bodyLayoutNodeId: LAYOUT_IDS.layoutUpload,
77
+ sortOrder: 1,
78
+ label: "cdn upload modal",
79
+ body: { label: "cdn upload modal content" },
80
+ config: {
81
+ title: labels.uploadTitle,
82
+ size: { width: PHI_DIALOG_WIDTH_SINGLE_COLUMN },
83
+ // Closed, the upload stops and its session stays open: the same file picked again resumes it.
84
+ mountPolicy: "remount",
85
+ openActionKey: "upload",
86
+ signalRoutes: { listens: [{
87
+ routeKey: "admin-cdn-upload-modal-open",
88
+ capabilityId: "open",
89
+ scope: "page",
90
+ channel: "action",
91
+ action: "activate",
92
+ valueType: "json",
93
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
94
+ receiver: createPhiSignalAddress("cms", OVERLAY_IDS.overlayUpload),
95
+ }] },
96
+ },
97
+ });
98
+ const check = nodes.dialog({
99
+ id: OVERLAY_IDS.overlayCheck,
100
+ bodyLayoutNodeId: LAYOUT_IDS.layoutCheck,
101
+ sortOrder: 2,
102
+ label: "cdn check modal",
103
+ body: { label: "cdn check modal content" },
104
+ config: {
105
+ title: labels.check.title,
106
+ size: { width: 980 },
107
+ maxSize: { width: "90vw" },
108
+ // Every opening is a new check: the bucket is read when the Table in it mounts.
109
+ mountPolicy: "remount",
110
+ openActionKey: "check",
111
+ signalRoutes: { listens: [{
112
+ routeKey: "admin-cdn-check-modal-open",
113
+ capabilityId: "open",
114
+ scope: "page",
115
+ channel: "action",
116
+ action: "activate",
117
+ valueType: "json",
118
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
119
+ receiver: createPhiSignalAddress("cms", OVERLAY_IDS.overlayCheck),
120
+ }] },
121
+ },
122
+ });
123
+ return {
124
+ page: nodes.page({ pageType: PhiCmsPageType.Standard }),
125
+ pageMeta: {
126
+ title: { msgId: 0, source: "CDN", value: labels.pageTitle },
127
+ description: {
128
+ msgId: 0,
129
+ source: "Files published once under the Site's name and served from its CDN host.",
130
+ value: labels.pageDescription,
131
+ },
132
+ },
133
+ overlays: [
134
+ nodes.overlay({
135
+ id: OVERLAY_IDS.overlayDetail,
136
+ overlayType: "modal",
137
+ bodyLayoutNodeId: LAYOUT_IDS.layoutDetail,
138
+ sortOrder: 0,
139
+ label: "cdn file detail modal",
140
+ config: {
141
+ title: labels.detail.title,
142
+ size: { width: 960 },
143
+ mountPolicy: "lazy-keep",
144
+ openActionKey: "view",
145
+ signalRoutes: {
146
+ emits: [{
147
+ routeKey: "admin-cdn-detail-modal-open-change",
148
+ capabilityId: "openChange",
149
+ scope: "page",
150
+ channel: "state",
151
+ action: "change",
152
+ valueType: "boolean",
153
+ receiver: createPhiSignalAddress("cms", WIDGET_IDS.widgetDetail),
154
+ }],
155
+ listens: [{
156
+ routeKey: "admin-cdn-detail-modal-open",
157
+ capabilityId: "open",
158
+ scope: "page",
159
+ channel: "action",
160
+ action: "activate",
161
+ valueType: "json",
162
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
163
+ receiver: createPhiSignalAddress("cms", OVERLAY_IDS.overlayDetail),
164
+ }],
165
+ },
166
+ },
167
+ }),
168
+ upload.overlay,
169
+ check.overlay,
170
+ ],
171
+ regions: [scaffold.region],
172
+ layoutNodes: [
173
+ scaffold.layoutNode,
174
+ nodes.layout({
175
+ id: LAYOUT_IDS.layoutDetail,
176
+ parentLayoutNodeId: null,
177
+ creationPreset: { layoutKind: "verticalflex", preset: "panel" },
178
+ typeKey: "flex-vertical",
179
+ slotIndex: PHI_CMS_DEFAULT_SLOT_INDEX,
180
+ sortOrder: 0,
181
+ label: "cdn file detail modal content",
182
+ config: {
183
+ ...PHI_DIALOG_BODY_CONFIG,
184
+ anchor: { horizontal: "left", vertical: "top" },
185
+ },
186
+ }),
187
+ ...upload.layouts,
188
+ ...check.layouts,
189
+ ],
190
+ contentWidgets: [
191
+ nodes.widget({
192
+ id: WIDGET_IDS.widgetTable,
193
+ parentLayoutNodeId: PHI_BASE_PAGE_LAYOUT_NODE_ID,
194
+ typeKey: "table",
195
+ slotIndex: PHI_CMS_DEFAULT_SLOT_INDEX,
196
+ sortOrder: 0,
197
+ // The Module's Label Set, translated already.
198
+ flags: PhiCmsFlags.NoTranslate,
199
+ label: labels.tableLabel,
200
+ config: {
201
+ source,
202
+ presentation: {
203
+ // Fixed, so a long file name and the checksum are cut to their columns and said whole on hover.
204
+ layout: { mode: "fixed", overflowX: "auto" },
205
+ columns: [
206
+ { key: "name", fieldKey: "name", title: labels.columns.name, sortable: true, ellipsis: true, sizing: { mode: "fixed", width: 140 }, sticky: "left" },
207
+ { key: "version", fieldKey: "version", title: labels.columns.version, ellipsis: true, sizing: { mode: "fixed", width: 110 } },
208
+ { key: "fileName", fieldKey: "fileName", title: labels.columns.file, ellipsis: true, sizing: { mode: "fill", minWidth: 200 } },
209
+ { key: "size", fieldKey: "sizeLabel", title: labels.columns.size, align: "right", sizing: { mode: "fixed", width: 96 } },
210
+ {
211
+ key: "storage",
212
+ fieldKey: "storage",
213
+ title: labels.columns.storage,
214
+ description: labels.columns.storageHint,
215
+ renderer: "badge",
216
+ valueMap: labels.storage,
217
+ tagColorMap: storageColors,
218
+ sizing: { mode: "fixed", width: 96 },
219
+ },
220
+ {
221
+ key: "platform",
222
+ fieldKey: "platform",
223
+ title: labels.columns.platform,
224
+ renderer: "tags",
225
+ valueMap: platformNames,
226
+ sizing: { mode: "fixed", width: 160 },
227
+ },
228
+ {
229
+ // Cut to the column's width; the cell holds the whole checksum, so copying it copies all of it.
230
+ key: "sha256",
231
+ fieldKey: "sha256",
232
+ title: labels.columns.sha256,
233
+ description: labels.columns.sha256Hint,
234
+ renderer: "code",
235
+ ellipsis: true,
236
+ sizing: { mode: "fixed", width: 120 },
237
+ },
238
+ {
239
+ key: "state",
240
+ fieldKey: "state",
241
+ title: labels.columns.state,
242
+ renderer: "badge",
243
+ valueMap: labels.states,
244
+ tagColorMap: stateColors,
245
+ sizing: { mode: "fixed", width: 116 },
246
+ },
247
+ { key: "origin", fieldKey: "origin", title: labels.columns.origin, valueMap: originNames, ellipsis: true, sizing: { mode: "fixed", width: 140 } },
248
+ { key: "publishedAt", fieldKey: "publishedAt", title: labels.columns.published, renderer: "datetime", sortable: true, sizing: { mode: "fixed", width: 180 } },
249
+ ],
250
+ emptyState: { title: labels.emptyTitle, description: labels.emptyText },
251
+ footer: {
252
+ template: labels.footer,
253
+ values: [
254
+ { key: "rows", value: { source: "core", fieldKey: "pageRows" } },
255
+ { key: "total", value: { source: "core", fieldKey: "totalRows" } },
256
+ ],
257
+ },
258
+ controlSize: "small",
259
+ },
260
+ features: {
261
+ search: { enabled: true, placeholder: labels.searchPlaceholder, debounceMs: 250 },
262
+ filters: [{
263
+ key: "state",
264
+ type: "select",
265
+ label: labels.filterState,
266
+ defaultValue: "offered",
267
+ options: [
268
+ { value: "offered", label: labels.states.offered },
269
+ { value: "withdrawn", label: labels.states.withdrawn },
270
+ { value: "deleted", label: labels.states.deleted },
271
+ { value: "all", label: labels.filterStateAll },
272
+ ],
273
+ }],
274
+ pagination: { enabled: true, pageSize: 50, pageSizes: [50, 100, 200] },
275
+ sorting: { mode: "single", defaultSorts: [{ key: "publishedAt", direction: "descending" }] },
276
+ tools: { mode: "self-contained", reload: true },
277
+ actions: {
278
+ toolbar: [
279
+ { key: "upload", label: labels.actions.upload, icon: "upload", display: "icon", mode: "primary", execution: "signal" },
280
+ { key: "check", label: labels.actions.check, icon: "safety-certificate", display: "icon", execution: "signal" },
281
+ ],
282
+ row: [
283
+ { key: "view", label: labels.actions.view, icon: "eye", display: "icon", execution: "signal" },
284
+ { key: "copy-url", label: labels.actions.copy, icon: "copy", display: "icon", execution: "provider" },
285
+ {
286
+ key: "withdraw",
287
+ label: labels.actions.withdraw,
288
+ icon: "stop",
289
+ display: "icon",
290
+ mode: "danger",
291
+ execution: "provider",
292
+ confirm: {
293
+ title: labels.withdraw.title,
294
+ description: labels.withdraw.text,
295
+ okText: labels.withdraw.ok,
296
+ cancelText: labels.confirmCancel,
297
+ },
298
+ },
299
+ {
300
+ key: "delete",
301
+ label: labels.actions.delete,
302
+ icon: "delete",
303
+ display: "icon",
304
+ mode: "danger",
305
+ execution: "provider",
306
+ confirm: {
307
+ title: labels.delete.title,
308
+ description: labels.delete.text,
309
+ alert: { level: "info", title: labels.delete.linkNote },
310
+ okText: labels.delete.ok,
311
+ cancelText: labels.confirmCancel,
312
+ },
313
+ },
314
+ ],
315
+ },
316
+ },
317
+ signalRoutes: {
318
+ /*
319
+ * One announcement, five listeners: each dialog decides by its `openActionKey`, the record by
320
+ * its own. Copy, Withdraw and Delete are the Provider's and go to nobody.
321
+ */
322
+ emits: [
323
+ tableActionRoute("admin-cdn-table-view-detail", WIDGET_IDS.widgetDetail),
324
+ tableActionRoute("admin-cdn-table-open-detail", OVERLAY_IDS.overlayDetail),
325
+ tableActionRoute("admin-cdn-table-open-upload", OVERLAY_IDS.overlayUpload),
326
+ tableActionRoute("admin-cdn-table-open-check", OVERLAY_IDS.overlayCheck),
327
+ ],
328
+ listens: [{
329
+ routeKey: "admin-cdn-table-reload",
330
+ capabilityId: "reload",
331
+ scope: "page",
332
+ channel: "reload",
333
+ action: "activate",
334
+ valueType: "none",
335
+ receiver: tableAddress,
336
+ }],
337
+ },
338
+ },
339
+ }),
340
+ nodes.widget({
341
+ id: WIDGET_IDS.widgetDetail,
342
+ parentLayoutNodeId: LAYOUT_IDS.layoutDetail,
343
+ typeKey: "record",
344
+ slotIndex: PHI_CMS_DEFAULT_SLOT_INDEX,
345
+ sortOrder: 0,
346
+ flags: PhiCmsFlags.NoTranslate,
347
+ label: "cdn file record",
348
+ config: {
349
+ source: { ...source },
350
+ openActionKey: "view",
351
+ presentation: {
352
+ appearance: "grid",
353
+ columns: 2,
354
+ fields: [
355
+ { key: "key", fieldKey: "key", label: labels.detail.key, renderer: "code", full: true },
356
+ { key: "name", fieldKey: "name", label: labels.columns.name },
357
+ { key: "version", fieldKey: "version", label: labels.columns.version },
358
+ { key: "fileName", fieldKey: "fileName", label: labels.columns.file },
359
+ { key: "size", fieldKey: "sizeLabel", label: labels.columns.size },
360
+ { key: "sizeBytes", fieldKey: "sizeBytes", label: labels.detail.sizeBytes },
361
+ { key: "contentType", fieldKey: "contentType", label: labels.detail.contentType, renderer: "code" },
362
+ { key: "storage", fieldKey: "storage", label: labels.columns.storage, renderer: "badge", valueMap: labels.storage, tagColorMap: storageColors },
363
+ { key: "platform", fieldKey: "platform", label: labels.columns.platform, renderer: "tags", valueMap: platformNames },
364
+ { key: "state", fieldKey: "state", label: labels.columns.state, renderer: "badge", valueMap: labels.states, tagColorMap: stateColors },
365
+ { key: "publishedAt", fieldKey: "publishedAt", label: labels.columns.published, renderer: "datetime" },
366
+ { key: "origin", fieldKey: "origin", label: labels.columns.origin, valueMap: originNames },
367
+ { key: "addonId", fieldKey: "addonId", label: labels.detail.addon },
368
+ { key: "actorUserId", fieldKey: "actorUserId", label: labels.detail.actor },
369
+ { key: "sha256", fieldKey: "sha256", label: labels.columns.sha256, renderer: "code", full: true },
370
+ { key: "url", fieldKey: "url", label: labels.detail.url, renderer: "link", full: true },
371
+ { key: "sourceUrl", fieldKey: "sourceUrl", label: labels.detail.sourceUrl, renderer: "link", full: true },
372
+ ],
373
+ },
374
+ signalRoutes: {
375
+ listens: [{
376
+ routeKey: "admin-cdn-detail-record-open",
377
+ capabilityId: "recordOpen",
378
+ scope: "page",
379
+ channel: "action",
380
+ action: "activate",
381
+ valueType: "json",
382
+ valueSchema: PHI_SIGNAL_VALUE_SCHEMAS.tableAction,
383
+ receiver: createPhiSignalAddress("cms", WIDGET_IDS.widgetDetail),
384
+ }, {
385
+ routeKey: "admin-cdn-detail-modal-closed",
386
+ capabilityId: "close",
387
+ scope: "page",
388
+ channel: "state",
389
+ action: "change",
390
+ valueType: "boolean",
391
+ receiver: createPhiSignalAddress("cms", WIDGET_IDS.widgetDetail),
392
+ }],
393
+ },
394
+ },
395
+ }),
396
+ nodes.widget({
397
+ id: WIDGET_IDS.widgetUpload,
398
+ parentLayoutNodeId: LAYOUT_IDS.layoutUpload,
399
+ typeKey: "cdn-upload",
400
+ slotIndex: PHI_CMS_DEFAULT_SLOT_INDEX,
401
+ sortOrder: 0,
402
+ label: "cdn upload",
403
+ config: {
404
+ signalRoutes: {
405
+ // A published file is a new row: the listing reads itself again.
406
+ emits: [{
407
+ routeKey: "admin-cdn-upload-published",
408
+ capabilityId: "uploaded",
409
+ scope: "page",
410
+ channel: "reload",
411
+ action: "activate",
412
+ valueType: "none",
413
+ receiver: tableAddress,
414
+ }],
415
+ },
416
+ },
417
+ }),
418
+ nodes.widget({
419
+ id: WIDGET_IDS.widgetCheck,
420
+ parentLayoutNodeId: LAYOUT_IDS.layoutCheck,
421
+ typeKey: "table",
422
+ slotIndex: PHI_CMS_DEFAULT_SLOT_INDEX,
423
+ sortOrder: 0,
424
+ flags: PhiCmsFlags.NoTranslate,
425
+ label: labels.check.tableLabel,
426
+ config: {
427
+ source: {
428
+ providerKey: PHI_CDN_RUNTIME_DATA_PROVIDER_KEYS.table,
429
+ resourceKey: PHI_CDN_TABLE_RESOURCE_KEYS.check,
430
+ params: { [PHI_CDN_TABLE_PARAM_KEYS.noCdnText]: labels.noCdn },
431
+ },
432
+ presentation: {
433
+ layout: { mode: "auto", overflowX: "auto" },
434
+ columns: [
435
+ { key: "key", fieldKey: "key", title: labels.check.columns.key, renderer: "code", sizing: { mode: "fill", minWidth: 240 } },
436
+ {
437
+ key: "finding",
438
+ fieldKey: "finding",
439
+ title: labels.check.columns.finding,
440
+ renderer: "badge",
441
+ valueMap: labels.check.findings,
442
+ tagColorMap: { unrecorded: "warning", missing: "error", "size-mismatch": "error" },
443
+ sizing: { mode: "content" },
444
+ },
445
+ { key: "size", fieldKey: "sizeLabel", title: labels.check.columns.size, align: "right", sizing: { mode: "content" } },
446
+ { key: "recorded", fieldKey: "recordedLabel", title: labels.check.columns.recorded, align: "right", sizing: { mode: "content" } },
447
+ { key: "reason", fieldKey: "reason", title: labels.check.columns.reason, sizing: { mode: "fill", minWidth: 160 } },
448
+ ],
449
+ emptyState: { title: labels.check.empty },
450
+ footer: {
451
+ template: labels.check.footer,
452
+ values: [
453
+ { key: "objects", value: { source: "provider", fieldKey: "objects" } },
454
+ { key: "recorded", value: { source: "provider", fieldKey: "recorded" } },
455
+ ],
456
+ variants: [{
457
+ when: { value: { source: "provider", fieldKey: "consistent" }, operator: "truthy" },
458
+ template: labels.check.footerConsistent,
459
+ values: [
460
+ { key: "objects", value: { source: "provider", fieldKey: "objects" } },
461
+ { key: "recorded", value: { source: "provider", fieldKey: "recorded" } },
462
+ ],
463
+ }],
464
+ },
465
+ controlSize: "small",
466
+ },
467
+ features: {
468
+ pagination: { enabled: false },
469
+ sorting: { mode: "none" },
470
+ tools: { mode: "self-contained", reload: true },
471
+ actions: {
472
+ row: [{ key: "adopt", label: labels.actions.adopt, icon: "plus", display: "icon-label", execution: "provider" }],
473
+ },
474
+ },
475
+ },
476
+ }),
477
+ ],
478
+ };
479
+ }