@orion-studios/payload-studio 0.6.0-beta.5 → 0.6.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/client.d.mts +1 -0
- package/dist/admin/client.d.ts +1 -0
- package/dist/admin/client.js +1489 -662
- package/dist/admin/client.mjs +1337 -511
- package/dist/admin/index.d.mts +1 -2
- package/dist/admin/index.d.ts +1 -2
- package/dist/admin/index.js +1 -1505
- package/dist/admin/index.mjs +2 -4
- package/dist/admin-app/index.mjs +4 -4
- package/dist/chunk-5FNTVRCR.mjs +910 -0
- package/dist/{chunk-EHUE4LCT.mjs → chunk-RKTIFEUY.mjs} +33 -3
- package/dist/chunk-W2UOCJDX.mjs +32 -0
- package/dist/{index-DEkV-sMs.d.mts → index-DyMmaRfI.d.mts} +2 -7
- package/dist/{index-bbA3HSxa.d.ts → index-QPDAedIX.d.ts} +2 -7
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +63 -1521
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-PKVTM6DY.mjs +0 -2372
- package/dist/chunk-Z6L5K5MH.mjs +0 -64
package/dist/index.js
CHANGED
|
@@ -42,7 +42,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
42
42
|
// src/admin/index.ts
|
|
43
43
|
var admin_exports = {};
|
|
44
44
|
__export(admin_exports, {
|
|
45
|
-
AdminStudioDashboard: () => AdminStudioDashboard,
|
|
46
45
|
SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM: () => SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
|
|
47
46
|
SOCIAL_MEDIA_ICON_OPTIONS: () => SOCIAL_MEDIA_ICON_OPTIONS,
|
|
48
47
|
SOCIAL_MEDIA_PLATFORMS: () => SOCIAL_MEDIA_PLATFORMS,
|
|
@@ -110,7 +109,6 @@ var navItemIsActive = (pathname, item) => {
|
|
|
110
109
|
// src/shared/studioSections.ts
|
|
111
110
|
var studioRoles = /* @__PURE__ */ new Set(["admin", "editor", "client"]);
|
|
112
111
|
var studioIcons = new Set(adminNavIcons);
|
|
113
|
-
var dashboardSpans = /* @__PURE__ */ new Set(["full", "half"]);
|
|
114
112
|
var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
115
113
|
var isAbsoluteExternalURL = (value) => /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value) || value.startsWith("//");
|
|
116
114
|
var normalizePathLikeValue = (value) => {
|
|
@@ -152,22 +150,6 @@ var normalizeCard = (value) => {
|
|
|
152
150
|
};
|
|
153
151
|
};
|
|
154
152
|
var normalizeIcon = (value) => typeof value === "string" && studioIcons.has(value) ? value : void 0;
|
|
155
|
-
var normalizeComponent = (value) => {
|
|
156
|
-
if (!isRecord(value)) {
|
|
157
|
-
return void 0;
|
|
158
|
-
}
|
|
159
|
-
const componentPath = typeof value.path === "string" ? value.path.trim() : "";
|
|
160
|
-
const exportName = typeof value.exportName === "string" ? value.exportName.trim() : "";
|
|
161
|
-
if (!componentPath || !exportName) {
|
|
162
|
-
return void 0;
|
|
163
|
-
}
|
|
164
|
-
return {
|
|
165
|
-
exportName,
|
|
166
|
-
path: componentPath,
|
|
167
|
-
...isRecord(value.clientProps) ? { clientProps: value.clientProps } : {}
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
var normalizeDashboardSpan = (value) => typeof value === "string" && dashboardSpans.has(value) ? value : "half";
|
|
171
153
|
var resolveStudioSections = (value) => {
|
|
172
154
|
if (!Array.isArray(value)) {
|
|
173
155
|
return [];
|
|
@@ -233,38 +215,6 @@ var resolveStudioSectionViews = (value) => {
|
|
|
233
215
|
}
|
|
234
216
|
return views;
|
|
235
217
|
};
|
|
236
|
-
var resolveStudioSectionDashboards = (value) => {
|
|
237
|
-
if (!Array.isArray(value)) {
|
|
238
|
-
return [];
|
|
239
|
-
}
|
|
240
|
-
const panels = [];
|
|
241
|
-
const seen = /* @__PURE__ */ new Set();
|
|
242
|
-
for (const entry of value) {
|
|
243
|
-
if (!isRecord(entry) || typeof entry.id !== "string" || typeof entry.label !== "string") {
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
const id = entry.id.trim();
|
|
247
|
-
const label = entry.label.trim();
|
|
248
|
-
const dashboard = isRecord(entry.dashboard) ? entry.dashboard : null;
|
|
249
|
-
const component = dashboard ? normalizeComponent(dashboard.Component) : void 0;
|
|
250
|
-
const href = typeof entry.href === "string" && entry.href.trim().length > 0 ? normalizePathLikeValue(entry.href) : isRecord(entry.view) && typeof entry.view.path === "string" ? normalizePathLikeValue(entry.view.path) : "";
|
|
251
|
-
if (!id || !label || !dashboard || !component || !href || seen.has(id)) {
|
|
252
|
-
continue;
|
|
253
|
-
}
|
|
254
|
-
const priority = typeof dashboard.priority === "number" && Number.isFinite(dashboard.priority) ? dashboard.priority : 100;
|
|
255
|
-
panels.push({
|
|
256
|
-
Component: component,
|
|
257
|
-
href,
|
|
258
|
-
id,
|
|
259
|
-
label,
|
|
260
|
-
priority,
|
|
261
|
-
...normalizeRoles(dashboard.roles ?? entry.roles) ? { roles: normalizeRoles(dashboard.roles ?? entry.roles) } : {},
|
|
262
|
-
span: normalizeDashboardSpan(dashboard.span)
|
|
263
|
-
});
|
|
264
|
-
seen.add(id);
|
|
265
|
-
}
|
|
266
|
-
return panels.sort((a, b) => a.priority === b.priority ? a.label.localeCompare(b.label) : a.priority - b.priority);
|
|
267
|
-
};
|
|
268
218
|
|
|
269
219
|
// src/admin/helpers/configureAdmin.ts
|
|
270
220
|
var import_meta = {};
|
|
@@ -324,7 +274,6 @@ function configureAdmin(config) {
|
|
|
324
274
|
};
|
|
325
275
|
});
|
|
326
276
|
const studioSections = resolveStudioSections(config.studio?.sections || []);
|
|
327
|
-
const studioDashboardPanels = resolveStudioSectionDashboards(config.studio?.sections || []);
|
|
328
277
|
const studioSectionViews = resolveStudioSectionViews(config.studio?.sections || []);
|
|
329
278
|
const sitePreview = config.studio?.sitePreview;
|
|
330
279
|
let cssPath;
|
|
@@ -354,7 +303,6 @@ function configureAdmin(config) {
|
|
|
354
303
|
cssPath = genPath;
|
|
355
304
|
}
|
|
356
305
|
const clientPath = "@orion-studios/payload-studio/admin/client";
|
|
357
|
-
const adminPath = "@orion-studios/payload-studio/admin";
|
|
358
306
|
const studioNavClientProps = {
|
|
359
307
|
brandName,
|
|
360
308
|
formSubmissionsCollectionSlug,
|
|
@@ -366,14 +314,8 @@ function configureAdmin(config) {
|
|
|
366
314
|
logoUrl,
|
|
367
315
|
mediaCollectionSlug,
|
|
368
316
|
pagesCollectionSlug,
|
|
369
|
-
dashboardPanels: studioDashboardPanels,
|
|
370
317
|
sections: studioSections
|
|
371
318
|
};
|
|
372
|
-
const dashboardImportMapGenerator = studioDashboardPanels.length > 0 ? ({ addToImportMap }) => {
|
|
373
|
-
addToImportMap(
|
|
374
|
-
studioDashboardPanels.map((panel) => panel.Component)
|
|
375
|
-
);
|
|
376
|
-
} : void 0;
|
|
377
319
|
const studioBackBreadcrumbComponent = {
|
|
378
320
|
exportName: "StudioBackBreadcrumb",
|
|
379
321
|
path: clientPath
|
|
@@ -408,11 +350,6 @@ function configureAdmin(config) {
|
|
|
408
350
|
return {
|
|
409
351
|
admin: {
|
|
410
352
|
css: cssPath,
|
|
411
|
-
...dashboardImportMapGenerator ? {
|
|
412
|
-
importMap: {
|
|
413
|
-
generators: [dashboardImportMapGenerator]
|
|
414
|
-
}
|
|
415
|
-
} : {},
|
|
416
353
|
components: {
|
|
417
354
|
...studioEnabled ? {
|
|
418
355
|
Nav: {
|
|
@@ -443,7 +380,7 @@ function configureAdmin(config) {
|
|
|
443
380
|
dashboard: {
|
|
444
381
|
Component: {
|
|
445
382
|
exportName: studioEnabled ? "AdminStudioDashboard" : "Dashboard",
|
|
446
|
-
path:
|
|
383
|
+
path: clientPath,
|
|
447
384
|
clientProps: studioNavClientProps
|
|
448
385
|
}
|
|
449
386
|
},
|
|
@@ -839,1431 +776,6 @@ function configureAdmin(config) {
|
|
|
839
776
|
};
|
|
840
777
|
}
|
|
841
778
|
|
|
842
|
-
// src/admin/components/studio/AdminStudioDashboard.tsx
|
|
843
|
-
var import_RenderServerComponent = require("@payloadcms/ui/elements/RenderServerComponent");
|
|
844
|
-
|
|
845
|
-
// src/admin-app/components/AdminBreadcrumbs.tsx
|
|
846
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
847
|
-
function AdminBreadcrumbs({ items }) {
|
|
848
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { "aria-label": "Breadcrumb", className: "orion-admin-breadcrumbs", children: items.map((item, index) => {
|
|
849
|
-
const isLast = index === items.length - 1;
|
|
850
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
851
|
-
item.href && !isLast ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: item.href, children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: item.label }),
|
|
852
|
-
!isLast ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "orion-admin-breadcrumb-sep", children: "/" }) : null
|
|
853
|
-
] }, `${item.label}-${index}`);
|
|
854
|
-
}) });
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// src/admin-app/components/AdminPage.tsx
|
|
858
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
859
|
-
function AdminPage({ title, description, breadcrumbs, actions, children }) {
|
|
860
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-page", children: [
|
|
861
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-page-header", children: [
|
|
862
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AdminBreadcrumbs, { items: breadcrumbs }),
|
|
863
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-page-title-row", children: [
|
|
864
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
865
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { children: title }),
|
|
866
|
-
description ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: description }) : null
|
|
867
|
-
] }),
|
|
868
|
-
actions ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-page-actions", children: actions }) : null
|
|
869
|
-
] })
|
|
870
|
-
] }),
|
|
871
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-page-content", children })
|
|
872
|
-
] });
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
// src/admin/components/studio/AdminStudioDashboardClient.tsx
|
|
876
|
-
var import_react = require("react");
|
|
877
|
-
var import_link = __toESM(require("next/link"));
|
|
878
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
879
|
-
var SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
880
|
-
var isRole = (value) => value === "admin" || value === "editor" || value === "client";
|
|
881
|
-
var canReviewForms = (role) => role === "admin" || role === "editor";
|
|
882
|
-
var canCreatePages = (role) => role === "admin" || role === "editor";
|
|
883
|
-
var canAccess = (role, roles) => {
|
|
884
|
-
if (!roles || roles.length === 0) {
|
|
885
|
-
return true;
|
|
886
|
-
}
|
|
887
|
-
if (!role) {
|
|
888
|
-
return false;
|
|
889
|
-
}
|
|
890
|
-
return roles.includes(role);
|
|
891
|
-
};
|
|
892
|
-
var asText = (value, fallback) => typeof value === "string" && value.trim().length > 0 ? value.trim() : fallback;
|
|
893
|
-
var asID = (value) => {
|
|
894
|
-
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
895
|
-
return "";
|
|
896
|
-
};
|
|
897
|
-
var toTimestamp = (value) => {
|
|
898
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
899
|
-
return Number.NaN;
|
|
900
|
-
}
|
|
901
|
-
const timestamp = Date.parse(value);
|
|
902
|
-
return Number.isFinite(timestamp) ? timestamp : Number.NaN;
|
|
903
|
-
};
|
|
904
|
-
var isRecent = (value) => {
|
|
905
|
-
const timestamp = toTimestamp(value);
|
|
906
|
-
return Number.isFinite(timestamp) && Date.now() - timestamp <= SEVEN_DAYS_MS;
|
|
907
|
-
};
|
|
908
|
-
var formatDateTime = (value) => {
|
|
909
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
910
|
-
return "Unknown time";
|
|
911
|
-
}
|
|
912
|
-
const date = new Date(value);
|
|
913
|
-
if (Number.isNaN(date.getTime())) {
|
|
914
|
-
return value;
|
|
915
|
-
}
|
|
916
|
-
return new Intl.DateTimeFormat(void 0, {
|
|
917
|
-
dateStyle: "medium",
|
|
918
|
-
timeStyle: "short"
|
|
919
|
-
}).format(date);
|
|
920
|
-
};
|
|
921
|
-
var formatRelativeTime = (timestamp) => {
|
|
922
|
-
if (!Number.isFinite(timestamp)) {
|
|
923
|
-
return "Unknown time";
|
|
924
|
-
}
|
|
925
|
-
const diffMs = timestamp - Date.now();
|
|
926
|
-
const diffMinutes = Math.round(diffMs / (60 * 1e3));
|
|
927
|
-
const rtf = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
|
|
928
|
-
if (Math.abs(diffMinutes) < 60) {
|
|
929
|
-
return rtf.format(diffMinutes, "minute");
|
|
930
|
-
}
|
|
931
|
-
const diffHours = Math.round(diffMinutes / 60);
|
|
932
|
-
if (Math.abs(diffHours) < 24) {
|
|
933
|
-
return rtf.format(diffHours, "hour");
|
|
934
|
-
}
|
|
935
|
-
const diffDays = Math.round(diffHours / 24);
|
|
936
|
-
return rtf.format(diffDays, "day");
|
|
937
|
-
};
|
|
938
|
-
var readSubmissionIdentity = (value) => {
|
|
939
|
-
if (!value || typeof value !== "object") {
|
|
940
|
-
return "New submission";
|
|
941
|
-
}
|
|
942
|
-
const data = value;
|
|
943
|
-
const firstName = typeof data.firstName === "string" ? data.firstName.trim() : "";
|
|
944
|
-
const lastName = typeof data.lastName === "string" ? data.lastName.trim() : "";
|
|
945
|
-
const name = typeof data.name === "string" ? data.name.trim() : "";
|
|
946
|
-
const email = typeof data.email === "string" ? data.email.trim() : typeof data.contactEmail === "string" ? data.contactEmail.trim() : "";
|
|
947
|
-
const fullName = [firstName, lastName].filter(Boolean).join(" ").trim();
|
|
948
|
-
return fullName || name || email || "New submission";
|
|
949
|
-
};
|
|
950
|
-
var getFormID = (value) => {
|
|
951
|
-
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
952
|
-
if (value && typeof value === "object") {
|
|
953
|
-
const nestedID = value.id;
|
|
954
|
-
if (typeof nestedID === "string" || typeof nestedID === "number") return String(nestedID);
|
|
955
|
-
}
|
|
956
|
-
return "";
|
|
957
|
-
};
|
|
958
|
-
var getFormTitle = (value) => {
|
|
959
|
-
if (!value || typeof value !== "object") {
|
|
960
|
-
return "";
|
|
961
|
-
}
|
|
962
|
-
const title = value.title;
|
|
963
|
-
if (typeof title === "string" && title.trim().length > 0) {
|
|
964
|
-
return title.trim();
|
|
965
|
-
}
|
|
966
|
-
const slug = value.slug;
|
|
967
|
-
return typeof slug === "string" && slug.trim().length > 0 ? slug.trim() : "";
|
|
968
|
-
};
|
|
969
|
-
var buildSearchParams = (params) => new URLSearchParams(
|
|
970
|
-
Object.entries(params).filter(([, value]) => typeof value === "string" && value.length > 0)
|
|
971
|
-
).toString();
|
|
972
|
-
async function loadCollection(path2) {
|
|
973
|
-
const response = await fetch(path2, {
|
|
974
|
-
cache: "no-store",
|
|
975
|
-
credentials: "include"
|
|
976
|
-
});
|
|
977
|
-
if (!response.ok) {
|
|
978
|
-
const body = await response.text();
|
|
979
|
-
throw new Error(body || `Request failed: ${response.status}`);
|
|
980
|
-
}
|
|
981
|
-
return await response.json();
|
|
982
|
-
}
|
|
983
|
-
async function loadPages(collectionSlug) {
|
|
984
|
-
const params = buildSearchParams({
|
|
985
|
-
depth: "0",
|
|
986
|
-
draft: "true",
|
|
987
|
-
limit: "200",
|
|
988
|
-
sort: "-updatedAt"
|
|
989
|
-
});
|
|
990
|
-
const result = await loadCollection(`/api/${collectionSlug}?${params}`);
|
|
991
|
-
const docs = Array.isArray(result.docs) ? result.docs : [];
|
|
992
|
-
return {
|
|
993
|
-
draftCount: docs.filter((doc) => doc._status === "draft").length,
|
|
994
|
-
recent: docs.slice(0, 8),
|
|
995
|
-
total: typeof result.totalDocs === "number" ? result.totalDocs : docs.length,
|
|
996
|
-
updatedThisWeek: docs.filter((doc) => isRecent(doc.updatedAt)).length
|
|
997
|
-
};
|
|
998
|
-
}
|
|
999
|
-
async function loadForms(formsCollectionSlug, submissionsCollectionSlug) {
|
|
1000
|
-
const [formsResult, submissionsResult] = await Promise.all([
|
|
1001
|
-
loadCollection(
|
|
1002
|
-
`/api/${formsCollectionSlug}?${buildSearchParams({
|
|
1003
|
-
depth: "0",
|
|
1004
|
-
draft: "true",
|
|
1005
|
-
limit: "80",
|
|
1006
|
-
sort: "-updatedAt"
|
|
1007
|
-
})}`
|
|
1008
|
-
),
|
|
1009
|
-
loadCollection(
|
|
1010
|
-
`/api/${submissionsCollectionSlug}?${buildSearchParams({
|
|
1011
|
-
depth: "1",
|
|
1012
|
-
limit: "40",
|
|
1013
|
-
sort: "-submittedAt"
|
|
1014
|
-
})}`
|
|
1015
|
-
)
|
|
1016
|
-
]);
|
|
1017
|
-
const forms = Array.isArray(formsResult.docs) ? formsResult.docs : [];
|
|
1018
|
-
const recentSubmissions = Array.isArray(submissionsResult.docs) ? submissionsResult.docs : [];
|
|
1019
|
-
const submissionsByForm = /* @__PURE__ */ new Map();
|
|
1020
|
-
for (const submission of recentSubmissions) {
|
|
1021
|
-
const formID = getFormID(submission.form);
|
|
1022
|
-
if (!formID) continue;
|
|
1023
|
-
submissionsByForm.set(formID, (submissionsByForm.get(formID) || 0) + 1);
|
|
1024
|
-
}
|
|
1025
|
-
let busiestFormTitle = null;
|
|
1026
|
-
let busiestFormCount = 0;
|
|
1027
|
-
for (const form of forms) {
|
|
1028
|
-
const formID = asID(form.id);
|
|
1029
|
-
if (!formID) continue;
|
|
1030
|
-
const submissionCount = submissionsByForm.get(formID) || 0;
|
|
1031
|
-
if (submissionCount > busiestFormCount) {
|
|
1032
|
-
busiestFormCount = submissionCount;
|
|
1033
|
-
busiestFormTitle = asText(form.title, "Untitled form");
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
return {
|
|
1037
|
-
busiestFormTitle,
|
|
1038
|
-
forms,
|
|
1039
|
-
recentSubmissions,
|
|
1040
|
-
submissionsThisWeek: recentSubmissions.filter((submission) => isRecent(submission.submittedAt)).length,
|
|
1041
|
-
totalForms: typeof formsResult.totalDocs === "number" ? formsResult.totalDocs : forms.length
|
|
1042
|
-
};
|
|
1043
|
-
}
|
|
1044
|
-
async function loadMedia(collectionSlug) {
|
|
1045
|
-
const params = buildSearchParams({
|
|
1046
|
-
depth: "0",
|
|
1047
|
-
limit: "24",
|
|
1048
|
-
sort: "-updatedAt"
|
|
1049
|
-
});
|
|
1050
|
-
const result = await loadCollection(`/api/${collectionSlug}?${params}`);
|
|
1051
|
-
const docs = Array.isArray(result.docs) ? result.docs : [];
|
|
1052
|
-
return {
|
|
1053
|
-
recent: docs.slice(0, 8),
|
|
1054
|
-
total: typeof result.totalDocs === "number" ? result.totalDocs : docs.length,
|
|
1055
|
-
uploadsThisWeek: docs.filter((doc) => isRecent(doc.updatedAt)).length
|
|
1056
|
-
};
|
|
1057
|
-
}
|
|
1058
|
-
var loadingState = {
|
|
1059
|
-
forms: null,
|
|
1060
|
-
media: { status: "loading" },
|
|
1061
|
-
pages: { status: "loading" }
|
|
1062
|
-
};
|
|
1063
|
-
function ModuleStatus({ message }) {
|
|
1064
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "orion-dashboard-inline-note", children: message });
|
|
1065
|
-
}
|
|
1066
|
-
function EmptyState({
|
|
1067
|
-
body,
|
|
1068
|
-
title
|
|
1069
|
-
}) {
|
|
1070
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-empty-state", children: [
|
|
1071
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: title }),
|
|
1072
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: body })
|
|
1073
|
-
] });
|
|
1074
|
-
}
|
|
1075
|
-
function SnapshotMetric({ card }) {
|
|
1076
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("article", { className: "orion-dashboard-snapshot-card", children: [
|
|
1077
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-snapshot-kicker", children: card.kicker }),
|
|
1078
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: card.value }),
|
|
1079
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: card.detail })
|
|
1080
|
-
] });
|
|
1081
|
-
}
|
|
1082
|
-
function AdminStudioDashboardClient({
|
|
1083
|
-
formSubmissionsCollectionSlug,
|
|
1084
|
-
formsCollectionSlug,
|
|
1085
|
-
formsEnabled,
|
|
1086
|
-
formsPath,
|
|
1087
|
-
globalsBasePath,
|
|
1088
|
-
mediaCollectionSlug,
|
|
1089
|
-
mediaPath,
|
|
1090
|
-
pagesCollectionSlug,
|
|
1091
|
-
pagesPath,
|
|
1092
|
-
sectionLinks,
|
|
1093
|
-
toolsPath,
|
|
1094
|
-
userRole,
|
|
1095
|
-
children
|
|
1096
|
-
}) {
|
|
1097
|
-
const role = isRole(userRole) ? userRole : void 0;
|
|
1098
|
-
const [state, setState] = (0, import_react.useState)(
|
|
1099
|
-
() => formsEnabled && canReviewForms(role) ? {
|
|
1100
|
-
forms: { status: "loading" },
|
|
1101
|
-
media: { status: "loading" },
|
|
1102
|
-
pages: { status: "loading" }
|
|
1103
|
-
} : loadingState
|
|
1104
|
-
);
|
|
1105
|
-
(0, import_react.useEffect)(() => {
|
|
1106
|
-
let cancelled = false;
|
|
1107
|
-
const run = async () => {
|
|
1108
|
-
const includeForms = formsEnabled && canReviewForms(role);
|
|
1109
|
-
(0, import_react.startTransition)(() => {
|
|
1110
|
-
setState({
|
|
1111
|
-
forms: includeForms ? { status: "loading" } : null,
|
|
1112
|
-
media: { status: "loading" },
|
|
1113
|
-
pages: { status: "loading" }
|
|
1114
|
-
});
|
|
1115
|
-
});
|
|
1116
|
-
const [pagesResult, formsResult, mediaResult] = await Promise.allSettled([
|
|
1117
|
-
loadPages(pagesCollectionSlug),
|
|
1118
|
-
includeForms ? loadForms(formsCollectionSlug, formSubmissionsCollectionSlug) : Promise.resolve(null),
|
|
1119
|
-
loadMedia(mediaCollectionSlug)
|
|
1120
|
-
]);
|
|
1121
|
-
if (cancelled) return;
|
|
1122
|
-
(0, import_react.startTransition)(() => {
|
|
1123
|
-
setState({
|
|
1124
|
-
forms: includeForms && formsResult.status === "rejected" ? {
|
|
1125
|
-
error: formsResult.reason instanceof Error ? formsResult.reason.message : "Unable to load form activity.",
|
|
1126
|
-
status: "error"
|
|
1127
|
-
} : includeForms && formsResult.status === "fulfilled" && formsResult.value ? {
|
|
1128
|
-
data: formsResult.value,
|
|
1129
|
-
status: "success"
|
|
1130
|
-
} : null,
|
|
1131
|
-
media: mediaResult.status === "rejected" ? {
|
|
1132
|
-
error: mediaResult.reason instanceof Error ? mediaResult.reason.message : "Unable to load media activity.",
|
|
1133
|
-
status: "error"
|
|
1134
|
-
} : {
|
|
1135
|
-
data: mediaResult.value,
|
|
1136
|
-
status: "success"
|
|
1137
|
-
},
|
|
1138
|
-
pages: pagesResult.status === "rejected" ? {
|
|
1139
|
-
error: pagesResult.reason instanceof Error ? pagesResult.reason.message : "Unable to load page activity.",
|
|
1140
|
-
status: "error"
|
|
1141
|
-
} : {
|
|
1142
|
-
data: pagesResult.value,
|
|
1143
|
-
status: "success"
|
|
1144
|
-
}
|
|
1145
|
-
});
|
|
1146
|
-
});
|
|
1147
|
-
};
|
|
1148
|
-
void run();
|
|
1149
|
-
return () => {
|
|
1150
|
-
cancelled = true;
|
|
1151
|
-
};
|
|
1152
|
-
}, [
|
|
1153
|
-
formSubmissionsCollectionSlug,
|
|
1154
|
-
formsCollectionSlug,
|
|
1155
|
-
formsEnabled,
|
|
1156
|
-
mediaCollectionSlug,
|
|
1157
|
-
pagesCollectionSlug,
|
|
1158
|
-
role
|
|
1159
|
-
]);
|
|
1160
|
-
const visibleWorkspaceLinks = (0, import_react.useMemo)(
|
|
1161
|
-
() => sectionLinks.filter((section) => canAccess(role, section.roles)),
|
|
1162
|
-
[role, sectionLinks]
|
|
1163
|
-
);
|
|
1164
|
-
const activityItems = (0, import_react.useMemo)(() => {
|
|
1165
|
-
const items = [];
|
|
1166
|
-
if (state.pages.status === "success") {
|
|
1167
|
-
for (const doc of state.pages.data.recent) {
|
|
1168
|
-
const id = asID(doc.id);
|
|
1169
|
-
if (!id) continue;
|
|
1170
|
-
const timestamp = toTimestamp(doc.updatedAt);
|
|
1171
|
-
items.push({
|
|
1172
|
-
href: `${pagesPath}/${id}`,
|
|
1173
|
-
id: `page-${id}`,
|
|
1174
|
-
kind: "page",
|
|
1175
|
-
label: typeof doc._status === "string" ? doc._status : "page",
|
|
1176
|
-
meta: Number.isFinite(timestamp) ? formatDateTime(doc.updatedAt) : "Update time unavailable",
|
|
1177
|
-
timestamp,
|
|
1178
|
-
title: asText(doc.title, "Untitled page")
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
if (state.forms?.status === "success") {
|
|
1183
|
-
for (const submission of state.forms.data.recentSubmissions) {
|
|
1184
|
-
const id = asID(submission.id);
|
|
1185
|
-
const formID = getFormID(submission.form);
|
|
1186
|
-
if (!id || !formID) continue;
|
|
1187
|
-
const timestamp = toTimestamp(submission.submittedAt);
|
|
1188
|
-
const formTitle = getFormTitle(submission.form) || "Form response";
|
|
1189
|
-
items.push({
|
|
1190
|
-
href: `${formsPath}?form=${encodeURIComponent(formID)}`,
|
|
1191
|
-
id: `submission-${id}`,
|
|
1192
|
-
kind: "submission",
|
|
1193
|
-
label: formTitle,
|
|
1194
|
-
meta: Number.isFinite(timestamp) ? `${readSubmissionIdentity(submission.data)} \xB7 ${formatDateTime(submission.submittedAt)}` : readSubmissionIdentity(submission.data),
|
|
1195
|
-
timestamp,
|
|
1196
|
-
title: "New submission"
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
if (state.media.status === "success") {
|
|
1201
|
-
for (const doc of state.media.data.recent) {
|
|
1202
|
-
const id = asID(doc.id);
|
|
1203
|
-
if (!id) continue;
|
|
1204
|
-
const timestamp = toTimestamp(doc.updatedAt);
|
|
1205
|
-
items.push({
|
|
1206
|
-
href: `${mediaPath}/${id}`,
|
|
1207
|
-
id: `media-${id}`,
|
|
1208
|
-
kind: "media",
|
|
1209
|
-
label: asText(doc.mimeType, "Media asset"),
|
|
1210
|
-
meta: Number.isFinite(timestamp) ? formatDateTime(doc.updatedAt) : "Update time unavailable",
|
|
1211
|
-
timestamp,
|
|
1212
|
-
title: asText(doc.filename, "Untitled asset")
|
|
1213
|
-
});
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
return items.filter((item) => Number.isFinite(item.timestamp)).sort((a, b) => b.timestamp - a.timestamp).slice(0, 10);
|
|
1217
|
-
}, [formsPath, mediaPath, pagesPath, state.forms, state.media, state.pages]);
|
|
1218
|
-
const attentionItems = (0, import_react.useMemo)(() => {
|
|
1219
|
-
if (role === "client") {
|
|
1220
|
-
const items2 = [];
|
|
1221
|
-
if (state.pages.status === "success" && state.pages.data.updatedThisWeek > 0) {
|
|
1222
|
-
items2.push({
|
|
1223
|
-
href: pagesPath,
|
|
1224
|
-
id: "pages-updated",
|
|
1225
|
-
label: `${state.pages.data.updatedThisWeek} page${state.pages.data.updatedThisWeek === 1 ? "" : "s"} changed in the last 7 days.`
|
|
1226
|
-
});
|
|
1227
|
-
}
|
|
1228
|
-
if (state.media.status === "success" && state.media.data.uploadsThisWeek > 0) {
|
|
1229
|
-
items2.push({
|
|
1230
|
-
href: mediaPath,
|
|
1231
|
-
id: "media-updated",
|
|
1232
|
-
label: `${state.media.data.uploadsThisWeek} new media asset${state.media.data.uploadsThisWeek === 1 ? "" : "s"} landed this week.`
|
|
1233
|
-
});
|
|
1234
|
-
}
|
|
1235
|
-
return items2;
|
|
1236
|
-
}
|
|
1237
|
-
const items = [];
|
|
1238
|
-
if (state.pages.status === "success" && state.pages.data.draftCount > 0) {
|
|
1239
|
-
items.push({
|
|
1240
|
-
href: pagesPath,
|
|
1241
|
-
id: "draft-pages",
|
|
1242
|
-
label: `${state.pages.data.draftCount} page${state.pages.data.draftCount === 1 ? "" : "s"} still need publishing review.`,
|
|
1243
|
-
tone: "accent"
|
|
1244
|
-
});
|
|
1245
|
-
}
|
|
1246
|
-
if (state.forms?.status === "success" && state.forms.data.submissionsThisWeek > 0) {
|
|
1247
|
-
items.push({
|
|
1248
|
-
href: formsPath,
|
|
1249
|
-
id: "recent-submissions",
|
|
1250
|
-
label: `${state.forms.data.submissionsThisWeek} form submission${state.forms.data.submissionsThisWeek === 1 ? "" : "s"} arrived in the last 7 days.`,
|
|
1251
|
-
tone: "accent"
|
|
1252
|
-
});
|
|
1253
|
-
}
|
|
1254
|
-
if (state.media.status === "success" && state.media.data.total === 0) {
|
|
1255
|
-
items.push({
|
|
1256
|
-
href: mediaPath,
|
|
1257
|
-
id: "empty-media",
|
|
1258
|
-
label: "The media library is still empty. Add brand assets before content expands."
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1261
|
-
if (state.pages.status === "error") {
|
|
1262
|
-
items.push({
|
|
1263
|
-
href: pagesPath,
|
|
1264
|
-
id: "pages-error",
|
|
1265
|
-
label: "Page activity could not be loaded for the dashboard.",
|
|
1266
|
-
tone: "muted"
|
|
1267
|
-
});
|
|
1268
|
-
}
|
|
1269
|
-
if (state.forms?.status === "error") {
|
|
1270
|
-
items.push({
|
|
1271
|
-
href: formsPath,
|
|
1272
|
-
id: "forms-error",
|
|
1273
|
-
label: "Form activity could not be loaded for the dashboard.",
|
|
1274
|
-
tone: "muted"
|
|
1275
|
-
});
|
|
1276
|
-
}
|
|
1277
|
-
if (state.media.status === "error") {
|
|
1278
|
-
items.push({
|
|
1279
|
-
href: mediaPath,
|
|
1280
|
-
id: "media-error",
|
|
1281
|
-
label: "Media activity could not be loaded for the dashboard.",
|
|
1282
|
-
tone: "muted"
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
|
-
return items;
|
|
1286
|
-
}, [formsPath, mediaPath, pagesPath, role, state.forms, state.media, state.pages]);
|
|
1287
|
-
const snapshotCards = (0, import_react.useMemo)(() => {
|
|
1288
|
-
const cards = [];
|
|
1289
|
-
if (state.pages.status === "success") {
|
|
1290
|
-
cards.push(
|
|
1291
|
-
role === "client" ? {
|
|
1292
|
-
detail: `${state.pages.data.updatedThisWeek} updated this week`,
|
|
1293
|
-
kicker: "Pages",
|
|
1294
|
-
value: `${state.pages.data.total}`
|
|
1295
|
-
} : {
|
|
1296
|
-
detail: `${state.pages.data.draftCount} draft${state.pages.data.draftCount === 1 ? "" : "s"} waiting`,
|
|
1297
|
-
kicker: "Pages",
|
|
1298
|
-
value: `${state.pages.data.total}`
|
|
1299
|
-
}
|
|
1300
|
-
);
|
|
1301
|
-
}
|
|
1302
|
-
if (state.forms?.status === "success") {
|
|
1303
|
-
cards.push({
|
|
1304
|
-
detail: state.forms.data.busiestFormTitle ? `Most active: ${state.forms.data.busiestFormTitle}` : "Waiting on the first submission",
|
|
1305
|
-
kicker: "Forms",
|
|
1306
|
-
value: `${state.forms.data.submissionsThisWeek}`
|
|
1307
|
-
});
|
|
1308
|
-
}
|
|
1309
|
-
if (state.media.status === "success") {
|
|
1310
|
-
cards.push({
|
|
1311
|
-
detail: `${state.media.data.uploadsThisWeek} uploaded this week`,
|
|
1312
|
-
kicker: "Media",
|
|
1313
|
-
value: `${state.media.data.total}`
|
|
1314
|
-
});
|
|
1315
|
-
}
|
|
1316
|
-
cards.push({
|
|
1317
|
-
detail: `${visibleWorkspaceLinks.length} section${visibleWorkspaceLinks.length === 1 ? "" : "s"} available`,
|
|
1318
|
-
kicker: "Workspace",
|
|
1319
|
-
value: role ? role.toUpperCase() : "CMS"
|
|
1320
|
-
});
|
|
1321
|
-
return cards.slice(0, 4);
|
|
1322
|
-
}, [role, state.forms, state.media, state.pages, visibleWorkspaceLinks.length]);
|
|
1323
|
-
const primaryActions = (0, import_react.useMemo)(() => {
|
|
1324
|
-
const actions = [];
|
|
1325
|
-
if (canCreatePages(role)) {
|
|
1326
|
-
actions.push({
|
|
1327
|
-
description: "Create or revise content in the visual builder.",
|
|
1328
|
-
href: `${pagesPath}/new`,
|
|
1329
|
-
label: "New Page"
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
|
-
actions.push({
|
|
1333
|
-
description: "Review live pages and recent edits.",
|
|
1334
|
-
href: pagesPath,
|
|
1335
|
-
label: "Open Pages",
|
|
1336
|
-
tone: "ghost"
|
|
1337
|
-
});
|
|
1338
|
-
if (formsEnabled && canReviewForms(role)) {
|
|
1339
|
-
actions.push({
|
|
1340
|
-
description: "Check submissions and form performance.",
|
|
1341
|
-
href: formsPath,
|
|
1342
|
-
label: "Review Forms",
|
|
1343
|
-
tone: "soft"
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
|
-
actions.push({
|
|
1347
|
-
description: "Update site settings, navigation, and footer content.",
|
|
1348
|
-
href: globalsBasePath,
|
|
1349
|
-
label: "Open Globals",
|
|
1350
|
-
tone: "ghost"
|
|
1351
|
-
});
|
|
1352
|
-
actions.push({
|
|
1353
|
-
description: "Upload or organize brand and campaign assets.",
|
|
1354
|
-
href: mediaPath,
|
|
1355
|
-
label: "Manage Media",
|
|
1356
|
-
tone: "ghost"
|
|
1357
|
-
});
|
|
1358
|
-
if (role === "admin") {
|
|
1359
|
-
actions.push({
|
|
1360
|
-
description: "Manage users, roles, and fallback tools.",
|
|
1361
|
-
href: toolsPath,
|
|
1362
|
-
label: "Admin Tools",
|
|
1363
|
-
tone: "ghost"
|
|
1364
|
-
});
|
|
1365
|
-
}
|
|
1366
|
-
return actions;
|
|
1367
|
-
}, [formsEnabled, formsPath, globalsBasePath, mediaPath, pagesPath, role, toolsPath]);
|
|
1368
|
-
const attentionTitle = role === "client" ? "What Changed" : "Needs Attention";
|
|
1369
|
-
const attentionDescription = role === "client" ? "A quick read on recent content and asset changes." : "The highest-signal items that still need review.";
|
|
1370
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-layout", children: [
|
|
1371
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "orion-dashboard-panel orion-dashboard-panel--attention", children: [
|
|
1372
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-panel-header", children: [
|
|
1373
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
1374
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-kicker", children: attentionTitle }),
|
|
1375
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: attentionDescription })
|
|
1376
|
-
] }),
|
|
1377
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-meta", children: "Last 7 days" })
|
|
1378
|
-
] }),
|
|
1379
|
-
attentionItems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "orion-dashboard-attention-list", children: attentionItems.map(
|
|
1380
|
-
(item) => item.href ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1381
|
-
import_link.default,
|
|
1382
|
-
{
|
|
1383
|
-
className: ["orion-dashboard-attention-item", item.tone ? `is-${item.tone}` : ""].filter(Boolean).join(" "),
|
|
1384
|
-
href: item.href,
|
|
1385
|
-
children: [
|
|
1386
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: item.label }),
|
|
1387
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Open" })
|
|
1388
|
-
]
|
|
1389
|
-
},
|
|
1390
|
-
item.id
|
|
1391
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1392
|
-
"div",
|
|
1393
|
-
{
|
|
1394
|
-
className: ["orion-dashboard-attention-item", item.tone ? `is-${item.tone}` : ""].filter(Boolean).join(" "),
|
|
1395
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: item.label })
|
|
1396
|
-
},
|
|
1397
|
-
item.id
|
|
1398
|
-
)
|
|
1399
|
-
) }) : state.pages.status === "loading" || state.media.status === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ModuleStatus, { message: "Loading attention items..." }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1400
|
-
EmptyState,
|
|
1401
|
-
{
|
|
1402
|
-
body: role === "client" ? "No major changes landed during the current review window." : "No urgent follow-up surfaced from content, forms, or media activity.",
|
|
1403
|
-
title: "Everything looks steady"
|
|
1404
|
-
}
|
|
1405
|
-
)
|
|
1406
|
-
] }),
|
|
1407
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "orion-dashboard-panel orion-dashboard-panel--actions", children: [
|
|
1408
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-panel-header", children: [
|
|
1409
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
1410
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-kicker", children: "Quick Actions" }),
|
|
1411
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "Jump into the work that matters most." })
|
|
1412
|
-
] }),
|
|
1413
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "orion-dashboard-panel-meta", children: [
|
|
1414
|
-
role || "studio",
|
|
1415
|
-
" mode"
|
|
1416
|
-
] })
|
|
1417
|
-
] }),
|
|
1418
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "orion-dashboard-action-list", children: primaryActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1419
|
-
import_link.default,
|
|
1420
|
-
{
|
|
1421
|
-
className: [
|
|
1422
|
-
"orion-dashboard-action",
|
|
1423
|
-
action.tone === "ghost" ? "is-ghost" : action.tone === "soft" ? "is-soft" : ""
|
|
1424
|
-
].filter(Boolean).join(" "),
|
|
1425
|
-
href: action.href,
|
|
1426
|
-
children: [
|
|
1427
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: action.label }),
|
|
1428
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: action.description })
|
|
1429
|
-
]
|
|
1430
|
-
},
|
|
1431
|
-
action.label
|
|
1432
|
-
)) }),
|
|
1433
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-workspace-strip", children: [
|
|
1434
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-workspace-label", children: "Workspace" }),
|
|
1435
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "orion-dashboard-workspace-pills", children: visibleWorkspaceLinks.map((section) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_link.default, { className: "orion-dashboard-workspace-pill", href: section.href, children: section.label }, section.id)) })
|
|
1436
|
-
] })
|
|
1437
|
-
] }),
|
|
1438
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "orion-dashboard-panel orion-dashboard-panel--activity", children: [
|
|
1439
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-panel-header", children: [
|
|
1440
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
1441
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-kicker", children: "Recent Activity" }),
|
|
1442
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "The freshest edits, responses, and uploads across the studio." })
|
|
1443
|
-
] }),
|
|
1444
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "orion-dashboard-panel-meta", children: [
|
|
1445
|
-
activityItems.length,
|
|
1446
|
-
" items"
|
|
1447
|
-
] })
|
|
1448
|
-
] }),
|
|
1449
|
-
activityItems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "orion-dashboard-activity-list", children: activityItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_link.default, { className: `orion-dashboard-activity-item is-${item.kind}`, href: item.href, children: [
|
|
1450
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-activity-copy", children: [
|
|
1451
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-activity-topline", children: [
|
|
1452
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: item.title }),
|
|
1453
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formatRelativeTime(item.timestamp) })
|
|
1454
|
-
] }),
|
|
1455
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: item.meta })
|
|
1456
|
-
] }),
|
|
1457
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-activity-pill", children: item.label })
|
|
1458
|
-
] }, item.id)) }) : state.pages.status === "loading" || state.media.status === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ModuleStatus, { message: "Loading activity feed..." }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1459
|
-
EmptyState,
|
|
1460
|
-
{
|
|
1461
|
-
body: "Recent page edits, submissions, and uploads will start stacking here as soon as the team gets moving.",
|
|
1462
|
-
title: "No recent activity yet"
|
|
1463
|
-
}
|
|
1464
|
-
)
|
|
1465
|
-
] }),
|
|
1466
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "orion-dashboard-panel orion-dashboard-panel--snapshot", children: [
|
|
1467
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-panel-header", children: [
|
|
1468
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
1469
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-kicker", children: "Business Snapshot" }),
|
|
1470
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "A compact read on content momentum and performance." })
|
|
1471
|
-
] }),
|
|
1472
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-meta", children: "30-day lens" })
|
|
1473
|
-
] }),
|
|
1474
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-snapshot-grid", children: [
|
|
1475
|
-
snapshotCards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SnapshotMetric, { card }, card.kicker)),
|
|
1476
|
-
children
|
|
1477
|
-
] }),
|
|
1478
|
-
state.pages.status === "error" || state.media.status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "orion-dashboard-inline-note", children: "Some dashboard modules could not be loaded. The rest of the workspace remains available." }) : null
|
|
1479
|
-
] })
|
|
1480
|
-
] });
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
// src/admin/components/studio/StudioSectionLayout.tsx
|
|
1484
|
-
var import_react5 = require("react");
|
|
1485
|
-
var import_navigation = require("next/navigation");
|
|
1486
|
-
var import_ui = require("@payloadcms/ui");
|
|
1487
|
-
|
|
1488
|
-
// src/admin-app/components/AdminShellClient.tsx
|
|
1489
|
-
var import_react2 = require("react");
|
|
1490
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1491
|
-
var iconSize = 20;
|
|
1492
|
-
var iconStyle = { display: "block", flexShrink: 0 };
|
|
1493
|
-
function NavIcon({ name }) {
|
|
1494
|
-
const props = { width: iconSize, height: iconSize, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", style: iconStyle };
|
|
1495
|
-
switch (name) {
|
|
1496
|
-
case "dashboard":
|
|
1497
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1498
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "3", y: "3", width: "7", height: "9", rx: "1" }),
|
|
1499
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "14", y: "3", width: "7", height: "5", rx: "1" }),
|
|
1500
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "14", y: "12", width: "7", height: "9", rx: "1" }),
|
|
1501
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "3", y: "16", width: "7", height: "5", rx: "1" })
|
|
1502
|
-
] });
|
|
1503
|
-
case "pages":
|
|
1504
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1505
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z" }),
|
|
1506
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("polyline", { points: "14 2 14 8 20 8" }),
|
|
1507
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "8", y1: "13", x2: "16", y2: "13" }),
|
|
1508
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "8", y1: "17", x2: "12", y2: "17" })
|
|
1509
|
-
] });
|
|
1510
|
-
case "forms":
|
|
1511
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1512
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9 3h6" }),
|
|
1513
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M12 3v18" }),
|
|
1514
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M5 7h14a2 2 0 0 1 2 2v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a2 2 0 0 1 2-2Z" }),
|
|
1515
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M7 11h10" }),
|
|
1516
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M7 15h6" })
|
|
1517
|
-
] });
|
|
1518
|
-
case "globals":
|
|
1519
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1520
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "3" }),
|
|
1521
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z" })
|
|
1522
|
-
] });
|
|
1523
|
-
case "media":
|
|
1524
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1525
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }),
|
|
1526
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "8.5", cy: "8.5", r: "1.5" }),
|
|
1527
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("polyline", { points: "21 15 16 10 5 21" })
|
|
1528
|
-
] });
|
|
1529
|
-
case "tools":
|
|
1530
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76Z" }) });
|
|
1531
|
-
case "analytics":
|
|
1532
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1533
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M4 19V5" }),
|
|
1534
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M10 19V10" }),
|
|
1535
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M16 19v-6" }),
|
|
1536
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M22 19V3" })
|
|
1537
|
-
] });
|
|
1538
|
-
case "account":
|
|
1539
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1540
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
|
|
1541
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "7", r: "4" })
|
|
1542
|
-
] });
|
|
1543
|
-
default:
|
|
1544
|
-
return null;
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
function AdminShellClient({
|
|
1548
|
-
children,
|
|
1549
|
-
brandName,
|
|
1550
|
-
logoUrl,
|
|
1551
|
-
userEmail,
|
|
1552
|
-
userRole,
|
|
1553
|
-
pathname,
|
|
1554
|
-
navItems,
|
|
1555
|
-
onLogout,
|
|
1556
|
-
storageKey = "orion-admin-shell-collapsed"
|
|
1557
|
-
}) {
|
|
1558
|
-
const [collapsed, setCollapsed] = (0, import_react2.useState)(false);
|
|
1559
|
-
const [loggingOut, setLoggingOut] = (0, import_react2.useState)(false);
|
|
1560
|
-
(0, import_react2.useEffect)(() => {
|
|
1561
|
-
try {
|
|
1562
|
-
const stored = window.localStorage.getItem(storageKey);
|
|
1563
|
-
if (stored === "1") {
|
|
1564
|
-
setCollapsed(true);
|
|
1565
|
-
}
|
|
1566
|
-
} catch {
|
|
1567
|
-
}
|
|
1568
|
-
}, [storageKey]);
|
|
1569
|
-
const toggleSidebar = () => {
|
|
1570
|
-
setCollapsed((current) => {
|
|
1571
|
-
const next = !current;
|
|
1572
|
-
try {
|
|
1573
|
-
window.localStorage.setItem(storageKey, next ? "1" : "0");
|
|
1574
|
-
} catch {
|
|
1575
|
-
}
|
|
1576
|
-
return next;
|
|
1577
|
-
});
|
|
1578
|
-
};
|
|
1579
|
-
const handleLogout = async () => {
|
|
1580
|
-
setLoggingOut(true);
|
|
1581
|
-
try {
|
|
1582
|
-
await onLogout();
|
|
1583
|
-
} finally {
|
|
1584
|
-
setLoggingOut(false);
|
|
1585
|
-
}
|
|
1586
|
-
};
|
|
1587
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `orion-admin-shell ${collapsed ? "is-collapsed" : ""}`, children: [
|
|
1588
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("aside", { className: "orion-admin-sidebar", children: [
|
|
1589
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1590
|
-
"button",
|
|
1591
|
-
{
|
|
1592
|
-
"aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
1593
|
-
className: "orion-admin-sidebar-toggle",
|
|
1594
|
-
onClick: toggleSidebar,
|
|
1595
|
-
type: "button",
|
|
1596
|
-
children: collapsed ? ">" : "<"
|
|
1597
|
-
}
|
|
1598
|
-
),
|
|
1599
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "orion-admin-brand-wrap", children: [
|
|
1600
|
-
logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "orion-admin-brand-logo", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { alt: `${brandName} logo`, src: logoUrl }) }) : null,
|
|
1601
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "orion-admin-brand-text", children: [
|
|
1602
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "orion-admin-brand-name", title: brandName, children: collapsed ? brandName.slice(0, 1).toUpperCase() : brandName }),
|
|
1603
|
-
!collapsed ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "orion-admin-brand-subtitle", children: "Studio" }) : null
|
|
1604
|
-
] })
|
|
1605
|
-
] }),
|
|
1606
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("nav", { className: "orion-admin-nav", children: navItems.filter((item) => roleCanAccessNav(userRole, item)).map((item) => {
|
|
1607
|
-
const active = navItemIsActive(pathname, item);
|
|
1608
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1609
|
-
"a",
|
|
1610
|
-
{
|
|
1611
|
-
className: `orion-admin-nav-link ${active ? "is-active" : ""}`,
|
|
1612
|
-
href: item.href,
|
|
1613
|
-
title: item.label,
|
|
1614
|
-
children: item.icon ? collapsed ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NavIcon, { name: item.icon }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { alignItems: "center", display: "flex", gap: "0.6rem" }, children: [
|
|
1615
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NavIcon, { name: item.icon }),
|
|
1616
|
-
item.label
|
|
1617
|
-
] }) : collapsed ? item.label.slice(0, 1) : item.label
|
|
1618
|
-
},
|
|
1619
|
-
item.href
|
|
1620
|
-
);
|
|
1621
|
-
}) }),
|
|
1622
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "orion-admin-sidebar-footer", children: [
|
|
1623
|
-
!collapsed ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1624
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "orion-admin-user-label", children: "Signed in as" }),
|
|
1625
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "orion-admin-user-email", children: userEmail })
|
|
1626
|
-
] }) : null,
|
|
1627
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "orion-admin-logout", disabled: loggingOut, onClick: handleLogout, type: "button", children: loggingOut ? "..." : "Log out" })
|
|
1628
|
-
] })
|
|
1629
|
-
] }),
|
|
1630
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("main", { className: "orion-admin-main", children })
|
|
1631
|
-
] });
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
// src/admin/hooks/useSiteBranding.ts
|
|
1635
|
-
var import_react3 = require("react");
|
|
1636
|
-
var asRecord = (value) => {
|
|
1637
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1638
|
-
return value;
|
|
1639
|
-
};
|
|
1640
|
-
var pickString = (value) => {
|
|
1641
|
-
if (typeof value !== "string") return null;
|
|
1642
|
-
const next = value.trim();
|
|
1643
|
-
return next.length > 0 ? next : null;
|
|
1644
|
-
};
|
|
1645
|
-
var resolveUploadUrl = (value) => {
|
|
1646
|
-
const direct = pickString(value);
|
|
1647
|
-
if (direct) return direct;
|
|
1648
|
-
const record = asRecord(value);
|
|
1649
|
-
if (!record) return null;
|
|
1650
|
-
const fromUrl = pickString(record.url);
|
|
1651
|
-
if (fromUrl) return fromUrl;
|
|
1652
|
-
const fromFilename = pickString(record.filename);
|
|
1653
|
-
if (fromFilename) return `/api/media/file/${fromFilename}`;
|
|
1654
|
-
return null;
|
|
1655
|
-
};
|
|
1656
|
-
var resolveLogoUrl = (settings) => {
|
|
1657
|
-
return resolveUploadUrl(settings.logo) || resolveUploadUrl(settings.adminLogo) || resolveUploadUrl(settings.brandLogo) || null;
|
|
1658
|
-
};
|
|
1659
|
-
var cachedBranding = null;
|
|
1660
|
-
function useSiteBranding(defaultName, defaultLogoUrl) {
|
|
1661
|
-
const [branding, setBranding] = (0, import_react3.useState)(() => {
|
|
1662
|
-
if (cachedBranding) {
|
|
1663
|
-
return {
|
|
1664
|
-
logoUrl: cachedBranding.logoUrl || defaultLogoUrl || null,
|
|
1665
|
-
siteName: cachedBranding.siteName || defaultName || null
|
|
1666
|
-
};
|
|
1667
|
-
}
|
|
1668
|
-
return {
|
|
1669
|
-
logoUrl: defaultLogoUrl || null,
|
|
1670
|
-
siteName: defaultName || null
|
|
1671
|
-
};
|
|
1672
|
-
});
|
|
1673
|
-
(0, import_react3.useEffect)(() => {
|
|
1674
|
-
let cancelled = false;
|
|
1675
|
-
const run = async () => {
|
|
1676
|
-
try {
|
|
1677
|
-
const res = await fetch("/api/globals/site-settings?depth=1", {
|
|
1678
|
-
credentials: "include"
|
|
1679
|
-
});
|
|
1680
|
-
if (!res.ok) return;
|
|
1681
|
-
const data = await res.json();
|
|
1682
|
-
const record = asRecord(data);
|
|
1683
|
-
if (!record) return;
|
|
1684
|
-
const siteName = pickString(record.siteName);
|
|
1685
|
-
const logoUrl = resolveLogoUrl(record);
|
|
1686
|
-
cachedBranding = { logoUrl, siteName };
|
|
1687
|
-
if (!cancelled) {
|
|
1688
|
-
setBranding({
|
|
1689
|
-
logoUrl: logoUrl || defaultLogoUrl || null,
|
|
1690
|
-
siteName: siteName || defaultName || null
|
|
1691
|
-
});
|
|
1692
|
-
}
|
|
1693
|
-
} catch {
|
|
1694
|
-
}
|
|
1695
|
-
};
|
|
1696
|
-
void run();
|
|
1697
|
-
return () => {
|
|
1698
|
-
cancelled = true;
|
|
1699
|
-
};
|
|
1700
|
-
}, [defaultLogoUrl, defaultName]);
|
|
1701
|
-
return branding;
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
// src/admin/components/studio/adminPathUtils.ts
|
|
1705
|
-
var import_react4 = require("react");
|
|
1706
|
-
var DEFAULT_ADMIN_BASE_PATH = "/admin";
|
|
1707
|
-
var normalizePath = (value) => {
|
|
1708
|
-
if (!value || value === "/") return "/";
|
|
1709
|
-
const withLeadingSlash = value.startsWith("/") ? value : `/${value}`;
|
|
1710
|
-
const trimmed = withLeadingSlash.replace(/\/+$/, "");
|
|
1711
|
-
return trimmed.length > 0 ? trimmed : "/";
|
|
1712
|
-
};
|
|
1713
|
-
var normalizeAdminBasePath = (value) => {
|
|
1714
|
-
const normalized = normalizePath(value);
|
|
1715
|
-
return normalized === "/" ? DEFAULT_ADMIN_BASE_PATH : normalized;
|
|
1716
|
-
};
|
|
1717
|
-
var detectAdminBasePath = (pathname, fallback = DEFAULT_ADMIN_BASE_PATH) => {
|
|
1718
|
-
const normalizedPathname = normalizePath(pathname);
|
|
1719
|
-
const normalizedFallback = normalizeAdminBasePath(fallback);
|
|
1720
|
-
const markers = [
|
|
1721
|
-
"/contact-form",
|
|
1722
|
-
"/collections/",
|
|
1723
|
-
"/globals/",
|
|
1724
|
-
"/forms",
|
|
1725
|
-
"/pages/",
|
|
1726
|
-
"/tools",
|
|
1727
|
-
"/media",
|
|
1728
|
-
"/logout",
|
|
1729
|
-
"/login"
|
|
1730
|
-
];
|
|
1731
|
-
for (const marker of markers) {
|
|
1732
|
-
const index = normalizedPathname.indexOf(marker);
|
|
1733
|
-
if (index > 0) {
|
|
1734
|
-
return normalizeAdminBasePath(normalizedPathname.slice(0, index));
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
if (normalizedPathname === normalizedFallback || normalizedPathname.startsWith(`${normalizedFallback}/`)) {
|
|
1738
|
-
return normalizedFallback;
|
|
1739
|
-
}
|
|
1740
|
-
const segments = normalizedPathname.split("/").filter(Boolean);
|
|
1741
|
-
if (segments.length > 0) {
|
|
1742
|
-
return normalizeAdminBasePath(`/${segments[0]}`);
|
|
1743
|
-
}
|
|
1744
|
-
return normalizedFallback;
|
|
1745
|
-
};
|
|
1746
|
-
var isAbsoluteExternalURL2 = (value) => /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value) || value.startsWith("//");
|
|
1747
|
-
var resolveAdminPath = (adminBasePath, targetPath) => {
|
|
1748
|
-
if (!targetPath) return adminBasePath;
|
|
1749
|
-
if (isAbsoluteExternalURL2(targetPath)) return targetPath;
|
|
1750
|
-
const normalizedBasePath = normalizeAdminBasePath(adminBasePath);
|
|
1751
|
-
const normalizedTargetPath = normalizePath(targetPath);
|
|
1752
|
-
if (normalizedTargetPath === "/admin") {
|
|
1753
|
-
return normalizedBasePath;
|
|
1754
|
-
}
|
|
1755
|
-
if (normalizedTargetPath.startsWith("/admin/")) {
|
|
1756
|
-
return `${normalizedBasePath}${normalizedTargetPath.slice("/admin".length)}`;
|
|
1757
|
-
}
|
|
1758
|
-
if (normalizedTargetPath === normalizedBasePath || normalizedTargetPath.startsWith(`${normalizedBasePath}/`)) {
|
|
1759
|
-
return normalizedTargetPath;
|
|
1760
|
-
}
|
|
1761
|
-
if (normalizedTargetPath === "/") {
|
|
1762
|
-
return normalizedBasePath;
|
|
1763
|
-
}
|
|
1764
|
-
return `${normalizedBasePath}${normalizedTargetPath}`;
|
|
1765
|
-
};
|
|
1766
|
-
var useAdminBasePath = (fallback = DEFAULT_ADMIN_BASE_PATH) => {
|
|
1767
|
-
const [adminBasePath, setAdminBasePath] = (0, import_react4.useState)(normalizeAdminBasePath(fallback));
|
|
1768
|
-
(0, import_react4.useEffect)(() => {
|
|
1769
|
-
const update = () => {
|
|
1770
|
-
setAdminBasePath(detectAdminBasePath(window.location.pathname, fallback));
|
|
1771
|
-
};
|
|
1772
|
-
update();
|
|
1773
|
-
window.addEventListener("popstate", update);
|
|
1774
|
-
return () => window.removeEventListener("popstate", update);
|
|
1775
|
-
}, [fallback]);
|
|
1776
|
-
return adminBasePath;
|
|
1777
|
-
};
|
|
1778
|
-
|
|
1779
|
-
// src/admin/components/studio/studioNavModel.ts
|
|
1780
|
-
var getPropString = (props, key, fallback) => {
|
|
1781
|
-
if (!props || typeof props !== "object") return fallback;
|
|
1782
|
-
const direct = props[key];
|
|
1783
|
-
if (typeof direct === "string" && direct.length > 0) return direct;
|
|
1784
|
-
const clientProps = props.clientProps;
|
|
1785
|
-
if (clientProps && typeof clientProps === "object") {
|
|
1786
|
-
const nested = clientProps[key];
|
|
1787
|
-
if (typeof nested === "string" && nested.length > 0) return nested;
|
|
1788
|
-
}
|
|
1789
|
-
return fallback;
|
|
1790
|
-
};
|
|
1791
|
-
var getPropBoolean = (props, key, fallback) => {
|
|
1792
|
-
if (!props || typeof props !== "object") return fallback;
|
|
1793
|
-
const direct = props[key];
|
|
1794
|
-
if (typeof direct === "boolean") return direct;
|
|
1795
|
-
const clientProps = props.clientProps;
|
|
1796
|
-
if (clientProps && typeof clientProps === "object") {
|
|
1797
|
-
const nested = clientProps[key];
|
|
1798
|
-
if (typeof nested === "boolean") return nested;
|
|
1799
|
-
}
|
|
1800
|
-
return fallback;
|
|
1801
|
-
};
|
|
1802
|
-
var getPropStringArray = (props, key, fallback) => {
|
|
1803
|
-
if (!props || typeof props !== "object") return fallback;
|
|
1804
|
-
const read = (candidate) => Array.isArray(candidate) ? candidate.filter((value) => typeof value === "string" && value.length > 0) : null;
|
|
1805
|
-
const direct = read(props[key]);
|
|
1806
|
-
if (direct) return direct;
|
|
1807
|
-
const clientProps = props.clientProps;
|
|
1808
|
-
if (clientProps && typeof clientProps === "object") {
|
|
1809
|
-
const nested = read(clientProps[key]);
|
|
1810
|
-
if (nested) return nested;
|
|
1811
|
-
}
|
|
1812
|
-
return fallback;
|
|
1813
|
-
};
|
|
1814
|
-
var getPropSections = (props) => {
|
|
1815
|
-
if (!props || typeof props !== "object") return [];
|
|
1816
|
-
const direct = resolveStudioSections(props.sections);
|
|
1817
|
-
if (direct.length > 0) return direct;
|
|
1818
|
-
const clientProps = props.clientProps;
|
|
1819
|
-
if (clientProps && typeof clientProps === "object") {
|
|
1820
|
-
return resolveStudioSections(clientProps.sections);
|
|
1821
|
-
}
|
|
1822
|
-
return [];
|
|
1823
|
-
};
|
|
1824
|
-
var readUserRole = (user) => {
|
|
1825
|
-
if (!user || typeof user !== "object") {
|
|
1826
|
-
return void 0;
|
|
1827
|
-
}
|
|
1828
|
-
const role = user.role;
|
|
1829
|
-
return typeof role === "string" ? role : void 0;
|
|
1830
|
-
};
|
|
1831
|
-
var buildStudioNavItems = (props, adminBasePath) => {
|
|
1832
|
-
const formsEnabled = getPropBoolean(props, "formsEnabled", false);
|
|
1833
|
-
const formsCollectionSlug = getPropString(props, "formsCollectionSlug", "forms");
|
|
1834
|
-
const formSubmissionsCollectionSlug = getPropString(
|
|
1835
|
-
props,
|
|
1836
|
-
"formSubmissionsCollectionSlug",
|
|
1837
|
-
"form-submissions"
|
|
1838
|
-
);
|
|
1839
|
-
const formUploadsCollectionSlug = getPropString(props, "formUploadsCollectionSlug", "form-uploads");
|
|
1840
|
-
const mediaCollectionSlug = getPropString(props, "mediaCollectionSlug", "media");
|
|
1841
|
-
const globalsBasePath = getPropString(props, "globalsBasePath", "/globals");
|
|
1842
|
-
const globalsExtraMatchPrefixes = getPropStringArray(props, "globalsExtraMatchPrefixes", []);
|
|
1843
|
-
const sections = getPropSections(props);
|
|
1844
|
-
const pagesPath = resolveAdminPath(adminBasePath, "/pages");
|
|
1845
|
-
const formsPath = resolveAdminPath(adminBasePath, "/forms");
|
|
1846
|
-
const mediaPath = resolveAdminPath(adminBasePath, "/media");
|
|
1847
|
-
const toolsPath = resolveAdminPath(adminBasePath, "/tools");
|
|
1848
|
-
const resolvedGlobalsBasePath = resolveAdminPath(adminBasePath, globalsBasePath);
|
|
1849
|
-
const resolvedGlobalsExtraMatchPrefixes = globalsExtraMatchPrefixes.map(
|
|
1850
|
-
(prefix) => resolveAdminPath(adminBasePath, prefix)
|
|
1851
|
-
);
|
|
1852
|
-
const baseItemsBeforeTools = [
|
|
1853
|
-
{
|
|
1854
|
-
href: adminBasePath,
|
|
1855
|
-
icon: "dashboard",
|
|
1856
|
-
label: "Dashboard",
|
|
1857
|
-
matchPrefixes: [adminBasePath]
|
|
1858
|
-
},
|
|
1859
|
-
{
|
|
1860
|
-
href: pagesPath,
|
|
1861
|
-
icon: "pages",
|
|
1862
|
-
label: "Pages",
|
|
1863
|
-
matchPrefixes: [pagesPath]
|
|
1864
|
-
},
|
|
1865
|
-
...formsEnabled ? [
|
|
1866
|
-
{
|
|
1867
|
-
href: formsPath,
|
|
1868
|
-
icon: "forms",
|
|
1869
|
-
label: "Forms",
|
|
1870
|
-
matchPrefixes: [
|
|
1871
|
-
formsPath,
|
|
1872
|
-
resolveAdminPath(adminBasePath, `/collections/${formsCollectionSlug}`),
|
|
1873
|
-
resolveAdminPath(adminBasePath, `/collections/${formSubmissionsCollectionSlug}`),
|
|
1874
|
-
resolveAdminPath(adminBasePath, `/collections/${formUploadsCollectionSlug}`)
|
|
1875
|
-
]
|
|
1876
|
-
}
|
|
1877
|
-
] : [],
|
|
1878
|
-
{
|
|
1879
|
-
href: resolvedGlobalsBasePath,
|
|
1880
|
-
icon: "globals",
|
|
1881
|
-
label: "Globals",
|
|
1882
|
-
matchPrefixes: [
|
|
1883
|
-
resolvedGlobalsBasePath,
|
|
1884
|
-
resolveAdminPath(adminBasePath, "/globals"),
|
|
1885
|
-
...resolvedGlobalsExtraMatchPrefixes
|
|
1886
|
-
]
|
|
1887
|
-
},
|
|
1888
|
-
{
|
|
1889
|
-
href: mediaPath,
|
|
1890
|
-
icon: "media",
|
|
1891
|
-
label: "Media",
|
|
1892
|
-
matchPrefixes: [mediaPath, resolveAdminPath(adminBasePath, `/collections/${mediaCollectionSlug}`)]
|
|
1893
|
-
}
|
|
1894
|
-
];
|
|
1895
|
-
const adminToolsItem = {
|
|
1896
|
-
href: toolsPath,
|
|
1897
|
-
icon: "tools",
|
|
1898
|
-
label: "Admin Tools",
|
|
1899
|
-
matchPrefixes: [toolsPath, resolveAdminPath(adminBasePath, "/collections/users")],
|
|
1900
|
-
roles: ["admin"]
|
|
1901
|
-
};
|
|
1902
|
-
const extensionItems = sections.map((section) => ({
|
|
1903
|
-
href: resolveAdminPath(adminBasePath, section.href),
|
|
1904
|
-
...section.icon ? { icon: section.icon } : {},
|
|
1905
|
-
label: section.label,
|
|
1906
|
-
matchPrefixes: section.matchPrefixes.map((prefix) => resolveAdminPath(adminBasePath, prefix)),
|
|
1907
|
-
roles: section.roles
|
|
1908
|
-
}));
|
|
1909
|
-
return [...baseItemsBeforeTools, ...extensionItems, adminToolsItem];
|
|
1910
|
-
};
|
|
1911
|
-
|
|
1912
|
-
// src/admin/components/studio/StudioSectionLayout.tsx
|
|
1913
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1914
|
-
function StudioSectionLayout({ children, navProps }) {
|
|
1915
|
-
const { user } = (0, import_ui.useAuth)();
|
|
1916
|
-
const pathname = (0, import_navigation.usePathname)() || "";
|
|
1917
|
-
const router = (0, import_navigation.useRouter)();
|
|
1918
|
-
const adminBasePath = useAdminBasePath();
|
|
1919
|
-
const defaultBrandName = getPropString(navProps, "brandName", "Orion Studio");
|
|
1920
|
-
const defaultLogoUrl = getPropString(navProps, "logoUrl", "");
|
|
1921
|
-
const navItems = (0, import_react5.useMemo)(
|
|
1922
|
-
() => buildStudioNavItems(navProps, adminBasePath),
|
|
1923
|
-
[adminBasePath, navProps]
|
|
1924
|
-
);
|
|
1925
|
-
const branding = useSiteBranding(defaultBrandName, defaultLogoUrl || void 0);
|
|
1926
|
-
(0, import_react5.useLayoutEffect)(() => {
|
|
1927
|
-
document.body.classList.add("orion-studio-shell-active");
|
|
1928
|
-
return () => {
|
|
1929
|
-
document.body.classList.remove("orion-studio-shell-active");
|
|
1930
|
-
};
|
|
1931
|
-
}, []);
|
|
1932
|
-
const logout = (0, import_react5.useMemo)(
|
|
1933
|
-
() => async () => {
|
|
1934
|
-
await fetch("/api/users/logout", {
|
|
1935
|
-
credentials: "include",
|
|
1936
|
-
method: "POST"
|
|
1937
|
-
});
|
|
1938
|
-
router.push(resolveAdminPath(adminBasePath, "/login"));
|
|
1939
|
-
router.refresh();
|
|
1940
|
-
},
|
|
1941
|
-
[adminBasePath, router]
|
|
1942
|
-
);
|
|
1943
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1944
|
-
AdminShellClient,
|
|
1945
|
-
{
|
|
1946
|
-
brandName: branding.siteName || defaultBrandName,
|
|
1947
|
-
logoUrl: branding.logoUrl || defaultLogoUrl || void 0,
|
|
1948
|
-
navItems,
|
|
1949
|
-
onLogout: logout,
|
|
1950
|
-
pathname,
|
|
1951
|
-
storageKey: "orion-admin-sidebar-collapsed-v1",
|
|
1952
|
-
userEmail: typeof user?.email === "string" ? user.email : "user",
|
|
1953
|
-
userRole: readUserRole(user),
|
|
1954
|
-
children
|
|
1955
|
-
}
|
|
1956
|
-
);
|
|
1957
|
-
}
|
|
1958
|
-
|
|
1959
|
-
// src/admin/components/studio/AdminStudioDashboard.tsx
|
|
1960
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1961
|
-
var DEFAULT_ADMIN_BASE_PATH2 = "/admin";
|
|
1962
|
-
var normalizePath2 = (value) => {
|
|
1963
|
-
if (!value || value === "/") return "/";
|
|
1964
|
-
const withLeadingSlash = value.startsWith("/") ? value : `/${value}`;
|
|
1965
|
-
const trimmed = withLeadingSlash.replace(/\/+$/, "");
|
|
1966
|
-
return trimmed.length > 0 ? trimmed : "/";
|
|
1967
|
-
};
|
|
1968
|
-
var normalizeAdminBasePath2 = (value) => {
|
|
1969
|
-
const normalized = normalizePath2(value);
|
|
1970
|
-
return normalized === "/" ? DEFAULT_ADMIN_BASE_PATH2 : normalized;
|
|
1971
|
-
};
|
|
1972
|
-
var isAbsoluteExternalURL3 = (value) => /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value) || value.startsWith("//");
|
|
1973
|
-
var resolveAdminPath2 = (adminBasePath, targetPath) => {
|
|
1974
|
-
if (!targetPath) return adminBasePath;
|
|
1975
|
-
if (isAbsoluteExternalURL3(targetPath)) return targetPath;
|
|
1976
|
-
const normalizedBasePath = normalizeAdminBasePath2(adminBasePath);
|
|
1977
|
-
const normalizedTargetPath = normalizePath2(targetPath);
|
|
1978
|
-
if (normalizedTargetPath === "/admin") {
|
|
1979
|
-
return normalizedBasePath;
|
|
1980
|
-
}
|
|
1981
|
-
if (normalizedTargetPath.startsWith("/admin/")) {
|
|
1982
|
-
return `${normalizedBasePath}${normalizedTargetPath.slice("/admin".length)}`;
|
|
1983
|
-
}
|
|
1984
|
-
if (normalizedTargetPath === normalizedBasePath || normalizedTargetPath.startsWith(`${normalizedBasePath}/`)) {
|
|
1985
|
-
return normalizedTargetPath;
|
|
1986
|
-
}
|
|
1987
|
-
if (normalizedTargetPath === "/") {
|
|
1988
|
-
return normalizedBasePath;
|
|
1989
|
-
}
|
|
1990
|
-
return `${normalizedBasePath}${normalizedTargetPath}`;
|
|
1991
|
-
};
|
|
1992
|
-
var getPropString2 = (props, key, fallback) => {
|
|
1993
|
-
if (!props || typeof props !== "object") return fallback;
|
|
1994
|
-
const direct = props[key];
|
|
1995
|
-
if (typeof direct === "string" && direct.length > 0) return direct;
|
|
1996
|
-
const clientProps = props.clientProps;
|
|
1997
|
-
if (clientProps && typeof clientProps === "object") {
|
|
1998
|
-
const nested = clientProps[key];
|
|
1999
|
-
if (typeof nested === "string" && nested.length > 0) return nested;
|
|
2000
|
-
}
|
|
2001
|
-
return fallback;
|
|
2002
|
-
};
|
|
2003
|
-
var getPropBoolean2 = (props, key, fallback) => {
|
|
2004
|
-
if (!props || typeof props !== "object") return fallback;
|
|
2005
|
-
const direct = props[key];
|
|
2006
|
-
if (typeof direct === "boolean") return direct;
|
|
2007
|
-
const clientProps = props.clientProps;
|
|
2008
|
-
if (clientProps && typeof clientProps === "object") {
|
|
2009
|
-
const nested = clientProps[key];
|
|
2010
|
-
if (typeof nested === "boolean") return nested;
|
|
2011
|
-
}
|
|
2012
|
-
return fallback;
|
|
2013
|
-
};
|
|
2014
|
-
var getPropSections2 = (props) => {
|
|
2015
|
-
if (!props || typeof props !== "object") return [];
|
|
2016
|
-
const direct = resolveStudioSections(props.sections);
|
|
2017
|
-
if (direct.length > 0) return direct;
|
|
2018
|
-
const clientProps = props.clientProps;
|
|
2019
|
-
if (clientProps && typeof clientProps === "object") {
|
|
2020
|
-
return resolveStudioSections(clientProps.sections);
|
|
2021
|
-
}
|
|
2022
|
-
return [];
|
|
2023
|
-
};
|
|
2024
|
-
var getPropDashboardPanels = (props) => {
|
|
2025
|
-
if (!props || typeof props !== "object") return [];
|
|
2026
|
-
const direct = resolveStudioSectionDashboards(props.dashboardPanels);
|
|
2027
|
-
if (direct.length > 0) return direct;
|
|
2028
|
-
const clientProps = props.clientProps;
|
|
2029
|
-
if (clientProps && typeof clientProps === "object") {
|
|
2030
|
-
return resolveStudioSectionDashboards(clientProps.dashboardPanels);
|
|
2031
|
-
}
|
|
2032
|
-
return [];
|
|
2033
|
-
};
|
|
2034
|
-
var readImportMap = (props) => {
|
|
2035
|
-
if (!props || typeof props !== "object") return void 0;
|
|
2036
|
-
const direct = props.importMap;
|
|
2037
|
-
if (direct && typeof direct === "object") {
|
|
2038
|
-
return direct;
|
|
2039
|
-
}
|
|
2040
|
-
const payloadLike = props.payload;
|
|
2041
|
-
if (payloadLike && typeof payloadLike === "object") {
|
|
2042
|
-
const nested = payloadLike.importMap;
|
|
2043
|
-
if (nested && typeof nested === "object") {
|
|
2044
|
-
return nested;
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
2047
|
-
const initPageResult = props.initPageResult;
|
|
2048
|
-
if (initPageResult && typeof initPageResult === "object") {
|
|
2049
|
-
const req = initPageResult.req;
|
|
2050
|
-
if (req && typeof req === "object") {
|
|
2051
|
-
const payload = req.payload;
|
|
2052
|
-
if (payload && typeof payload === "object") {
|
|
2053
|
-
const nested = payload.importMap;
|
|
2054
|
-
if (nested && typeof nested === "object") {
|
|
2055
|
-
return nested;
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
|
-
return void 0;
|
|
2061
|
-
};
|
|
2062
|
-
var readUserRole2 = (props) => {
|
|
2063
|
-
if (!props || typeof props !== "object") return void 0;
|
|
2064
|
-
const user = props.user;
|
|
2065
|
-
if (user && typeof user === "object") {
|
|
2066
|
-
const role = user.role;
|
|
2067
|
-
if (typeof role === "string") {
|
|
2068
|
-
return role;
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
const initPageResult = props.initPageResult;
|
|
2072
|
-
if (initPageResult && typeof initPageResult === "object") {
|
|
2073
|
-
const req = initPageResult.req;
|
|
2074
|
-
if (req && typeof req === "object") {
|
|
2075
|
-
const nestedUser = req.user;
|
|
2076
|
-
if (nestedUser && typeof nestedUser === "object") {
|
|
2077
|
-
const role = nestedUser.role;
|
|
2078
|
-
if (typeof role === "string") {
|
|
2079
|
-
return role;
|
|
2080
|
-
}
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
}
|
|
2084
|
-
return void 0;
|
|
2085
|
-
};
|
|
2086
|
-
var readAdminBasePath = (props) => {
|
|
2087
|
-
if (!props || typeof props !== "object") {
|
|
2088
|
-
return DEFAULT_ADMIN_BASE_PATH2;
|
|
2089
|
-
}
|
|
2090
|
-
const payloadLike = props.payload;
|
|
2091
|
-
if (payloadLike && typeof payloadLike === "object") {
|
|
2092
|
-
const config = payloadLike.config;
|
|
2093
|
-
const routes = config && typeof config === "object" ? config.routes : null;
|
|
2094
|
-
const admin = routes && typeof routes === "object" ? routes.admin : null;
|
|
2095
|
-
if (typeof admin === "string" && admin.length > 0) {
|
|
2096
|
-
return normalizeAdminBasePath2(admin);
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
const initPageResult = props.initPageResult;
|
|
2100
|
-
if (initPageResult && typeof initPageResult === "object") {
|
|
2101
|
-
const req = initPageResult.req;
|
|
2102
|
-
if (req && typeof req === "object") {
|
|
2103
|
-
const nestedPayload = req.payload;
|
|
2104
|
-
if (nestedPayload && typeof nestedPayload === "object") {
|
|
2105
|
-
const config = nestedPayload.config;
|
|
2106
|
-
const routes = config && typeof config === "object" ? config.routes : null;
|
|
2107
|
-
const admin = routes && typeof routes === "object" ? routes.admin : null;
|
|
2108
|
-
if (typeof admin === "string" && admin.length > 0) {
|
|
2109
|
-
return normalizeAdminBasePath2(admin);
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
return DEFAULT_ADMIN_BASE_PATH2;
|
|
2115
|
-
};
|
|
2116
|
-
var canAccess2 = (role, roles) => {
|
|
2117
|
-
if (!roles || roles.length === 0) {
|
|
2118
|
-
return true;
|
|
2119
|
-
}
|
|
2120
|
-
if (!role) {
|
|
2121
|
-
return false;
|
|
2122
|
-
}
|
|
2123
|
-
return roles.includes(role);
|
|
2124
|
-
};
|
|
2125
|
-
var buildSectionLinks = (adminBasePath, sections, formsEnabled, globalsBasePath) => {
|
|
2126
|
-
const links = [
|
|
2127
|
-
{
|
|
2128
|
-
href: resolveAdminPath2(adminBasePath, "/pages"),
|
|
2129
|
-
id: "pages",
|
|
2130
|
-
label: "Pages"
|
|
2131
|
-
},
|
|
2132
|
-
...formsEnabled ? [
|
|
2133
|
-
{
|
|
2134
|
-
href: resolveAdminPath2(adminBasePath, "/forms"),
|
|
2135
|
-
id: "forms",
|
|
2136
|
-
label: "Forms",
|
|
2137
|
-
roles: ["admin", "editor"]
|
|
2138
|
-
}
|
|
2139
|
-
] : [],
|
|
2140
|
-
{
|
|
2141
|
-
href: resolveAdminPath2(adminBasePath, globalsBasePath),
|
|
2142
|
-
id: "globals",
|
|
2143
|
-
label: "Globals"
|
|
2144
|
-
},
|
|
2145
|
-
{
|
|
2146
|
-
href: resolveAdminPath2(adminBasePath, "/media"),
|
|
2147
|
-
id: "media",
|
|
2148
|
-
label: "Media"
|
|
2149
|
-
},
|
|
2150
|
-
...sections.map((section) => ({
|
|
2151
|
-
href: resolveAdminPath2(adminBasePath, section.href),
|
|
2152
|
-
id: section.id,
|
|
2153
|
-
label: section.label,
|
|
2154
|
-
...section.roles ? { roles: section.roles } : {}
|
|
2155
|
-
})),
|
|
2156
|
-
{
|
|
2157
|
-
href: resolveAdminPath2(adminBasePath, "/tools"),
|
|
2158
|
-
id: "admin-tools",
|
|
2159
|
-
label: "Admin Tools",
|
|
2160
|
-
roles: ["admin"]
|
|
2161
|
-
}
|
|
2162
|
-
];
|
|
2163
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2164
|
-
return links.filter((link) => {
|
|
2165
|
-
if (seen.has(link.id)) {
|
|
2166
|
-
return false;
|
|
2167
|
-
}
|
|
2168
|
-
seen.add(link.id);
|
|
2169
|
-
return true;
|
|
2170
|
-
});
|
|
2171
|
-
};
|
|
2172
|
-
function DashboardPanelFallback({ label }) {
|
|
2173
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "orion-dashboard-extension-fallback", children: [
|
|
2174
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "orion-dashboard-panel-kicker", children: "Extension Unavailable" }),
|
|
2175
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: label }),
|
|
2176
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: "This dashboard panel could not be rendered, but the rest of the dashboard is still available." })
|
|
2177
|
-
] });
|
|
2178
|
-
}
|
|
2179
|
-
function buildExtensionPanels(adminBasePath, importMap, panels, userRole) {
|
|
2180
|
-
const visiblePanels = panels.filter((panel) => canAccess2(userRole, panel.roles));
|
|
2181
|
-
return visiblePanels.map((panel) => {
|
|
2182
|
-
const href = resolveAdminPath2(adminBasePath, panel.href);
|
|
2183
|
-
return {
|
|
2184
|
-
id: panel.id,
|
|
2185
|
-
node: importMap ? (0, import_RenderServerComponent.RenderServerComponent)({
|
|
2186
|
-
Component: panel.Component,
|
|
2187
|
-
Fallback: () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DashboardPanelFallback, { label: panel.label }),
|
|
2188
|
-
importMap,
|
|
2189
|
-
serverProps: {
|
|
2190
|
-
adminBasePath,
|
|
2191
|
-
href,
|
|
2192
|
-
label: panel.label
|
|
2193
|
-
}
|
|
2194
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DashboardPanelFallback, { label: panel.label }),
|
|
2195
|
-
span: panel.span
|
|
2196
|
-
};
|
|
2197
|
-
});
|
|
2198
|
-
}
|
|
2199
|
-
function AdminStudioDashboard(rawProps) {
|
|
2200
|
-
const props = rawProps || {};
|
|
2201
|
-
const formsEnabled = getPropBoolean2(props, "formsEnabled", false);
|
|
2202
|
-
const globalsBasePath = getPropString2(props, "globalsBasePath", "/globals");
|
|
2203
|
-
const sections = getPropSections2(props);
|
|
2204
|
-
const dashboardPanels = getPropDashboardPanels(props);
|
|
2205
|
-
const pagesCollectionSlug = getPropString2(props, "pagesCollectionSlug", "pages");
|
|
2206
|
-
const formsCollectionSlug = getPropString2(props, "formsCollectionSlug", "forms");
|
|
2207
|
-
const formSubmissionsCollectionSlug = getPropString2(
|
|
2208
|
-
props,
|
|
2209
|
-
"formSubmissionsCollectionSlug",
|
|
2210
|
-
"form-submissions"
|
|
2211
|
-
);
|
|
2212
|
-
const mediaCollectionSlug = getPropString2(props, "mediaCollectionSlug", "media");
|
|
2213
|
-
const adminBasePath = readAdminBasePath(props);
|
|
2214
|
-
const importMap = readImportMap(props);
|
|
2215
|
-
const userRole = readUserRole2(props);
|
|
2216
|
-
const navProps = {
|
|
2217
|
-
brandName: getPropString2(props, "brandName", "Orion Studio"),
|
|
2218
|
-
dashboardPanels,
|
|
2219
|
-
formSubmissionsCollectionSlug,
|
|
2220
|
-
formsCollectionSlug,
|
|
2221
|
-
formsEnabled,
|
|
2222
|
-
globalsBasePath,
|
|
2223
|
-
logoUrl: getPropString2(props, "logoUrl", ""),
|
|
2224
|
-
mediaCollectionSlug,
|
|
2225
|
-
pagesCollectionSlug,
|
|
2226
|
-
sections
|
|
2227
|
-
};
|
|
2228
|
-
const extensionPanels = buildExtensionPanels(adminBasePath, importMap, dashboardPanels, userRole);
|
|
2229
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StudioSectionLayout, { navProps, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2230
|
-
AdminPage,
|
|
2231
|
-
{
|
|
2232
|
-
breadcrumbs: [{ label: "Dashboard" }],
|
|
2233
|
-
description: "What needs attention, what changed recently, and how the site is performing.",
|
|
2234
|
-
title: "Studio",
|
|
2235
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2236
|
-
AdminStudioDashboardClient,
|
|
2237
|
-
{
|
|
2238
|
-
formSubmissionsCollectionSlug,
|
|
2239
|
-
formsCollectionSlug,
|
|
2240
|
-
formsEnabled,
|
|
2241
|
-
formsPath: resolveAdminPath2(adminBasePath, "/forms"),
|
|
2242
|
-
globalsBasePath: resolveAdminPath2(adminBasePath, globalsBasePath),
|
|
2243
|
-
mediaCollectionSlug,
|
|
2244
|
-
mediaPath: resolveAdminPath2(adminBasePath, "/media"),
|
|
2245
|
-
pagesCollectionSlug,
|
|
2246
|
-
pagesPath: resolveAdminPath2(adminBasePath, "/pages"),
|
|
2247
|
-
sectionLinks: buildSectionLinks(adminBasePath, sections, formsEnabled, globalsBasePath),
|
|
2248
|
-
toolsPath: resolveAdminPath2(adminBasePath, "/tools"),
|
|
2249
|
-
userRole,
|
|
2250
|
-
children: extensionPanels.map((panel) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2251
|
-
"div",
|
|
2252
|
-
{
|
|
2253
|
-
className: [
|
|
2254
|
-
"orion-dashboard-extension-panel",
|
|
2255
|
-
panel.span === "full" ? "is-full" : "is-half"
|
|
2256
|
-
].filter(Boolean).join(" "),
|
|
2257
|
-
children: panel.node
|
|
2258
|
-
},
|
|
2259
|
-
panel.id
|
|
2260
|
-
))
|
|
2261
|
-
}
|
|
2262
|
-
)
|
|
2263
|
-
}
|
|
2264
|
-
) });
|
|
2265
|
-
}
|
|
2266
|
-
|
|
2267
779
|
// src/admin/helpers/withTooltips.ts
|
|
2268
780
|
var defaultTooltips = {
|
|
2269
781
|
title: "The main title displayed on this page.",
|
|
@@ -2534,6 +1046,36 @@ __export(admin_app_exports, {
|
|
|
2534
1046
|
roleCanAccessNav: () => roleCanAccessNav
|
|
2535
1047
|
});
|
|
2536
1048
|
|
|
1049
|
+
// src/admin-app/components/AdminBreadcrumbs.tsx
|
|
1050
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1051
|
+
function AdminBreadcrumbs({ items }) {
|
|
1052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { "aria-label": "Breadcrumb", className: "orion-admin-breadcrumbs", children: items.map((item, index) => {
|
|
1053
|
+
const isLast = index === items.length - 1;
|
|
1054
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
1055
|
+
item.href && !isLast ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: item.href, children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: item.label }),
|
|
1056
|
+
!isLast ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "orion-admin-breadcrumb-sep", children: "/" }) : null
|
|
1057
|
+
] }, `${item.label}-${index}`);
|
|
1058
|
+
}) });
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
// src/admin-app/components/AdminPage.tsx
|
|
1062
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1063
|
+
function AdminPage({ title, description, breadcrumbs, actions, children }) {
|
|
1064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-page", children: [
|
|
1065
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-page-header", children: [
|
|
1066
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AdminBreadcrumbs, { items: breadcrumbs }),
|
|
1067
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-page-title-row", children: [
|
|
1068
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
1069
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { children: title }),
|
|
1070
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: description }) : null
|
|
1071
|
+
] }),
|
|
1072
|
+
actions ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-page-actions", children: actions }) : null
|
|
1073
|
+
] })
|
|
1074
|
+
] }),
|
|
1075
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-page-content", children })
|
|
1076
|
+
] });
|
|
1077
|
+
}
|
|
1078
|
+
|
|
2537
1079
|
// src/admin-app/nestedNavigation.ts
|
|
2538
1080
|
var normalizeNestedNavItems = (items) => {
|
|
2539
1081
|
const deduped = [];
|
|
@@ -4330,7 +2872,7 @@ var TestimonialsBlock = {
|
|
|
4330
2872
|
};
|
|
4331
2873
|
|
|
4332
2874
|
// src/blocks/components/BuilderBlockLabel.tsx
|
|
4333
|
-
var
|
|
2875
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
4334
2876
|
var blockTitles = {
|
|
4335
2877
|
bookingEmbed: "Booking Embed",
|
|
4336
2878
|
cta: "Call to Action",
|
|
@@ -4357,8 +2899,8 @@ function BuilderBlockLabel({ blockType, rowLabel, rowNumber }) {
|
|
|
4357
2899
|
const fallbackTitle = blockTitles[blockType] || blockType;
|
|
4358
2900
|
const title = rowLabel && rowLabel.trim().length > 0 ? rowLabel : fallbackTitle;
|
|
4359
2901
|
const tag = blockEmojis[blockType] || "Section";
|
|
4360
|
-
return /* @__PURE__ */ (0,
|
|
4361
|
-
/* @__PURE__ */ (0,
|
|
2902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { alignItems: "center", display: "flex", gap: 8 }, children: [
|
|
2903
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
4362
2904
|
"span",
|
|
4363
2905
|
{
|
|
4364
2906
|
style: {
|
|
@@ -4373,7 +2915,7 @@ function BuilderBlockLabel({ blockType, rowLabel, rowNumber }) {
|
|
|
4373
2915
|
children: tag
|
|
4374
2916
|
}
|
|
4375
2917
|
),
|
|
4376
|
-
/* @__PURE__ */ (0,
|
|
2918
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { fontWeight: 700 }, children: [
|
|
4377
2919
|
typeof rowNumber === "number" ? `${rowNumber + 1}. ` : "",
|
|
4378
2920
|
title
|
|
4379
2921
|
] })
|
|
@@ -4920,18 +3462,18 @@ function createStudioRegistry(modules) {
|
|
|
4920
3462
|
listNodeTypes: () => [...nodeTypes]
|
|
4921
3463
|
};
|
|
4922
3464
|
}
|
|
4923
|
-
function validateStudioDocument(
|
|
3465
|
+
function validateStudioDocument(document, modules) {
|
|
4924
3466
|
const issues = [];
|
|
4925
|
-
if (
|
|
3467
|
+
if (document.schemaVersion !== 1) {
|
|
4926
3468
|
issues.push(makeIssue("Unsupported schema version", "schemaVersion", "studio.schemaVersion"));
|
|
4927
3469
|
}
|
|
4928
|
-
if (!Array.isArray(
|
|
3470
|
+
if (!Array.isArray(document.nodes)) {
|
|
4929
3471
|
issues.push(makeIssue("Nodes must be an array", "nodes", "studio.nodes"));
|
|
4930
3472
|
return issues;
|
|
4931
3473
|
}
|
|
4932
3474
|
const registry = createStudioRegistry(modules);
|
|
4933
3475
|
const nodeIDs = /* @__PURE__ */ new Set();
|
|
4934
|
-
|
|
3476
|
+
document.nodes.forEach((node, index) => {
|
|
4935
3477
|
if (!node.id) {
|
|
4936
3478
|
issues.push(makeIssue("Node id is required", `nodes.${index}.id`, "studio.node.id"));
|
|
4937
3479
|
}
|
|
@@ -4945,15 +3487,15 @@ function validateStudioDocument(document2, modules) {
|
|
|
4945
3487
|
});
|
|
4946
3488
|
for (const module2 of modules) {
|
|
4947
3489
|
for (const validate of module2.validators) {
|
|
4948
|
-
issues.push(...validate(
|
|
3490
|
+
issues.push(...validate(document));
|
|
4949
3491
|
}
|
|
4950
3492
|
}
|
|
4951
3493
|
return issues;
|
|
4952
3494
|
}
|
|
4953
|
-
function compileStudioDocument(
|
|
4954
|
-
const issues = validateStudioDocument(
|
|
3495
|
+
function compileStudioDocument(document, modules) {
|
|
3496
|
+
const issues = validateStudioDocument(document, modules);
|
|
4955
3497
|
const compilerEntries = modules.filter((mod) => typeof mod.compiler?.compileNode === "function").map((mod) => mod.compiler?.compileNode);
|
|
4956
|
-
const layout =
|
|
3498
|
+
const layout = document.nodes.map((node) => {
|
|
4957
3499
|
for (const compileNode of compilerEntries) {
|
|
4958
3500
|
if (!compileNode) {
|
|
4959
3501
|
continue;
|
|
@@ -5290,7 +3832,7 @@ var layoutToStudioDocument = (layout, title, metadata) => {
|
|
|
5290
3832
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5291
3833
|
};
|
|
5292
3834
|
};
|
|
5293
|
-
var studioDocumentToLayout = (
|
|
3835
|
+
var studioDocumentToLayout = (document) => document.nodes.map(
|
|
5294
3836
|
(node) => migrateBlockToSettingsV2({
|
|
5295
3837
|
id: node.id,
|
|
5296
3838
|
blockType: node.type,
|
|
@@ -5324,7 +3866,7 @@ function withStudioDocumentLayout(page) {
|
|
|
5324
3866
|
}
|
|
5325
3867
|
return page;
|
|
5326
3868
|
}
|
|
5327
|
-
function
|
|
3869
|
+
function normalizePath(segments) {
|
|
5328
3870
|
if (!segments || segments.length === 0) {
|
|
5329
3871
|
return "/";
|
|
5330
3872
|
}
|
|
@@ -5381,7 +3923,7 @@ function createPageQueries(getPayloadClient, contentTag = "website-content") {
|
|
|
5381
3923
|
{ tags: [contentTag] }
|
|
5382
3924
|
);
|
|
5383
3925
|
async function getPageBySegments(segments, draft = false) {
|
|
5384
|
-
const path2 =
|
|
3926
|
+
const path2 = normalizePath(segments);
|
|
5385
3927
|
const payload = await getPayloadClient();
|
|
5386
3928
|
if (draft) {
|
|
5387
3929
|
return queryPageByPath(payload, path2, true);
|
|
@@ -5993,8 +4535,8 @@ var hydrateRelationship = (valueFromStudio, valueFromLayout) => {
|
|
|
5993
4535
|
}
|
|
5994
4536
|
return valueFromLayout;
|
|
5995
4537
|
};
|
|
5996
|
-
var hydrateDocumentWithLayoutRelations = (
|
|
5997
|
-
const nextNodes =
|
|
4538
|
+
var hydrateDocumentWithLayoutRelations = (document, layout) => {
|
|
4539
|
+
const nextNodes = document.nodes.map((node, index) => {
|
|
5998
4540
|
const layoutBlock = layout[index];
|
|
5999
4541
|
if (!isRecord5(layoutBlock)) {
|
|
6000
4542
|
return node;
|
|
@@ -6033,17 +4575,17 @@ var hydrateDocumentWithLayoutRelations = (document2, layout) => {
|
|
|
6033
4575
|
};
|
|
6034
4576
|
});
|
|
6035
4577
|
return {
|
|
6036
|
-
...
|
|
4578
|
+
...document,
|
|
6037
4579
|
nodes: nextNodes
|
|
6038
4580
|
};
|
|
6039
4581
|
};
|
|
6040
|
-
var normalizeDocument = (
|
|
6041
|
-
...
|
|
4582
|
+
var normalizeDocument = (document) => ({
|
|
4583
|
+
...document,
|
|
6042
4584
|
schemaVersion: 1,
|
|
6043
4585
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6044
4586
|
});
|
|
6045
|
-
var normalizeLegacyHeroDefaults = (
|
|
6046
|
-
const nodes =
|
|
4587
|
+
var normalizeLegacyHeroDefaults = (document) => {
|
|
4588
|
+
const nodes = document.nodes.map((node) => {
|
|
6047
4589
|
if (node.type !== "hero" || !isRecord5(node.data)) {
|
|
6048
4590
|
return node;
|
|
6049
4591
|
}
|
|
@@ -6061,7 +4603,7 @@ var normalizeLegacyHeroDefaults = (document2) => {
|
|
|
6061
4603
|
};
|
|
6062
4604
|
});
|
|
6063
4605
|
return {
|
|
6064
|
-
...
|
|
4606
|
+
...document,
|
|
6065
4607
|
nodes
|
|
6066
4608
|
};
|
|
6067
4609
|
};
|
|
@@ -6110,9 +4652,9 @@ var createStudioPageService = ({
|
|
|
6110
4652
|
title: typeof page.title === "string" ? page.title : "Untitled Page"
|
|
6111
4653
|
};
|
|
6112
4654
|
},
|
|
6113
|
-
validateStudioDocument: (
|
|
6114
|
-
saveDraft: async (pageID,
|
|
6115
|
-
const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(
|
|
4655
|
+
validateStudioDocument: (document) => validateStudioDocument(document, modules),
|
|
4656
|
+
saveDraft: async (pageID, document, _metadata) => {
|
|
4657
|
+
const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(document));
|
|
6116
4658
|
const compileResult = compileStudioDocument(normalizedDocument, modules);
|
|
6117
4659
|
await payload.update({
|
|
6118
4660
|
collection: collectionSlug,
|
|
@@ -6132,8 +4674,8 @@ var createStudioPageService = ({
|
|
|
6132
4674
|
status: "draft"
|
|
6133
4675
|
};
|
|
6134
4676
|
},
|
|
6135
|
-
publish: async (pageID,
|
|
6136
|
-
const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(
|
|
4677
|
+
publish: async (pageID, document, _metadata) => {
|
|
4678
|
+
const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(document));
|
|
6137
4679
|
const compileResult = compileStudioDocument(normalizedDocument, modules);
|
|
6138
4680
|
assertCanPublish(compileResult.issues);
|
|
6139
4681
|
await payload.update({
|
|
@@ -6413,9 +4955,9 @@ var pageNodeTypes = Object.keys(defaultNodeData).map((type) => ({
|
|
|
6413
4955
|
return data;
|
|
6414
4956
|
}
|
|
6415
4957
|
}));
|
|
6416
|
-
var validatePageDocument = (
|
|
4958
|
+
var validatePageDocument = (document) => {
|
|
6417
4959
|
const issues = [];
|
|
6418
|
-
if (!
|
|
4960
|
+
if (!document.title || document.title.trim().length === 0) {
|
|
6419
4961
|
issues.push({
|
|
6420
4962
|
code: "pages.title.required",
|
|
6421
4963
|
message: "Page title is required before publishing.",
|
|
@@ -6423,7 +4965,7 @@ var validatePageDocument = (document2) => {
|
|
|
6423
4965
|
severity: "error"
|
|
6424
4966
|
});
|
|
6425
4967
|
}
|
|
6426
|
-
if (
|
|
4968
|
+
if (document.nodes.length === 0) {
|
|
6427
4969
|
issues.push({
|
|
6428
4970
|
code: "pages.nodes.required",
|
|
6429
4971
|
message: "At least one section is required.",
|
|
@@ -6431,7 +4973,7 @@ var validatePageDocument = (document2) => {
|
|
|
6431
4973
|
severity: "error"
|
|
6432
4974
|
});
|
|
6433
4975
|
}
|
|
6434
|
-
|
|
4976
|
+
document.nodes.forEach((node, index) => {
|
|
6435
4977
|
if (node.type === "hero" && typeof node.data.headline !== "string") {
|
|
6436
4978
|
issues.push({
|
|
6437
4979
|
code: "pages.hero.headline",
|