@orion-studios/payload-studio 0.6.0-beta.3 → 0.6.0-beta.4
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 +0 -1
- package/dist/admin/client.d.ts +0 -1
- package/dist/admin/client.js +887 -973
- package/dist/admin/client.mjs +600 -687
- package/dist/admin/index.d.mts +2 -1
- package/dist/admin/index.d.ts +2 -1
- package/dist/admin/index.js +1505 -1
- package/dist/admin/index.mjs +4 -2
- package/dist/admin-app/index.mjs +4 -4
- package/dist/admin-app/styles.css +362 -0
- package/dist/chunk-DYXSAVUQ.mjs +2372 -0
- package/dist/{chunk-RKTIFEUY.mjs → chunk-EHUE4LCT.mjs} +3 -33
- package/dist/chunk-Z6L5K5MH.mjs +64 -0
- package/dist/index-DEkV-sMs.d.mts +191 -0
- package/dist/index-bbA3HSxa.d.ts +191 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1521 -63
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-QJAWO6K3.mjs +0 -910
- package/dist/chunk-W2UOCJDX.mjs +0 -32
- package/dist/index-B6_D4Hm4.d.ts +0 -439
- package/dist/index-CYaWadBl.d.mts +0 -439
package/dist/admin/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/admin/index.ts
|
|
31
31
|
var admin_exports = {};
|
|
32
32
|
__export(admin_exports, {
|
|
33
|
+
AdminStudioDashboard: () => AdminStudioDashboard,
|
|
33
34
|
SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM: () => SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
|
|
34
35
|
SOCIAL_MEDIA_ICON_OPTIONS: () => SOCIAL_MEDIA_ICON_OPTIONS,
|
|
35
36
|
SOCIAL_MEDIA_PLATFORMS: () => SOCIAL_MEDIA_PLATFORMS,
|
|
@@ -79,10 +80,26 @@ var adminNavIcons = [
|
|
|
79
80
|
"account",
|
|
80
81
|
"analytics"
|
|
81
82
|
];
|
|
83
|
+
var roleCanAccessNav = (role, item) => {
|
|
84
|
+
if (!item.roles || item.roles.length === 0) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if (!role) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return item.roles.includes(role);
|
|
91
|
+
};
|
|
92
|
+
var navItemIsActive = (pathname, item) => {
|
|
93
|
+
if (item.href === "/admin") {
|
|
94
|
+
return pathname === "/admin";
|
|
95
|
+
}
|
|
96
|
+
return item.matchPrefixes.some((prefix) => pathname.startsWith(prefix));
|
|
97
|
+
};
|
|
82
98
|
|
|
83
99
|
// src/shared/studioSections.ts
|
|
84
100
|
var studioRoles = /* @__PURE__ */ new Set(["admin", "editor", "client"]);
|
|
85
101
|
var studioIcons = new Set(adminNavIcons);
|
|
102
|
+
var dashboardSpans = /* @__PURE__ */ new Set(["full", "half"]);
|
|
86
103
|
var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
87
104
|
var isAbsoluteExternalURL = (value) => /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value) || value.startsWith("//");
|
|
88
105
|
var normalizePathLikeValue = (value) => {
|
|
@@ -124,6 +141,22 @@ var normalizeCard = (value) => {
|
|
|
124
141
|
};
|
|
125
142
|
};
|
|
126
143
|
var normalizeIcon = (value) => typeof value === "string" && studioIcons.has(value) ? value : void 0;
|
|
144
|
+
var normalizeComponent = (value) => {
|
|
145
|
+
if (!isRecord(value)) {
|
|
146
|
+
return void 0;
|
|
147
|
+
}
|
|
148
|
+
const componentPath = typeof value.path === "string" ? value.path.trim() : "";
|
|
149
|
+
const exportName = typeof value.exportName === "string" ? value.exportName.trim() : "";
|
|
150
|
+
if (!componentPath || !exportName) {
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
exportName,
|
|
155
|
+
path: componentPath,
|
|
156
|
+
...isRecord(value.clientProps) ? { clientProps: value.clientProps } : {}
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
var normalizeDashboardSpan = (value) => typeof value === "string" && dashboardSpans.has(value) ? value : "half";
|
|
127
160
|
var resolveStudioSections = (value) => {
|
|
128
161
|
if (!Array.isArray(value)) {
|
|
129
162
|
return [];
|
|
@@ -189,6 +222,38 @@ var resolveStudioSectionViews = (value) => {
|
|
|
189
222
|
}
|
|
190
223
|
return views;
|
|
191
224
|
};
|
|
225
|
+
var resolveStudioSectionDashboards = (value) => {
|
|
226
|
+
if (!Array.isArray(value)) {
|
|
227
|
+
return [];
|
|
228
|
+
}
|
|
229
|
+
const panels = [];
|
|
230
|
+
const seen = /* @__PURE__ */ new Set();
|
|
231
|
+
for (const entry of value) {
|
|
232
|
+
if (!isRecord(entry) || typeof entry.id !== "string" || typeof entry.label !== "string") {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const id = entry.id.trim();
|
|
236
|
+
const label = entry.label.trim();
|
|
237
|
+
const dashboard = isRecord(entry.dashboard) ? entry.dashboard : null;
|
|
238
|
+
const component = dashboard ? normalizeComponent(dashboard.Component) : void 0;
|
|
239
|
+
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) : "";
|
|
240
|
+
if (!id || !label || !dashboard || !component || !href || seen.has(id)) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const priority = typeof dashboard.priority === "number" && Number.isFinite(dashboard.priority) ? dashboard.priority : 100;
|
|
244
|
+
panels.push({
|
|
245
|
+
Component: component,
|
|
246
|
+
href,
|
|
247
|
+
id,
|
|
248
|
+
label,
|
|
249
|
+
priority,
|
|
250
|
+
...normalizeRoles(dashboard.roles ?? entry.roles) ? { roles: normalizeRoles(dashboard.roles ?? entry.roles) } : {},
|
|
251
|
+
span: normalizeDashboardSpan(dashboard.span)
|
|
252
|
+
});
|
|
253
|
+
seen.add(id);
|
|
254
|
+
}
|
|
255
|
+
return panels.sort((a, b) => a.priority === b.priority ? a.label.localeCompare(b.label) : a.priority - b.priority);
|
|
256
|
+
};
|
|
192
257
|
|
|
193
258
|
// src/admin/helpers/configureAdmin.ts
|
|
194
259
|
var import_meta = {};
|
|
@@ -248,6 +313,7 @@ function configureAdmin(config) {
|
|
|
248
313
|
};
|
|
249
314
|
});
|
|
250
315
|
const studioSections = resolveStudioSections(config.studio?.sections || []);
|
|
316
|
+
const studioDashboardPanels = resolveStudioSectionDashboards(config.studio?.sections || []);
|
|
251
317
|
const studioSectionViews = resolveStudioSectionViews(config.studio?.sections || []);
|
|
252
318
|
const sitePreview = config.studio?.sitePreview;
|
|
253
319
|
let cssPath;
|
|
@@ -277,6 +343,7 @@ function configureAdmin(config) {
|
|
|
277
343
|
cssPath = genPath;
|
|
278
344
|
}
|
|
279
345
|
const clientPath = "@orion-studios/payload-studio/admin/client";
|
|
346
|
+
const adminPath = "@orion-studios/payload-studio/admin";
|
|
280
347
|
const studioNavClientProps = {
|
|
281
348
|
brandName,
|
|
282
349
|
formSubmissionsCollectionSlug,
|
|
@@ -288,8 +355,14 @@ function configureAdmin(config) {
|
|
|
288
355
|
logoUrl,
|
|
289
356
|
mediaCollectionSlug,
|
|
290
357
|
pagesCollectionSlug,
|
|
358
|
+
dashboardPanels: studioDashboardPanels,
|
|
291
359
|
sections: studioSections
|
|
292
360
|
};
|
|
361
|
+
const dashboardImportMapGenerator = studioDashboardPanels.length > 0 ? ({ addToImportMap }) => {
|
|
362
|
+
addToImportMap(
|
|
363
|
+
studioDashboardPanels.map((panel) => panel.Component)
|
|
364
|
+
);
|
|
365
|
+
} : void 0;
|
|
293
366
|
const studioBackBreadcrumbComponent = {
|
|
294
367
|
exportName: "StudioBackBreadcrumb",
|
|
295
368
|
path: clientPath
|
|
@@ -324,6 +397,11 @@ function configureAdmin(config) {
|
|
|
324
397
|
return {
|
|
325
398
|
admin: {
|
|
326
399
|
css: cssPath,
|
|
400
|
+
...dashboardImportMapGenerator ? {
|
|
401
|
+
importMap: {
|
|
402
|
+
generators: [dashboardImportMapGenerator]
|
|
403
|
+
}
|
|
404
|
+
} : {},
|
|
327
405
|
components: {
|
|
328
406
|
...studioEnabled ? {
|
|
329
407
|
Nav: {
|
|
@@ -354,7 +432,7 @@ function configureAdmin(config) {
|
|
|
354
432
|
dashboard: {
|
|
355
433
|
Component: {
|
|
356
434
|
exportName: studioEnabled ? "AdminStudioDashboard" : "Dashboard",
|
|
357
|
-
path: clientPath,
|
|
435
|
+
path: studioEnabled ? adminPath : clientPath,
|
|
358
436
|
clientProps: studioNavClientProps
|
|
359
437
|
}
|
|
360
438
|
},
|
|
@@ -750,6 +828,1431 @@ function configureAdmin(config) {
|
|
|
750
828
|
};
|
|
751
829
|
}
|
|
752
830
|
|
|
831
|
+
// src/admin/components/studio/AdminStudioDashboard.tsx
|
|
832
|
+
var import_RenderServerComponent = require("@payloadcms/ui/elements/RenderServerComponent");
|
|
833
|
+
|
|
834
|
+
// src/admin-app/components/AdminBreadcrumbs.tsx
|
|
835
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
836
|
+
function AdminBreadcrumbs({ items }) {
|
|
837
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { "aria-label": "Breadcrumb", className: "orion-admin-breadcrumbs", children: items.map((item, index) => {
|
|
838
|
+
const isLast = index === items.length - 1;
|
|
839
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
840
|
+
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 }),
|
|
841
|
+
!isLast ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "orion-admin-breadcrumb-sep", children: "/" }) : null
|
|
842
|
+
] }, `${item.label}-${index}`);
|
|
843
|
+
}) });
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// src/admin-app/components/AdminPage.tsx
|
|
847
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
848
|
+
function AdminPage({ title, description, breadcrumbs, actions, children }) {
|
|
849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-page", children: [
|
|
850
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-page-header", children: [
|
|
851
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AdminBreadcrumbs, { items: breadcrumbs }),
|
|
852
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "orion-admin-page-title-row", children: [
|
|
853
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
854
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { children: title }),
|
|
855
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: description }) : null
|
|
856
|
+
] }),
|
|
857
|
+
actions ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-page-actions", children: actions }) : null
|
|
858
|
+
] })
|
|
859
|
+
] }),
|
|
860
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "orion-admin-page-content", children })
|
|
861
|
+
] });
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// src/admin/components/studio/AdminStudioDashboardClient.tsx
|
|
865
|
+
var import_react = require("react");
|
|
866
|
+
var import_link = __toESM(require("next/link"));
|
|
867
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
868
|
+
var SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
869
|
+
var isRole = (value) => value === "admin" || value === "editor" || value === "client";
|
|
870
|
+
var canReviewForms = (role) => role === "admin" || role === "editor";
|
|
871
|
+
var canCreatePages = (role) => role === "admin" || role === "editor";
|
|
872
|
+
var canAccess = (role, roles) => {
|
|
873
|
+
if (!roles || roles.length === 0) {
|
|
874
|
+
return true;
|
|
875
|
+
}
|
|
876
|
+
if (!role) {
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
return roles.includes(role);
|
|
880
|
+
};
|
|
881
|
+
var asText = (value, fallback) => typeof value === "string" && value.trim().length > 0 ? value.trim() : fallback;
|
|
882
|
+
var asID = (value) => {
|
|
883
|
+
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
884
|
+
return "";
|
|
885
|
+
};
|
|
886
|
+
var toTimestamp = (value) => {
|
|
887
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
888
|
+
return Number.NaN;
|
|
889
|
+
}
|
|
890
|
+
const timestamp = Date.parse(value);
|
|
891
|
+
return Number.isFinite(timestamp) ? timestamp : Number.NaN;
|
|
892
|
+
};
|
|
893
|
+
var isRecent = (value) => {
|
|
894
|
+
const timestamp = toTimestamp(value);
|
|
895
|
+
return Number.isFinite(timestamp) && Date.now() - timestamp <= SEVEN_DAYS_MS;
|
|
896
|
+
};
|
|
897
|
+
var formatDateTime = (value) => {
|
|
898
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
899
|
+
return "Unknown time";
|
|
900
|
+
}
|
|
901
|
+
const date = new Date(value);
|
|
902
|
+
if (Number.isNaN(date.getTime())) {
|
|
903
|
+
return value;
|
|
904
|
+
}
|
|
905
|
+
return new Intl.DateTimeFormat(void 0, {
|
|
906
|
+
dateStyle: "medium",
|
|
907
|
+
timeStyle: "short"
|
|
908
|
+
}).format(date);
|
|
909
|
+
};
|
|
910
|
+
var formatRelativeTime = (timestamp) => {
|
|
911
|
+
if (!Number.isFinite(timestamp)) {
|
|
912
|
+
return "Unknown time";
|
|
913
|
+
}
|
|
914
|
+
const diffMs = timestamp - Date.now();
|
|
915
|
+
const diffMinutes = Math.round(diffMs / (60 * 1e3));
|
|
916
|
+
const rtf = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
|
|
917
|
+
if (Math.abs(diffMinutes) < 60) {
|
|
918
|
+
return rtf.format(diffMinutes, "minute");
|
|
919
|
+
}
|
|
920
|
+
const diffHours = Math.round(diffMinutes / 60);
|
|
921
|
+
if (Math.abs(diffHours) < 24) {
|
|
922
|
+
return rtf.format(diffHours, "hour");
|
|
923
|
+
}
|
|
924
|
+
const diffDays = Math.round(diffHours / 24);
|
|
925
|
+
return rtf.format(diffDays, "day");
|
|
926
|
+
};
|
|
927
|
+
var readSubmissionIdentity = (value) => {
|
|
928
|
+
if (!value || typeof value !== "object") {
|
|
929
|
+
return "New submission";
|
|
930
|
+
}
|
|
931
|
+
const data = value;
|
|
932
|
+
const firstName = typeof data.firstName === "string" ? data.firstName.trim() : "";
|
|
933
|
+
const lastName = typeof data.lastName === "string" ? data.lastName.trim() : "";
|
|
934
|
+
const name = typeof data.name === "string" ? data.name.trim() : "";
|
|
935
|
+
const email = typeof data.email === "string" ? data.email.trim() : typeof data.contactEmail === "string" ? data.contactEmail.trim() : "";
|
|
936
|
+
const fullName = [firstName, lastName].filter(Boolean).join(" ").trim();
|
|
937
|
+
return fullName || name || email || "New submission";
|
|
938
|
+
};
|
|
939
|
+
var getFormID = (value) => {
|
|
940
|
+
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
941
|
+
if (value && typeof value === "object") {
|
|
942
|
+
const nestedID = value.id;
|
|
943
|
+
if (typeof nestedID === "string" || typeof nestedID === "number") return String(nestedID);
|
|
944
|
+
}
|
|
945
|
+
return "";
|
|
946
|
+
};
|
|
947
|
+
var getFormTitle = (value) => {
|
|
948
|
+
if (!value || typeof value !== "object") {
|
|
949
|
+
return "";
|
|
950
|
+
}
|
|
951
|
+
const title = value.title;
|
|
952
|
+
if (typeof title === "string" && title.trim().length > 0) {
|
|
953
|
+
return title.trim();
|
|
954
|
+
}
|
|
955
|
+
const slug = value.slug;
|
|
956
|
+
return typeof slug === "string" && slug.trim().length > 0 ? slug.trim() : "";
|
|
957
|
+
};
|
|
958
|
+
var buildSearchParams = (params) => new URLSearchParams(
|
|
959
|
+
Object.entries(params).filter(([, value]) => typeof value === "string" && value.length > 0)
|
|
960
|
+
).toString();
|
|
961
|
+
async function loadCollection(path2) {
|
|
962
|
+
const response = await fetch(path2, {
|
|
963
|
+
cache: "no-store",
|
|
964
|
+
credentials: "include"
|
|
965
|
+
});
|
|
966
|
+
if (!response.ok) {
|
|
967
|
+
const body = await response.text();
|
|
968
|
+
throw new Error(body || `Request failed: ${response.status}`);
|
|
969
|
+
}
|
|
970
|
+
return await response.json();
|
|
971
|
+
}
|
|
972
|
+
async function loadPages(collectionSlug) {
|
|
973
|
+
const params = buildSearchParams({
|
|
974
|
+
depth: "0",
|
|
975
|
+
draft: "true",
|
|
976
|
+
limit: "200",
|
|
977
|
+
sort: "-updatedAt"
|
|
978
|
+
});
|
|
979
|
+
const result = await loadCollection(`/api/${collectionSlug}?${params}`);
|
|
980
|
+
const docs = Array.isArray(result.docs) ? result.docs : [];
|
|
981
|
+
return {
|
|
982
|
+
draftCount: docs.filter((doc) => doc._status === "draft").length,
|
|
983
|
+
recent: docs.slice(0, 8),
|
|
984
|
+
total: typeof result.totalDocs === "number" ? result.totalDocs : docs.length,
|
|
985
|
+
updatedThisWeek: docs.filter((doc) => isRecent(doc.updatedAt)).length
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
async function loadForms(formsCollectionSlug, submissionsCollectionSlug) {
|
|
989
|
+
const [formsResult, submissionsResult] = await Promise.all([
|
|
990
|
+
loadCollection(
|
|
991
|
+
`/api/${formsCollectionSlug}?${buildSearchParams({
|
|
992
|
+
depth: "0",
|
|
993
|
+
draft: "true",
|
|
994
|
+
limit: "80",
|
|
995
|
+
sort: "-updatedAt"
|
|
996
|
+
})}`
|
|
997
|
+
),
|
|
998
|
+
loadCollection(
|
|
999
|
+
`/api/${submissionsCollectionSlug}?${buildSearchParams({
|
|
1000
|
+
depth: "1",
|
|
1001
|
+
limit: "40",
|
|
1002
|
+
sort: "-submittedAt"
|
|
1003
|
+
})}`
|
|
1004
|
+
)
|
|
1005
|
+
]);
|
|
1006
|
+
const forms = Array.isArray(formsResult.docs) ? formsResult.docs : [];
|
|
1007
|
+
const recentSubmissions = Array.isArray(submissionsResult.docs) ? submissionsResult.docs : [];
|
|
1008
|
+
const submissionsByForm = /* @__PURE__ */ new Map();
|
|
1009
|
+
for (const submission of recentSubmissions) {
|
|
1010
|
+
const formID = getFormID(submission.form);
|
|
1011
|
+
if (!formID) continue;
|
|
1012
|
+
submissionsByForm.set(formID, (submissionsByForm.get(formID) || 0) + 1);
|
|
1013
|
+
}
|
|
1014
|
+
let busiestFormTitle = null;
|
|
1015
|
+
let busiestFormCount = 0;
|
|
1016
|
+
for (const form of forms) {
|
|
1017
|
+
const formID = asID(form.id);
|
|
1018
|
+
if (!formID) continue;
|
|
1019
|
+
const submissionCount = submissionsByForm.get(formID) || 0;
|
|
1020
|
+
if (submissionCount > busiestFormCount) {
|
|
1021
|
+
busiestFormCount = submissionCount;
|
|
1022
|
+
busiestFormTitle = asText(form.title, "Untitled form");
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
return {
|
|
1026
|
+
busiestFormTitle,
|
|
1027
|
+
forms,
|
|
1028
|
+
recentSubmissions,
|
|
1029
|
+
submissionsThisWeek: recentSubmissions.filter((submission) => isRecent(submission.submittedAt)).length,
|
|
1030
|
+
totalForms: typeof formsResult.totalDocs === "number" ? formsResult.totalDocs : forms.length
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
async function loadMedia(collectionSlug) {
|
|
1034
|
+
const params = buildSearchParams({
|
|
1035
|
+
depth: "0",
|
|
1036
|
+
limit: "24",
|
|
1037
|
+
sort: "-updatedAt"
|
|
1038
|
+
});
|
|
1039
|
+
const result = await loadCollection(`/api/${collectionSlug}?${params}`);
|
|
1040
|
+
const docs = Array.isArray(result.docs) ? result.docs : [];
|
|
1041
|
+
return {
|
|
1042
|
+
recent: docs.slice(0, 8),
|
|
1043
|
+
total: typeof result.totalDocs === "number" ? result.totalDocs : docs.length,
|
|
1044
|
+
uploadsThisWeek: docs.filter((doc) => isRecent(doc.updatedAt)).length
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
var loadingState = {
|
|
1048
|
+
forms: null,
|
|
1049
|
+
media: { status: "loading" },
|
|
1050
|
+
pages: { status: "loading" }
|
|
1051
|
+
};
|
|
1052
|
+
function ModuleStatus({ message }) {
|
|
1053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "orion-dashboard-inline-note", children: message });
|
|
1054
|
+
}
|
|
1055
|
+
function EmptyState({
|
|
1056
|
+
body,
|
|
1057
|
+
title
|
|
1058
|
+
}) {
|
|
1059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-empty-state", children: [
|
|
1060
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: title }),
|
|
1061
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: body })
|
|
1062
|
+
] });
|
|
1063
|
+
}
|
|
1064
|
+
function SnapshotMetric({ card }) {
|
|
1065
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("article", { className: "orion-dashboard-snapshot-card", children: [
|
|
1066
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-snapshot-kicker", children: card.kicker }),
|
|
1067
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: card.value }),
|
|
1068
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: card.detail })
|
|
1069
|
+
] });
|
|
1070
|
+
}
|
|
1071
|
+
function AdminStudioDashboardClient({
|
|
1072
|
+
extensionPanels = [],
|
|
1073
|
+
formSubmissionsCollectionSlug,
|
|
1074
|
+
formsCollectionSlug,
|
|
1075
|
+
formsEnabled,
|
|
1076
|
+
formsPath,
|
|
1077
|
+
globalsBasePath,
|
|
1078
|
+
mediaCollectionSlug,
|
|
1079
|
+
mediaPath,
|
|
1080
|
+
pagesCollectionSlug,
|
|
1081
|
+
pagesPath,
|
|
1082
|
+
sectionLinks,
|
|
1083
|
+
toolsPath,
|
|
1084
|
+
userRole
|
|
1085
|
+
}) {
|
|
1086
|
+
const role = isRole(userRole) ? userRole : void 0;
|
|
1087
|
+
const [state, setState] = (0, import_react.useState)(
|
|
1088
|
+
() => formsEnabled && canReviewForms(role) ? {
|
|
1089
|
+
forms: { status: "loading" },
|
|
1090
|
+
media: { status: "loading" },
|
|
1091
|
+
pages: { status: "loading" }
|
|
1092
|
+
} : loadingState
|
|
1093
|
+
);
|
|
1094
|
+
(0, import_react.useEffect)(() => {
|
|
1095
|
+
let cancelled = false;
|
|
1096
|
+
const run = async () => {
|
|
1097
|
+
const includeForms = formsEnabled && canReviewForms(role);
|
|
1098
|
+
(0, import_react.startTransition)(() => {
|
|
1099
|
+
setState({
|
|
1100
|
+
forms: includeForms ? { status: "loading" } : null,
|
|
1101
|
+
media: { status: "loading" },
|
|
1102
|
+
pages: { status: "loading" }
|
|
1103
|
+
});
|
|
1104
|
+
});
|
|
1105
|
+
const [pagesResult, formsResult, mediaResult] = await Promise.allSettled([
|
|
1106
|
+
loadPages(pagesCollectionSlug),
|
|
1107
|
+
includeForms ? loadForms(formsCollectionSlug, formSubmissionsCollectionSlug) : Promise.resolve(null),
|
|
1108
|
+
loadMedia(mediaCollectionSlug)
|
|
1109
|
+
]);
|
|
1110
|
+
if (cancelled) return;
|
|
1111
|
+
(0, import_react.startTransition)(() => {
|
|
1112
|
+
setState({
|
|
1113
|
+
forms: includeForms && formsResult.status === "rejected" ? {
|
|
1114
|
+
error: formsResult.reason instanceof Error ? formsResult.reason.message : "Unable to load form activity.",
|
|
1115
|
+
status: "error"
|
|
1116
|
+
} : includeForms && formsResult.status === "fulfilled" && formsResult.value ? {
|
|
1117
|
+
data: formsResult.value,
|
|
1118
|
+
status: "success"
|
|
1119
|
+
} : null,
|
|
1120
|
+
media: mediaResult.status === "rejected" ? {
|
|
1121
|
+
error: mediaResult.reason instanceof Error ? mediaResult.reason.message : "Unable to load media activity.",
|
|
1122
|
+
status: "error"
|
|
1123
|
+
} : {
|
|
1124
|
+
data: mediaResult.value,
|
|
1125
|
+
status: "success"
|
|
1126
|
+
},
|
|
1127
|
+
pages: pagesResult.status === "rejected" ? {
|
|
1128
|
+
error: pagesResult.reason instanceof Error ? pagesResult.reason.message : "Unable to load page activity.",
|
|
1129
|
+
status: "error"
|
|
1130
|
+
} : {
|
|
1131
|
+
data: pagesResult.value,
|
|
1132
|
+
status: "success"
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
});
|
|
1136
|
+
};
|
|
1137
|
+
void run();
|
|
1138
|
+
return () => {
|
|
1139
|
+
cancelled = true;
|
|
1140
|
+
};
|
|
1141
|
+
}, [
|
|
1142
|
+
formSubmissionsCollectionSlug,
|
|
1143
|
+
formsCollectionSlug,
|
|
1144
|
+
formsEnabled,
|
|
1145
|
+
mediaCollectionSlug,
|
|
1146
|
+
pagesCollectionSlug,
|
|
1147
|
+
role
|
|
1148
|
+
]);
|
|
1149
|
+
const visibleWorkspaceLinks = (0, import_react.useMemo)(
|
|
1150
|
+
() => sectionLinks.filter((section) => canAccess(role, section.roles)),
|
|
1151
|
+
[role, sectionLinks]
|
|
1152
|
+
);
|
|
1153
|
+
const activityItems = (0, import_react.useMemo)(() => {
|
|
1154
|
+
const items = [];
|
|
1155
|
+
if (state.pages.status === "success") {
|
|
1156
|
+
for (const doc of state.pages.data.recent) {
|
|
1157
|
+
const id = asID(doc.id);
|
|
1158
|
+
if (!id) continue;
|
|
1159
|
+
const timestamp = toTimestamp(doc.updatedAt);
|
|
1160
|
+
items.push({
|
|
1161
|
+
href: `${pagesPath}/${id}`,
|
|
1162
|
+
id: `page-${id}`,
|
|
1163
|
+
kind: "page",
|
|
1164
|
+
label: typeof doc._status === "string" ? doc._status : "page",
|
|
1165
|
+
meta: Number.isFinite(timestamp) ? formatDateTime(doc.updatedAt) : "Update time unavailable",
|
|
1166
|
+
timestamp,
|
|
1167
|
+
title: asText(doc.title, "Untitled page")
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
if (state.forms?.status === "success") {
|
|
1172
|
+
for (const submission of state.forms.data.recentSubmissions) {
|
|
1173
|
+
const id = asID(submission.id);
|
|
1174
|
+
const formID = getFormID(submission.form);
|
|
1175
|
+
if (!id || !formID) continue;
|
|
1176
|
+
const timestamp = toTimestamp(submission.submittedAt);
|
|
1177
|
+
const formTitle = getFormTitle(submission.form) || "Form response";
|
|
1178
|
+
items.push({
|
|
1179
|
+
href: `${formsPath}?form=${encodeURIComponent(formID)}`,
|
|
1180
|
+
id: `submission-${id}`,
|
|
1181
|
+
kind: "submission",
|
|
1182
|
+
label: formTitle,
|
|
1183
|
+
meta: Number.isFinite(timestamp) ? `${readSubmissionIdentity(submission.data)} \xB7 ${formatDateTime(submission.submittedAt)}` : readSubmissionIdentity(submission.data),
|
|
1184
|
+
timestamp,
|
|
1185
|
+
title: "New submission"
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
if (state.media.status === "success") {
|
|
1190
|
+
for (const doc of state.media.data.recent) {
|
|
1191
|
+
const id = asID(doc.id);
|
|
1192
|
+
if (!id) continue;
|
|
1193
|
+
const timestamp = toTimestamp(doc.updatedAt);
|
|
1194
|
+
items.push({
|
|
1195
|
+
href: `${mediaPath}/${id}`,
|
|
1196
|
+
id: `media-${id}`,
|
|
1197
|
+
kind: "media",
|
|
1198
|
+
label: asText(doc.mimeType, "Media asset"),
|
|
1199
|
+
meta: Number.isFinite(timestamp) ? formatDateTime(doc.updatedAt) : "Update time unavailable",
|
|
1200
|
+
timestamp,
|
|
1201
|
+
title: asText(doc.filename, "Untitled asset")
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
return items.filter((item) => Number.isFinite(item.timestamp)).sort((a, b) => b.timestamp - a.timestamp).slice(0, 10);
|
|
1206
|
+
}, [formsPath, mediaPath, pagesPath, state.forms, state.media, state.pages]);
|
|
1207
|
+
const attentionItems = (0, import_react.useMemo)(() => {
|
|
1208
|
+
if (role === "client") {
|
|
1209
|
+
const items2 = [];
|
|
1210
|
+
if (state.pages.status === "success" && state.pages.data.updatedThisWeek > 0) {
|
|
1211
|
+
items2.push({
|
|
1212
|
+
href: pagesPath,
|
|
1213
|
+
id: "pages-updated",
|
|
1214
|
+
label: `${state.pages.data.updatedThisWeek} page${state.pages.data.updatedThisWeek === 1 ? "" : "s"} changed in the last 7 days.`
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
if (state.media.status === "success" && state.media.data.uploadsThisWeek > 0) {
|
|
1218
|
+
items2.push({
|
|
1219
|
+
href: mediaPath,
|
|
1220
|
+
id: "media-updated",
|
|
1221
|
+
label: `${state.media.data.uploadsThisWeek} new media asset${state.media.data.uploadsThisWeek === 1 ? "" : "s"} landed this week.`
|
|
1222
|
+
});
|
|
1223
|
+
}
|
|
1224
|
+
return items2;
|
|
1225
|
+
}
|
|
1226
|
+
const items = [];
|
|
1227
|
+
if (state.pages.status === "success" && state.pages.data.draftCount > 0) {
|
|
1228
|
+
items.push({
|
|
1229
|
+
href: pagesPath,
|
|
1230
|
+
id: "draft-pages",
|
|
1231
|
+
label: `${state.pages.data.draftCount} page${state.pages.data.draftCount === 1 ? "" : "s"} still need publishing review.`,
|
|
1232
|
+
tone: "accent"
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
if (state.forms?.status === "success" && state.forms.data.submissionsThisWeek > 0) {
|
|
1236
|
+
items.push({
|
|
1237
|
+
href: formsPath,
|
|
1238
|
+
id: "recent-submissions",
|
|
1239
|
+
label: `${state.forms.data.submissionsThisWeek} form submission${state.forms.data.submissionsThisWeek === 1 ? "" : "s"} arrived in the last 7 days.`,
|
|
1240
|
+
tone: "accent"
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
if (state.media.status === "success" && state.media.data.total === 0) {
|
|
1244
|
+
items.push({
|
|
1245
|
+
href: mediaPath,
|
|
1246
|
+
id: "empty-media",
|
|
1247
|
+
label: "The media library is still empty. Add brand assets before content expands."
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
if (state.pages.status === "error") {
|
|
1251
|
+
items.push({
|
|
1252
|
+
href: pagesPath,
|
|
1253
|
+
id: "pages-error",
|
|
1254
|
+
label: "Page activity could not be loaded for the dashboard.",
|
|
1255
|
+
tone: "muted"
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
if (state.forms?.status === "error") {
|
|
1259
|
+
items.push({
|
|
1260
|
+
href: formsPath,
|
|
1261
|
+
id: "forms-error",
|
|
1262
|
+
label: "Form activity could not be loaded for the dashboard.",
|
|
1263
|
+
tone: "muted"
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
if (state.media.status === "error") {
|
|
1267
|
+
items.push({
|
|
1268
|
+
href: mediaPath,
|
|
1269
|
+
id: "media-error",
|
|
1270
|
+
label: "Media activity could not be loaded for the dashboard.",
|
|
1271
|
+
tone: "muted"
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
return items;
|
|
1275
|
+
}, [formsPath, mediaPath, pagesPath, role, state.forms, state.media, state.pages]);
|
|
1276
|
+
const snapshotCards = (0, import_react.useMemo)(() => {
|
|
1277
|
+
const cards = [];
|
|
1278
|
+
if (state.pages.status === "success") {
|
|
1279
|
+
cards.push(
|
|
1280
|
+
role === "client" ? {
|
|
1281
|
+
detail: `${state.pages.data.updatedThisWeek} updated this week`,
|
|
1282
|
+
kicker: "Pages",
|
|
1283
|
+
value: `${state.pages.data.total}`
|
|
1284
|
+
} : {
|
|
1285
|
+
detail: `${state.pages.data.draftCount} draft${state.pages.data.draftCount === 1 ? "" : "s"} waiting`,
|
|
1286
|
+
kicker: "Pages",
|
|
1287
|
+
value: `${state.pages.data.total}`
|
|
1288
|
+
}
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
if (state.forms?.status === "success") {
|
|
1292
|
+
cards.push({
|
|
1293
|
+
detail: state.forms.data.busiestFormTitle ? `Most active: ${state.forms.data.busiestFormTitle}` : "Waiting on the first submission",
|
|
1294
|
+
kicker: "Forms",
|
|
1295
|
+
value: `${state.forms.data.submissionsThisWeek}`
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
if (state.media.status === "success") {
|
|
1299
|
+
cards.push({
|
|
1300
|
+
detail: `${state.media.data.uploadsThisWeek} uploaded this week`,
|
|
1301
|
+
kicker: "Media",
|
|
1302
|
+
value: `${state.media.data.total}`
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
cards.push({
|
|
1306
|
+
detail: `${visibleWorkspaceLinks.length} section${visibleWorkspaceLinks.length === 1 ? "" : "s"} available`,
|
|
1307
|
+
kicker: "Workspace",
|
|
1308
|
+
value: role ? role.toUpperCase() : "CMS"
|
|
1309
|
+
});
|
|
1310
|
+
return cards.slice(0, 4);
|
|
1311
|
+
}, [role, state.forms, state.media, state.pages, visibleWorkspaceLinks.length]);
|
|
1312
|
+
const primaryActions = (0, import_react.useMemo)(() => {
|
|
1313
|
+
const actions = [];
|
|
1314
|
+
if (canCreatePages(role)) {
|
|
1315
|
+
actions.push({
|
|
1316
|
+
description: "Create or revise content in the visual builder.",
|
|
1317
|
+
href: `${pagesPath}/new`,
|
|
1318
|
+
label: "New Page"
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
actions.push({
|
|
1322
|
+
description: "Review live pages and recent edits.",
|
|
1323
|
+
href: pagesPath,
|
|
1324
|
+
label: "Open Pages",
|
|
1325
|
+
tone: "ghost"
|
|
1326
|
+
});
|
|
1327
|
+
if (formsEnabled && canReviewForms(role)) {
|
|
1328
|
+
actions.push({
|
|
1329
|
+
description: "Check submissions and form performance.",
|
|
1330
|
+
href: formsPath,
|
|
1331
|
+
label: "Review Forms",
|
|
1332
|
+
tone: "soft"
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
actions.push({
|
|
1336
|
+
description: "Update site settings, navigation, and footer content.",
|
|
1337
|
+
href: globalsBasePath,
|
|
1338
|
+
label: "Open Globals",
|
|
1339
|
+
tone: "ghost"
|
|
1340
|
+
});
|
|
1341
|
+
actions.push({
|
|
1342
|
+
description: "Upload or organize brand and campaign assets.",
|
|
1343
|
+
href: mediaPath,
|
|
1344
|
+
label: "Manage Media",
|
|
1345
|
+
tone: "ghost"
|
|
1346
|
+
});
|
|
1347
|
+
if (role === "admin") {
|
|
1348
|
+
actions.push({
|
|
1349
|
+
description: "Manage users, roles, and fallback tools.",
|
|
1350
|
+
href: toolsPath,
|
|
1351
|
+
label: "Admin Tools",
|
|
1352
|
+
tone: "ghost"
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
return actions;
|
|
1356
|
+
}, [formsEnabled, formsPath, globalsBasePath, mediaPath, pagesPath, role, toolsPath]);
|
|
1357
|
+
const attentionTitle = role === "client" ? "What Changed" : "Needs Attention";
|
|
1358
|
+
const attentionDescription = role === "client" ? "A quick read on recent content and asset changes." : "The highest-signal items that still need review.";
|
|
1359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-layout", children: [
|
|
1360
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "orion-dashboard-panel orion-dashboard-panel--attention", children: [
|
|
1361
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-panel-header", children: [
|
|
1362
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
1363
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-kicker", children: attentionTitle }),
|
|
1364
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: attentionDescription })
|
|
1365
|
+
] }),
|
|
1366
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-meta", children: "Last 7 days" })
|
|
1367
|
+
] }),
|
|
1368
|
+
attentionItems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "orion-dashboard-attention-list", children: attentionItems.map(
|
|
1369
|
+
(item) => item.href ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1370
|
+
import_link.default,
|
|
1371
|
+
{
|
|
1372
|
+
className: ["orion-dashboard-attention-item", item.tone ? `is-${item.tone}` : ""].filter(Boolean).join(" "),
|
|
1373
|
+
href: item.href,
|
|
1374
|
+
children: [
|
|
1375
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: item.label }),
|
|
1376
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Open" })
|
|
1377
|
+
]
|
|
1378
|
+
},
|
|
1379
|
+
item.id
|
|
1380
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1381
|
+
"div",
|
|
1382
|
+
{
|
|
1383
|
+
className: ["orion-dashboard-attention-item", item.tone ? `is-${item.tone}` : ""].filter(Boolean).join(" "),
|
|
1384
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: item.label })
|
|
1385
|
+
},
|
|
1386
|
+
item.id
|
|
1387
|
+
)
|
|
1388
|
+
) }) : 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)(
|
|
1389
|
+
EmptyState,
|
|
1390
|
+
{
|
|
1391
|
+
body: role === "client" ? "No major changes landed during the current review window." : "No urgent follow-up surfaced from content, forms, or media activity.",
|
|
1392
|
+
title: "Everything looks steady"
|
|
1393
|
+
}
|
|
1394
|
+
)
|
|
1395
|
+
] }),
|
|
1396
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "orion-dashboard-panel orion-dashboard-panel--actions", children: [
|
|
1397
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-panel-header", children: [
|
|
1398
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
1399
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-kicker", children: "Quick Actions" }),
|
|
1400
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "Jump into the work that matters most." })
|
|
1401
|
+
] }),
|
|
1402
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "orion-dashboard-panel-meta", children: [
|
|
1403
|
+
role || "studio",
|
|
1404
|
+
" mode"
|
|
1405
|
+
] })
|
|
1406
|
+
] }),
|
|
1407
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "orion-dashboard-action-list", children: primaryActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1408
|
+
import_link.default,
|
|
1409
|
+
{
|
|
1410
|
+
className: [
|
|
1411
|
+
"orion-dashboard-action",
|
|
1412
|
+
action.tone === "ghost" ? "is-ghost" : action.tone === "soft" ? "is-soft" : ""
|
|
1413
|
+
].filter(Boolean).join(" "),
|
|
1414
|
+
href: action.href,
|
|
1415
|
+
children: [
|
|
1416
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: action.label }),
|
|
1417
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: action.description })
|
|
1418
|
+
]
|
|
1419
|
+
},
|
|
1420
|
+
action.label
|
|
1421
|
+
)) }),
|
|
1422
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-workspace-strip", children: [
|
|
1423
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-workspace-label", children: "Workspace" }),
|
|
1424
|
+
/* @__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)) })
|
|
1425
|
+
] })
|
|
1426
|
+
] }),
|
|
1427
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "orion-dashboard-panel orion-dashboard-panel--activity", children: [
|
|
1428
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-panel-header", children: [
|
|
1429
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
1430
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-kicker", children: "Recent Activity" }),
|
|
1431
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "The freshest edits, responses, and uploads across the studio." })
|
|
1432
|
+
] }),
|
|
1433
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "orion-dashboard-panel-meta", children: [
|
|
1434
|
+
activityItems.length,
|
|
1435
|
+
" items"
|
|
1436
|
+
] })
|
|
1437
|
+
] }),
|
|
1438
|
+
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: [
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-activity-copy", children: [
|
|
1440
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-activity-topline", children: [
|
|
1441
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: item.title }),
|
|
1442
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formatRelativeTime(item.timestamp) })
|
|
1443
|
+
] }),
|
|
1444
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: item.meta })
|
|
1445
|
+
] }),
|
|
1446
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-activity-pill", children: item.label })
|
|
1447
|
+
] }, 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)(
|
|
1448
|
+
EmptyState,
|
|
1449
|
+
{
|
|
1450
|
+
body: "Recent page edits, submissions, and uploads will start stacking here as soon as the team gets moving.",
|
|
1451
|
+
title: "No recent activity yet"
|
|
1452
|
+
}
|
|
1453
|
+
)
|
|
1454
|
+
] }),
|
|
1455
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "orion-dashboard-panel orion-dashboard-panel--snapshot", children: [
|
|
1456
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-panel-header", children: [
|
|
1457
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
1458
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-kicker", children: "Business Snapshot" }),
|
|
1459
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: "A compact read on content momentum and performance." })
|
|
1460
|
+
] }),
|
|
1461
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "orion-dashboard-panel-meta", children: "30-day lens" })
|
|
1462
|
+
] }),
|
|
1463
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "orion-dashboard-snapshot-grid", children: [
|
|
1464
|
+
snapshotCards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SnapshotMetric, { card }, card.kicker)),
|
|
1465
|
+
extensionPanels.map((panel) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1466
|
+
"div",
|
|
1467
|
+
{
|
|
1468
|
+
className: [
|
|
1469
|
+
"orion-dashboard-extension-panel",
|
|
1470
|
+
panel.span === "full" ? "is-full" : "is-half"
|
|
1471
|
+
].filter(Boolean).join(" "),
|
|
1472
|
+
children: panel.node
|
|
1473
|
+
},
|
|
1474
|
+
panel.id
|
|
1475
|
+
))
|
|
1476
|
+
] }),
|
|
1477
|
+
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
|
|
1478
|
+
] })
|
|
1479
|
+
] });
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
// src/admin/components/studio/StudioSectionLayout.tsx
|
|
1483
|
+
var import_react5 = require("react");
|
|
1484
|
+
var import_navigation = require("next/navigation");
|
|
1485
|
+
var import_ui = require("@payloadcms/ui");
|
|
1486
|
+
|
|
1487
|
+
// src/admin-app/components/AdminShellClient.tsx
|
|
1488
|
+
var import_react2 = require("react");
|
|
1489
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1490
|
+
var iconSize = 20;
|
|
1491
|
+
var iconStyle = { display: "block", flexShrink: 0 };
|
|
1492
|
+
function NavIcon({ name }) {
|
|
1493
|
+
const props = { width: iconSize, height: iconSize, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", style: iconStyle };
|
|
1494
|
+
switch (name) {
|
|
1495
|
+
case "dashboard":
|
|
1496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1497
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "3", y: "3", width: "7", height: "9", rx: "1" }),
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "14", y: "3", width: "7", height: "5", rx: "1" }),
|
|
1499
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "14", y: "12", width: "7", height: "9", rx: "1" }),
|
|
1500
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "3", y: "16", width: "7", height: "5", rx: "1" })
|
|
1501
|
+
] });
|
|
1502
|
+
case "pages":
|
|
1503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1504
|
+
/* @__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" }),
|
|
1505
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("polyline", { points: "14 2 14 8 20 8" }),
|
|
1506
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "8", y1: "13", x2: "16", y2: "13" }),
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "8", y1: "17", x2: "12", y2: "17" })
|
|
1508
|
+
] });
|
|
1509
|
+
case "forms":
|
|
1510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1511
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9 3h6" }),
|
|
1512
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M12 3v18" }),
|
|
1513
|
+
/* @__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" }),
|
|
1514
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M7 11h10" }),
|
|
1515
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M7 15h6" })
|
|
1516
|
+
] });
|
|
1517
|
+
case "globals":
|
|
1518
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1519
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "3" }),
|
|
1520
|
+
/* @__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" })
|
|
1521
|
+
] });
|
|
1522
|
+
case "media":
|
|
1523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1524
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }),
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "8.5", cy: "8.5", r: "1.5" }),
|
|
1526
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("polyline", { points: "21 15 16 10 5 21" })
|
|
1527
|
+
] });
|
|
1528
|
+
case "tools":
|
|
1529
|
+
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" }) });
|
|
1530
|
+
case "analytics":
|
|
1531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1532
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M4 19V5" }),
|
|
1533
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M10 19V10" }),
|
|
1534
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M16 19v-6" }),
|
|
1535
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M22 19V3" })
|
|
1536
|
+
] });
|
|
1537
|
+
case "account":
|
|
1538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { ...props, children: [
|
|
1539
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" }),
|
|
1540
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "7", r: "4" })
|
|
1541
|
+
] });
|
|
1542
|
+
default:
|
|
1543
|
+
return null;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
function AdminShellClient({
|
|
1547
|
+
children,
|
|
1548
|
+
brandName,
|
|
1549
|
+
logoUrl,
|
|
1550
|
+
userEmail,
|
|
1551
|
+
userRole,
|
|
1552
|
+
pathname,
|
|
1553
|
+
navItems,
|
|
1554
|
+
onLogout,
|
|
1555
|
+
storageKey = "orion-admin-shell-collapsed"
|
|
1556
|
+
}) {
|
|
1557
|
+
const [collapsed, setCollapsed] = (0, import_react2.useState)(false);
|
|
1558
|
+
const [loggingOut, setLoggingOut] = (0, import_react2.useState)(false);
|
|
1559
|
+
(0, import_react2.useEffect)(() => {
|
|
1560
|
+
try {
|
|
1561
|
+
const stored = window.localStorage.getItem(storageKey);
|
|
1562
|
+
if (stored === "1") {
|
|
1563
|
+
setCollapsed(true);
|
|
1564
|
+
}
|
|
1565
|
+
} catch {
|
|
1566
|
+
}
|
|
1567
|
+
}, [storageKey]);
|
|
1568
|
+
const toggleSidebar = () => {
|
|
1569
|
+
setCollapsed((current) => {
|
|
1570
|
+
const next = !current;
|
|
1571
|
+
try {
|
|
1572
|
+
window.localStorage.setItem(storageKey, next ? "1" : "0");
|
|
1573
|
+
} catch {
|
|
1574
|
+
}
|
|
1575
|
+
return next;
|
|
1576
|
+
});
|
|
1577
|
+
};
|
|
1578
|
+
const handleLogout = async () => {
|
|
1579
|
+
setLoggingOut(true);
|
|
1580
|
+
try {
|
|
1581
|
+
await onLogout();
|
|
1582
|
+
} finally {
|
|
1583
|
+
setLoggingOut(false);
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `orion-admin-shell ${collapsed ? "is-collapsed" : ""}`, children: [
|
|
1587
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("aside", { className: "orion-admin-sidebar", children: [
|
|
1588
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1589
|
+
"button",
|
|
1590
|
+
{
|
|
1591
|
+
"aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
1592
|
+
className: "orion-admin-sidebar-toggle",
|
|
1593
|
+
onClick: toggleSidebar,
|
|
1594
|
+
type: "button",
|
|
1595
|
+
children: collapsed ? ">" : "<"
|
|
1596
|
+
}
|
|
1597
|
+
),
|
|
1598
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "orion-admin-brand-wrap", children: [
|
|
1599
|
+
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,
|
|
1600
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "orion-admin-brand-text", children: [
|
|
1601
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "orion-admin-brand-name", title: brandName, children: collapsed ? brandName.slice(0, 1).toUpperCase() : brandName }),
|
|
1602
|
+
!collapsed ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "orion-admin-brand-subtitle", children: "Studio" }) : null
|
|
1603
|
+
] })
|
|
1604
|
+
] }),
|
|
1605
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("nav", { className: "orion-admin-nav", children: navItems.filter((item) => roleCanAccessNav(userRole, item)).map((item) => {
|
|
1606
|
+
const active = navItemIsActive(pathname, item);
|
|
1607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1608
|
+
"a",
|
|
1609
|
+
{
|
|
1610
|
+
className: `orion-admin-nav-link ${active ? "is-active" : ""}`,
|
|
1611
|
+
href: item.href,
|
|
1612
|
+
title: item.label,
|
|
1613
|
+
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: [
|
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NavIcon, { name: item.icon }),
|
|
1615
|
+
item.label
|
|
1616
|
+
] }) : collapsed ? item.label.slice(0, 1) : item.label
|
|
1617
|
+
},
|
|
1618
|
+
item.href
|
|
1619
|
+
);
|
|
1620
|
+
}) }),
|
|
1621
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "orion-admin-sidebar-footer", children: [
|
|
1622
|
+
!collapsed ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "orion-admin-user-label", children: "Signed in as" }),
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "orion-admin-user-email", children: userEmail })
|
|
1625
|
+
] }) : null,
|
|
1626
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "orion-admin-logout", disabled: loggingOut, onClick: handleLogout, type: "button", children: loggingOut ? "..." : "Log out" })
|
|
1627
|
+
] })
|
|
1628
|
+
] }),
|
|
1629
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("main", { className: "orion-admin-main", children })
|
|
1630
|
+
] });
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
// src/admin/hooks/useSiteBranding.ts
|
|
1634
|
+
var import_react3 = require("react");
|
|
1635
|
+
var asRecord = (value) => {
|
|
1636
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1637
|
+
return value;
|
|
1638
|
+
};
|
|
1639
|
+
var pickString = (value) => {
|
|
1640
|
+
if (typeof value !== "string") return null;
|
|
1641
|
+
const next = value.trim();
|
|
1642
|
+
return next.length > 0 ? next : null;
|
|
1643
|
+
};
|
|
1644
|
+
var resolveUploadUrl = (value) => {
|
|
1645
|
+
const direct = pickString(value);
|
|
1646
|
+
if (direct) return direct;
|
|
1647
|
+
const record = asRecord(value);
|
|
1648
|
+
if (!record) return null;
|
|
1649
|
+
const fromUrl = pickString(record.url);
|
|
1650
|
+
if (fromUrl) return fromUrl;
|
|
1651
|
+
const fromFilename = pickString(record.filename);
|
|
1652
|
+
if (fromFilename) return `/api/media/file/${fromFilename}`;
|
|
1653
|
+
return null;
|
|
1654
|
+
};
|
|
1655
|
+
var resolveLogoUrl = (settings) => {
|
|
1656
|
+
return resolveUploadUrl(settings.logo) || resolveUploadUrl(settings.adminLogo) || resolveUploadUrl(settings.brandLogo) || null;
|
|
1657
|
+
};
|
|
1658
|
+
var cachedBranding = null;
|
|
1659
|
+
function useSiteBranding(defaultName, defaultLogoUrl) {
|
|
1660
|
+
const [branding, setBranding] = (0, import_react3.useState)(() => {
|
|
1661
|
+
if (cachedBranding) {
|
|
1662
|
+
return {
|
|
1663
|
+
logoUrl: cachedBranding.logoUrl || defaultLogoUrl || null,
|
|
1664
|
+
siteName: cachedBranding.siteName || defaultName || null
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1667
|
+
return {
|
|
1668
|
+
logoUrl: defaultLogoUrl || null,
|
|
1669
|
+
siteName: defaultName || null
|
|
1670
|
+
};
|
|
1671
|
+
});
|
|
1672
|
+
(0, import_react3.useEffect)(() => {
|
|
1673
|
+
let cancelled = false;
|
|
1674
|
+
const run = async () => {
|
|
1675
|
+
try {
|
|
1676
|
+
const res = await fetch("/api/globals/site-settings?depth=1&draft=true", {
|
|
1677
|
+
credentials: "include"
|
|
1678
|
+
});
|
|
1679
|
+
if (!res.ok) return;
|
|
1680
|
+
const data = await res.json();
|
|
1681
|
+
const record = asRecord(data);
|
|
1682
|
+
if (!record) return;
|
|
1683
|
+
const siteName = pickString(record.siteName);
|
|
1684
|
+
const logoUrl = resolveLogoUrl(record);
|
|
1685
|
+
cachedBranding = { logoUrl, siteName };
|
|
1686
|
+
if (!cancelled) {
|
|
1687
|
+
setBranding({
|
|
1688
|
+
logoUrl: logoUrl || defaultLogoUrl || null,
|
|
1689
|
+
siteName: siteName || defaultName || null
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
} catch {
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
void run();
|
|
1696
|
+
return () => {
|
|
1697
|
+
cancelled = true;
|
|
1698
|
+
};
|
|
1699
|
+
}, [defaultLogoUrl, defaultName]);
|
|
1700
|
+
return branding;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
// src/admin/components/studio/adminPathUtils.ts
|
|
1704
|
+
var import_react4 = require("react");
|
|
1705
|
+
var DEFAULT_ADMIN_BASE_PATH = "/admin";
|
|
1706
|
+
var normalizePath = (value) => {
|
|
1707
|
+
if (!value || value === "/") return "/";
|
|
1708
|
+
const withLeadingSlash = value.startsWith("/") ? value : `/${value}`;
|
|
1709
|
+
const trimmed = withLeadingSlash.replace(/\/+$/, "");
|
|
1710
|
+
return trimmed.length > 0 ? trimmed : "/";
|
|
1711
|
+
};
|
|
1712
|
+
var normalizeAdminBasePath = (value) => {
|
|
1713
|
+
const normalized = normalizePath(value);
|
|
1714
|
+
return normalized === "/" ? DEFAULT_ADMIN_BASE_PATH : normalized;
|
|
1715
|
+
};
|
|
1716
|
+
var detectAdminBasePath = (pathname, fallback = DEFAULT_ADMIN_BASE_PATH) => {
|
|
1717
|
+
const normalizedPathname = normalizePath(pathname);
|
|
1718
|
+
const normalizedFallback = normalizeAdminBasePath(fallback);
|
|
1719
|
+
const markers = [
|
|
1720
|
+
"/contact-form",
|
|
1721
|
+
"/collections/",
|
|
1722
|
+
"/globals/",
|
|
1723
|
+
"/forms",
|
|
1724
|
+
"/pages/",
|
|
1725
|
+
"/tools",
|
|
1726
|
+
"/media",
|
|
1727
|
+
"/logout",
|
|
1728
|
+
"/login"
|
|
1729
|
+
];
|
|
1730
|
+
for (const marker of markers) {
|
|
1731
|
+
const index = normalizedPathname.indexOf(marker);
|
|
1732
|
+
if (index > 0) {
|
|
1733
|
+
return normalizeAdminBasePath(normalizedPathname.slice(0, index));
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
if (normalizedPathname === normalizedFallback || normalizedPathname.startsWith(`${normalizedFallback}/`)) {
|
|
1737
|
+
return normalizedFallback;
|
|
1738
|
+
}
|
|
1739
|
+
const segments = normalizedPathname.split("/").filter(Boolean);
|
|
1740
|
+
if (segments.length > 0) {
|
|
1741
|
+
return normalizeAdminBasePath(`/${segments[0]}`);
|
|
1742
|
+
}
|
|
1743
|
+
return normalizedFallback;
|
|
1744
|
+
};
|
|
1745
|
+
var isAbsoluteExternalURL2 = (value) => /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value) || value.startsWith("//");
|
|
1746
|
+
var resolveAdminPath = (adminBasePath, targetPath) => {
|
|
1747
|
+
if (!targetPath) return adminBasePath;
|
|
1748
|
+
if (isAbsoluteExternalURL2(targetPath)) return targetPath;
|
|
1749
|
+
const normalizedBasePath = normalizeAdminBasePath(adminBasePath);
|
|
1750
|
+
const normalizedTargetPath = normalizePath(targetPath);
|
|
1751
|
+
if (normalizedTargetPath === "/admin") {
|
|
1752
|
+
return normalizedBasePath;
|
|
1753
|
+
}
|
|
1754
|
+
if (normalizedTargetPath.startsWith("/admin/")) {
|
|
1755
|
+
return `${normalizedBasePath}${normalizedTargetPath.slice("/admin".length)}`;
|
|
1756
|
+
}
|
|
1757
|
+
if (normalizedTargetPath === normalizedBasePath || normalizedTargetPath.startsWith(`${normalizedBasePath}/`)) {
|
|
1758
|
+
return normalizedTargetPath;
|
|
1759
|
+
}
|
|
1760
|
+
if (normalizedTargetPath === "/") {
|
|
1761
|
+
return normalizedBasePath;
|
|
1762
|
+
}
|
|
1763
|
+
return `${normalizedBasePath}${normalizedTargetPath}`;
|
|
1764
|
+
};
|
|
1765
|
+
var useAdminBasePath = (fallback = DEFAULT_ADMIN_BASE_PATH) => {
|
|
1766
|
+
const [adminBasePath, setAdminBasePath] = (0, import_react4.useState)(normalizeAdminBasePath(fallback));
|
|
1767
|
+
(0, import_react4.useEffect)(() => {
|
|
1768
|
+
const update = () => {
|
|
1769
|
+
setAdminBasePath(detectAdminBasePath(window.location.pathname, fallback));
|
|
1770
|
+
};
|
|
1771
|
+
update();
|
|
1772
|
+
window.addEventListener("popstate", update);
|
|
1773
|
+
return () => window.removeEventListener("popstate", update);
|
|
1774
|
+
}, [fallback]);
|
|
1775
|
+
return adminBasePath;
|
|
1776
|
+
};
|
|
1777
|
+
|
|
1778
|
+
// src/admin/components/studio/studioNavModel.ts
|
|
1779
|
+
var getPropString = (props, key, fallback) => {
|
|
1780
|
+
if (!props || typeof props !== "object") return fallback;
|
|
1781
|
+
const direct = props[key];
|
|
1782
|
+
if (typeof direct === "string" && direct.length > 0) return direct;
|
|
1783
|
+
const clientProps = props.clientProps;
|
|
1784
|
+
if (clientProps && typeof clientProps === "object") {
|
|
1785
|
+
const nested = clientProps[key];
|
|
1786
|
+
if (typeof nested === "string" && nested.length > 0) return nested;
|
|
1787
|
+
}
|
|
1788
|
+
return fallback;
|
|
1789
|
+
};
|
|
1790
|
+
var getPropBoolean = (props, key, fallback) => {
|
|
1791
|
+
if (!props || typeof props !== "object") return fallback;
|
|
1792
|
+
const direct = props[key];
|
|
1793
|
+
if (typeof direct === "boolean") return direct;
|
|
1794
|
+
const clientProps = props.clientProps;
|
|
1795
|
+
if (clientProps && typeof clientProps === "object") {
|
|
1796
|
+
const nested = clientProps[key];
|
|
1797
|
+
if (typeof nested === "boolean") return nested;
|
|
1798
|
+
}
|
|
1799
|
+
return fallback;
|
|
1800
|
+
};
|
|
1801
|
+
var getPropStringArray = (props, key, fallback) => {
|
|
1802
|
+
if (!props || typeof props !== "object") return fallback;
|
|
1803
|
+
const read = (candidate) => Array.isArray(candidate) ? candidate.filter((value) => typeof value === "string" && value.length > 0) : null;
|
|
1804
|
+
const direct = read(props[key]);
|
|
1805
|
+
if (direct) return direct;
|
|
1806
|
+
const clientProps = props.clientProps;
|
|
1807
|
+
if (clientProps && typeof clientProps === "object") {
|
|
1808
|
+
const nested = read(clientProps[key]);
|
|
1809
|
+
if (nested) return nested;
|
|
1810
|
+
}
|
|
1811
|
+
return fallback;
|
|
1812
|
+
};
|
|
1813
|
+
var getPropSections = (props) => {
|
|
1814
|
+
if (!props || typeof props !== "object") return [];
|
|
1815
|
+
const direct = resolveStudioSections(props.sections);
|
|
1816
|
+
if (direct.length > 0) return direct;
|
|
1817
|
+
const clientProps = props.clientProps;
|
|
1818
|
+
if (clientProps && typeof clientProps === "object") {
|
|
1819
|
+
return resolveStudioSections(clientProps.sections);
|
|
1820
|
+
}
|
|
1821
|
+
return [];
|
|
1822
|
+
};
|
|
1823
|
+
var readUserRole = (user) => {
|
|
1824
|
+
if (!user || typeof user !== "object") {
|
|
1825
|
+
return void 0;
|
|
1826
|
+
}
|
|
1827
|
+
const role = user.role;
|
|
1828
|
+
return typeof role === "string" ? role : void 0;
|
|
1829
|
+
};
|
|
1830
|
+
var buildStudioNavItems = (props, adminBasePath) => {
|
|
1831
|
+
const formsEnabled = getPropBoolean(props, "formsEnabled", false);
|
|
1832
|
+
const formsCollectionSlug = getPropString(props, "formsCollectionSlug", "forms");
|
|
1833
|
+
const formSubmissionsCollectionSlug = getPropString(
|
|
1834
|
+
props,
|
|
1835
|
+
"formSubmissionsCollectionSlug",
|
|
1836
|
+
"form-submissions"
|
|
1837
|
+
);
|
|
1838
|
+
const formUploadsCollectionSlug = getPropString(props, "formUploadsCollectionSlug", "form-uploads");
|
|
1839
|
+
const mediaCollectionSlug = getPropString(props, "mediaCollectionSlug", "media");
|
|
1840
|
+
const globalsBasePath = getPropString(props, "globalsBasePath", "/globals");
|
|
1841
|
+
const globalsExtraMatchPrefixes = getPropStringArray(props, "globalsExtraMatchPrefixes", []);
|
|
1842
|
+
const sections = getPropSections(props);
|
|
1843
|
+
const pagesPath = resolveAdminPath(adminBasePath, "/pages");
|
|
1844
|
+
const formsPath = resolveAdminPath(adminBasePath, "/forms");
|
|
1845
|
+
const mediaPath = resolveAdminPath(adminBasePath, "/media");
|
|
1846
|
+
const toolsPath = resolveAdminPath(adminBasePath, "/tools");
|
|
1847
|
+
const resolvedGlobalsBasePath = resolveAdminPath(adminBasePath, globalsBasePath);
|
|
1848
|
+
const resolvedGlobalsExtraMatchPrefixes = globalsExtraMatchPrefixes.map(
|
|
1849
|
+
(prefix) => resolveAdminPath(adminBasePath, prefix)
|
|
1850
|
+
);
|
|
1851
|
+
const baseItemsBeforeTools = [
|
|
1852
|
+
{
|
|
1853
|
+
href: adminBasePath,
|
|
1854
|
+
icon: "dashboard",
|
|
1855
|
+
label: "Dashboard",
|
|
1856
|
+
matchPrefixes: [adminBasePath]
|
|
1857
|
+
},
|
|
1858
|
+
{
|
|
1859
|
+
href: pagesPath,
|
|
1860
|
+
icon: "pages",
|
|
1861
|
+
label: "Pages",
|
|
1862
|
+
matchPrefixes: [pagesPath]
|
|
1863
|
+
},
|
|
1864
|
+
...formsEnabled ? [
|
|
1865
|
+
{
|
|
1866
|
+
href: formsPath,
|
|
1867
|
+
icon: "forms",
|
|
1868
|
+
label: "Forms",
|
|
1869
|
+
matchPrefixes: [
|
|
1870
|
+
formsPath,
|
|
1871
|
+
resolveAdminPath(adminBasePath, `/collections/${formsCollectionSlug}`),
|
|
1872
|
+
resolveAdminPath(adminBasePath, `/collections/${formSubmissionsCollectionSlug}`),
|
|
1873
|
+
resolveAdminPath(adminBasePath, `/collections/${formUploadsCollectionSlug}`)
|
|
1874
|
+
]
|
|
1875
|
+
}
|
|
1876
|
+
] : [],
|
|
1877
|
+
{
|
|
1878
|
+
href: resolvedGlobalsBasePath,
|
|
1879
|
+
icon: "globals",
|
|
1880
|
+
label: "Globals",
|
|
1881
|
+
matchPrefixes: [
|
|
1882
|
+
resolvedGlobalsBasePath,
|
|
1883
|
+
resolveAdminPath(adminBasePath, "/globals"),
|
|
1884
|
+
...resolvedGlobalsExtraMatchPrefixes
|
|
1885
|
+
]
|
|
1886
|
+
},
|
|
1887
|
+
{
|
|
1888
|
+
href: mediaPath,
|
|
1889
|
+
icon: "media",
|
|
1890
|
+
label: "Media",
|
|
1891
|
+
matchPrefixes: [mediaPath, resolveAdminPath(adminBasePath, `/collections/${mediaCollectionSlug}`)]
|
|
1892
|
+
}
|
|
1893
|
+
];
|
|
1894
|
+
const adminToolsItem = {
|
|
1895
|
+
href: toolsPath,
|
|
1896
|
+
icon: "tools",
|
|
1897
|
+
label: "Admin Tools",
|
|
1898
|
+
matchPrefixes: [toolsPath, resolveAdminPath(adminBasePath, "/collections/users")],
|
|
1899
|
+
roles: ["admin"]
|
|
1900
|
+
};
|
|
1901
|
+
const extensionItems = sections.map((section) => ({
|
|
1902
|
+
href: resolveAdminPath(adminBasePath, section.href),
|
|
1903
|
+
...section.icon ? { icon: section.icon } : {},
|
|
1904
|
+
label: section.label,
|
|
1905
|
+
matchPrefixes: section.matchPrefixes.map((prefix) => resolveAdminPath(adminBasePath, prefix)),
|
|
1906
|
+
roles: section.roles
|
|
1907
|
+
}));
|
|
1908
|
+
return [...baseItemsBeforeTools, ...extensionItems, adminToolsItem];
|
|
1909
|
+
};
|
|
1910
|
+
|
|
1911
|
+
// src/admin/components/studio/StudioSectionLayout.tsx
|
|
1912
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1913
|
+
function StudioSectionLayout({ children, navProps }) {
|
|
1914
|
+
const { user } = (0, import_ui.useAuth)();
|
|
1915
|
+
const pathname = (0, import_navigation.usePathname)() || "";
|
|
1916
|
+
const router = (0, import_navigation.useRouter)();
|
|
1917
|
+
const adminBasePath = useAdminBasePath();
|
|
1918
|
+
const defaultBrandName = getPropString(navProps, "brandName", "Orion Studio");
|
|
1919
|
+
const defaultLogoUrl = getPropString(navProps, "logoUrl", "");
|
|
1920
|
+
const navItems = (0, import_react5.useMemo)(
|
|
1921
|
+
() => buildStudioNavItems(navProps, adminBasePath),
|
|
1922
|
+
[adminBasePath, navProps]
|
|
1923
|
+
);
|
|
1924
|
+
const branding = useSiteBranding(defaultBrandName, defaultLogoUrl || void 0);
|
|
1925
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
1926
|
+
document.body.classList.add("orion-studio-shell-active");
|
|
1927
|
+
return () => {
|
|
1928
|
+
document.body.classList.remove("orion-studio-shell-active");
|
|
1929
|
+
};
|
|
1930
|
+
}, []);
|
|
1931
|
+
const logout = (0, import_react5.useMemo)(
|
|
1932
|
+
() => async () => {
|
|
1933
|
+
await fetch("/api/users/logout", {
|
|
1934
|
+
credentials: "include",
|
|
1935
|
+
method: "POST"
|
|
1936
|
+
});
|
|
1937
|
+
router.push(resolveAdminPath(adminBasePath, "/login"));
|
|
1938
|
+
router.refresh();
|
|
1939
|
+
},
|
|
1940
|
+
[adminBasePath, router]
|
|
1941
|
+
);
|
|
1942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1943
|
+
AdminShellClient,
|
|
1944
|
+
{
|
|
1945
|
+
brandName: branding.siteName || defaultBrandName,
|
|
1946
|
+
logoUrl: branding.logoUrl || defaultLogoUrl || void 0,
|
|
1947
|
+
navItems,
|
|
1948
|
+
onLogout: logout,
|
|
1949
|
+
pathname,
|
|
1950
|
+
storageKey: "orion-admin-sidebar-collapsed-v1",
|
|
1951
|
+
userEmail: typeof user?.email === "string" ? user.email : "user",
|
|
1952
|
+
userRole: readUserRole(user),
|
|
1953
|
+
children
|
|
1954
|
+
}
|
|
1955
|
+
);
|
|
1956
|
+
}
|
|
1957
|
+
|
|
1958
|
+
// src/admin/components/studio/AdminStudioDashboard.tsx
|
|
1959
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1960
|
+
var DEFAULT_ADMIN_BASE_PATH2 = "/admin";
|
|
1961
|
+
var normalizePath2 = (value) => {
|
|
1962
|
+
if (!value || value === "/") return "/";
|
|
1963
|
+
const withLeadingSlash = value.startsWith("/") ? value : `/${value}`;
|
|
1964
|
+
const trimmed = withLeadingSlash.replace(/\/+$/, "");
|
|
1965
|
+
return trimmed.length > 0 ? trimmed : "/";
|
|
1966
|
+
};
|
|
1967
|
+
var normalizeAdminBasePath2 = (value) => {
|
|
1968
|
+
const normalized = normalizePath2(value);
|
|
1969
|
+
return normalized === "/" ? DEFAULT_ADMIN_BASE_PATH2 : normalized;
|
|
1970
|
+
};
|
|
1971
|
+
var isAbsoluteExternalURL3 = (value) => /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value) || value.startsWith("//");
|
|
1972
|
+
var resolveAdminPath2 = (adminBasePath, targetPath) => {
|
|
1973
|
+
if (!targetPath) return adminBasePath;
|
|
1974
|
+
if (isAbsoluteExternalURL3(targetPath)) return targetPath;
|
|
1975
|
+
const normalizedBasePath = normalizeAdminBasePath2(adminBasePath);
|
|
1976
|
+
const normalizedTargetPath = normalizePath2(targetPath);
|
|
1977
|
+
if (normalizedTargetPath === "/admin") {
|
|
1978
|
+
return normalizedBasePath;
|
|
1979
|
+
}
|
|
1980
|
+
if (normalizedTargetPath.startsWith("/admin/")) {
|
|
1981
|
+
return `${normalizedBasePath}${normalizedTargetPath.slice("/admin".length)}`;
|
|
1982
|
+
}
|
|
1983
|
+
if (normalizedTargetPath === normalizedBasePath || normalizedTargetPath.startsWith(`${normalizedBasePath}/`)) {
|
|
1984
|
+
return normalizedTargetPath;
|
|
1985
|
+
}
|
|
1986
|
+
if (normalizedTargetPath === "/") {
|
|
1987
|
+
return normalizedBasePath;
|
|
1988
|
+
}
|
|
1989
|
+
return `${normalizedBasePath}${normalizedTargetPath}`;
|
|
1990
|
+
};
|
|
1991
|
+
var getPropString2 = (props, key, fallback) => {
|
|
1992
|
+
if (!props || typeof props !== "object") return fallback;
|
|
1993
|
+
const direct = props[key];
|
|
1994
|
+
if (typeof direct === "string" && direct.length > 0) return direct;
|
|
1995
|
+
const clientProps = props.clientProps;
|
|
1996
|
+
if (clientProps && typeof clientProps === "object") {
|
|
1997
|
+
const nested = clientProps[key];
|
|
1998
|
+
if (typeof nested === "string" && nested.length > 0) return nested;
|
|
1999
|
+
}
|
|
2000
|
+
return fallback;
|
|
2001
|
+
};
|
|
2002
|
+
var getPropBoolean2 = (props, key, fallback) => {
|
|
2003
|
+
if (!props || typeof props !== "object") return fallback;
|
|
2004
|
+
const direct = props[key];
|
|
2005
|
+
if (typeof direct === "boolean") return direct;
|
|
2006
|
+
const clientProps = props.clientProps;
|
|
2007
|
+
if (clientProps && typeof clientProps === "object") {
|
|
2008
|
+
const nested = clientProps[key];
|
|
2009
|
+
if (typeof nested === "boolean") return nested;
|
|
2010
|
+
}
|
|
2011
|
+
return fallback;
|
|
2012
|
+
};
|
|
2013
|
+
var getPropSections2 = (props) => {
|
|
2014
|
+
if (!props || typeof props !== "object") return [];
|
|
2015
|
+
const direct = resolveStudioSections(props.sections);
|
|
2016
|
+
if (direct.length > 0) return direct;
|
|
2017
|
+
const clientProps = props.clientProps;
|
|
2018
|
+
if (clientProps && typeof clientProps === "object") {
|
|
2019
|
+
return resolveStudioSections(clientProps.sections);
|
|
2020
|
+
}
|
|
2021
|
+
return [];
|
|
2022
|
+
};
|
|
2023
|
+
var getPropDashboardPanels = (props) => {
|
|
2024
|
+
if (!props || typeof props !== "object") return [];
|
|
2025
|
+
const direct = resolveStudioSectionDashboards(props.dashboardPanels);
|
|
2026
|
+
if (direct.length > 0) return direct;
|
|
2027
|
+
const clientProps = props.clientProps;
|
|
2028
|
+
if (clientProps && typeof clientProps === "object") {
|
|
2029
|
+
return resolveStudioSectionDashboards(clientProps.dashboardPanels);
|
|
2030
|
+
}
|
|
2031
|
+
return [];
|
|
2032
|
+
};
|
|
2033
|
+
var readImportMap = (props) => {
|
|
2034
|
+
if (!props || typeof props !== "object") return void 0;
|
|
2035
|
+
const direct = props.importMap;
|
|
2036
|
+
if (direct && typeof direct === "object") {
|
|
2037
|
+
return direct;
|
|
2038
|
+
}
|
|
2039
|
+
const payloadLike = props.payload;
|
|
2040
|
+
if (payloadLike && typeof payloadLike === "object") {
|
|
2041
|
+
const nested = payloadLike.importMap;
|
|
2042
|
+
if (nested && typeof nested === "object") {
|
|
2043
|
+
return nested;
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
const initPageResult = props.initPageResult;
|
|
2047
|
+
if (initPageResult && typeof initPageResult === "object") {
|
|
2048
|
+
const req = initPageResult.req;
|
|
2049
|
+
if (req && typeof req === "object") {
|
|
2050
|
+
const payload = req.payload;
|
|
2051
|
+
if (payload && typeof payload === "object") {
|
|
2052
|
+
const nested = payload.importMap;
|
|
2053
|
+
if (nested && typeof nested === "object") {
|
|
2054
|
+
return nested;
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
return void 0;
|
|
2060
|
+
};
|
|
2061
|
+
var readUserRole2 = (props) => {
|
|
2062
|
+
if (!props || typeof props !== "object") return void 0;
|
|
2063
|
+
const user = props.user;
|
|
2064
|
+
if (user && typeof user === "object") {
|
|
2065
|
+
const role = user.role;
|
|
2066
|
+
if (typeof role === "string") {
|
|
2067
|
+
return role;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
const initPageResult = props.initPageResult;
|
|
2071
|
+
if (initPageResult && typeof initPageResult === "object") {
|
|
2072
|
+
const req = initPageResult.req;
|
|
2073
|
+
if (req && typeof req === "object") {
|
|
2074
|
+
const nestedUser = req.user;
|
|
2075
|
+
if (nestedUser && typeof nestedUser === "object") {
|
|
2076
|
+
const role = nestedUser.role;
|
|
2077
|
+
if (typeof role === "string") {
|
|
2078
|
+
return role;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
return void 0;
|
|
2084
|
+
};
|
|
2085
|
+
var readAdminBasePath = (props) => {
|
|
2086
|
+
if (!props || typeof props !== "object") {
|
|
2087
|
+
return DEFAULT_ADMIN_BASE_PATH2;
|
|
2088
|
+
}
|
|
2089
|
+
const payloadLike = props.payload;
|
|
2090
|
+
if (payloadLike && typeof payloadLike === "object") {
|
|
2091
|
+
const config = payloadLike.config;
|
|
2092
|
+
const routes = config && typeof config === "object" ? config.routes : null;
|
|
2093
|
+
const admin = routes && typeof routes === "object" ? routes.admin : null;
|
|
2094
|
+
if (typeof admin === "string" && admin.length > 0) {
|
|
2095
|
+
return normalizeAdminBasePath2(admin);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
const initPageResult = props.initPageResult;
|
|
2099
|
+
if (initPageResult && typeof initPageResult === "object") {
|
|
2100
|
+
const req = initPageResult.req;
|
|
2101
|
+
if (req && typeof req === "object") {
|
|
2102
|
+
const nestedPayload = req.payload;
|
|
2103
|
+
if (nestedPayload && typeof nestedPayload === "object") {
|
|
2104
|
+
const config = nestedPayload.config;
|
|
2105
|
+
const routes = config && typeof config === "object" ? config.routes : null;
|
|
2106
|
+
const admin = routes && typeof routes === "object" ? routes.admin : null;
|
|
2107
|
+
if (typeof admin === "string" && admin.length > 0) {
|
|
2108
|
+
return normalizeAdminBasePath2(admin);
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
return DEFAULT_ADMIN_BASE_PATH2;
|
|
2114
|
+
};
|
|
2115
|
+
var canAccess2 = (role, roles) => {
|
|
2116
|
+
if (!roles || roles.length === 0) {
|
|
2117
|
+
return true;
|
|
2118
|
+
}
|
|
2119
|
+
if (!role) {
|
|
2120
|
+
return false;
|
|
2121
|
+
}
|
|
2122
|
+
return roles.includes(role);
|
|
2123
|
+
};
|
|
2124
|
+
var buildSectionLinks = (adminBasePath, sections, formsEnabled, globalsBasePath) => {
|
|
2125
|
+
const links = [
|
|
2126
|
+
{
|
|
2127
|
+
href: resolveAdminPath2(adminBasePath, "/pages"),
|
|
2128
|
+
id: "pages",
|
|
2129
|
+
label: "Pages"
|
|
2130
|
+
},
|
|
2131
|
+
...formsEnabled ? [
|
|
2132
|
+
{
|
|
2133
|
+
href: resolveAdminPath2(adminBasePath, "/forms"),
|
|
2134
|
+
id: "forms",
|
|
2135
|
+
label: "Forms",
|
|
2136
|
+
roles: ["admin", "editor"]
|
|
2137
|
+
}
|
|
2138
|
+
] : [],
|
|
2139
|
+
{
|
|
2140
|
+
href: resolveAdminPath2(adminBasePath, globalsBasePath),
|
|
2141
|
+
id: "globals",
|
|
2142
|
+
label: "Globals"
|
|
2143
|
+
},
|
|
2144
|
+
{
|
|
2145
|
+
href: resolveAdminPath2(adminBasePath, "/media"),
|
|
2146
|
+
id: "media",
|
|
2147
|
+
label: "Media"
|
|
2148
|
+
},
|
|
2149
|
+
...sections.map((section) => ({
|
|
2150
|
+
href: resolveAdminPath2(adminBasePath, section.href),
|
|
2151
|
+
id: section.id,
|
|
2152
|
+
label: section.label,
|
|
2153
|
+
...section.roles ? { roles: section.roles } : {}
|
|
2154
|
+
})),
|
|
2155
|
+
{
|
|
2156
|
+
href: resolveAdminPath2(adminBasePath, "/tools"),
|
|
2157
|
+
id: "admin-tools",
|
|
2158
|
+
label: "Admin Tools",
|
|
2159
|
+
roles: ["admin"]
|
|
2160
|
+
}
|
|
2161
|
+
];
|
|
2162
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2163
|
+
return links.filter((link) => {
|
|
2164
|
+
if (seen.has(link.id)) {
|
|
2165
|
+
return false;
|
|
2166
|
+
}
|
|
2167
|
+
seen.add(link.id);
|
|
2168
|
+
return true;
|
|
2169
|
+
});
|
|
2170
|
+
};
|
|
2171
|
+
function DashboardPanelFallback({ label }) {
|
|
2172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "orion-dashboard-extension-fallback", children: [
|
|
2173
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "orion-dashboard-panel-kicker", children: "Extension Unavailable" }),
|
|
2174
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: label }),
|
|
2175
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: "This dashboard panel could not be rendered, but the rest of the dashboard is still available." })
|
|
2176
|
+
] });
|
|
2177
|
+
}
|
|
2178
|
+
function buildExtensionPanels(adminBasePath, importMap, panels, userRole) {
|
|
2179
|
+
const visiblePanels = panels.filter((panel) => canAccess2(userRole, panel.roles));
|
|
2180
|
+
return visiblePanels.map((panel) => {
|
|
2181
|
+
const href = resolveAdminPath2(adminBasePath, panel.href);
|
|
2182
|
+
return {
|
|
2183
|
+
id: panel.id,
|
|
2184
|
+
node: importMap ? (0, import_RenderServerComponent.RenderServerComponent)({
|
|
2185
|
+
Component: panel.Component,
|
|
2186
|
+
Fallback: () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DashboardPanelFallback, { label: panel.label }),
|
|
2187
|
+
importMap,
|
|
2188
|
+
serverProps: {
|
|
2189
|
+
adminBasePath,
|
|
2190
|
+
href,
|
|
2191
|
+
label: panel.label
|
|
2192
|
+
}
|
|
2193
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DashboardPanelFallback, { label: panel.label }),
|
|
2194
|
+
span: panel.span
|
|
2195
|
+
};
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
function AdminStudioDashboard(rawProps) {
|
|
2199
|
+
const props = rawProps || {};
|
|
2200
|
+
const formsEnabled = getPropBoolean2(props, "formsEnabled", false);
|
|
2201
|
+
const globalsBasePath = getPropString2(props, "globalsBasePath", "/globals");
|
|
2202
|
+
const sections = getPropSections2(props);
|
|
2203
|
+
const dashboardPanels = getPropDashboardPanels(props);
|
|
2204
|
+
const pagesCollectionSlug = getPropString2(props, "pagesCollectionSlug", "pages");
|
|
2205
|
+
const formsCollectionSlug = getPropString2(props, "formsCollectionSlug", "forms");
|
|
2206
|
+
const formSubmissionsCollectionSlug = getPropString2(
|
|
2207
|
+
props,
|
|
2208
|
+
"formSubmissionsCollectionSlug",
|
|
2209
|
+
"form-submissions"
|
|
2210
|
+
);
|
|
2211
|
+
const mediaCollectionSlug = getPropString2(props, "mediaCollectionSlug", "media");
|
|
2212
|
+
const adminBasePath = readAdminBasePath(props);
|
|
2213
|
+
const importMap = readImportMap(props);
|
|
2214
|
+
const userRole = readUserRole2(props);
|
|
2215
|
+
const navProps = {
|
|
2216
|
+
brandName: getPropString2(props, "brandName", "Orion Studio"),
|
|
2217
|
+
dashboardPanels,
|
|
2218
|
+
formSubmissionsCollectionSlug,
|
|
2219
|
+
formsCollectionSlug,
|
|
2220
|
+
formsEnabled,
|
|
2221
|
+
globalsBasePath,
|
|
2222
|
+
logoUrl: getPropString2(props, "logoUrl", ""),
|
|
2223
|
+
mediaCollectionSlug,
|
|
2224
|
+
pagesCollectionSlug,
|
|
2225
|
+
sections
|
|
2226
|
+
};
|
|
2227
|
+
const extensionPanels = buildExtensionPanels(adminBasePath, importMap, dashboardPanels, userRole);
|
|
2228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StudioSectionLayout, { navProps, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2229
|
+
AdminPage,
|
|
2230
|
+
{
|
|
2231
|
+
breadcrumbs: [{ label: "Dashboard" }],
|
|
2232
|
+
description: "What needs attention, what changed recently, and how the site is performing.",
|
|
2233
|
+
title: "Studio",
|
|
2234
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2235
|
+
AdminStudioDashboardClient,
|
|
2236
|
+
{
|
|
2237
|
+
extensionPanels,
|
|
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
|
+
}
|
|
2251
|
+
)
|
|
2252
|
+
}
|
|
2253
|
+
) });
|
|
2254
|
+
}
|
|
2255
|
+
|
|
753
2256
|
// src/admin/helpers/withTooltips.ts
|
|
754
2257
|
var defaultTooltips = {
|
|
755
2258
|
title: "The main title displayed on this page.",
|
|
@@ -1006,6 +2509,7 @@ var createSocialMediaGlobal = (options = {}) => ({
|
|
|
1006
2509
|
});
|
|
1007
2510
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1008
2511
|
0 && (module.exports = {
|
|
2512
|
+
AdminStudioDashboard,
|
|
1009
2513
|
SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
|
|
1010
2514
|
SOCIAL_MEDIA_ICON_OPTIONS,
|
|
1011
2515
|
SOCIAL_MEDIA_PLATFORMS,
|