@chaibuilder/pages 0.13.4 → 0.14.1
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/{2AITGKQY-Dx_Cte-P.js → 2AITGKQY-Cti4x7QE.js} +5 -5
- package/dist/{2AITGKQY-DpAgk_u8.cjs → 2AITGKQY-PHs1xUsz.cjs} +1 -1
- package/dist/{NCMVHL6D-B6lv7Umq.cjs → NCMVHL6D-BChQ0wDN.cjs} +1 -1
- package/dist/{NCMVHL6D-CT2qHOTS.js → NCMVHL6D-fAWarBw8.js} +4 -4
- package/dist/{ZDWCUMSJ-C1vrgsti.cjs → ZDWCUMSJ-CwWfQqyn.cjs} +1 -1
- package/dist/{ZDWCUMSJ-W9xywtZH.js → ZDWCUMSJ-DRWuu_nE.js} +1 -1
- package/dist/add-new-language-page-CcBqDtYv.js +390 -0
- package/dist/add-new-language-page-Dt9DWunK.cjs +1 -0
- package/dist/add-new-page-BN3z9rSq.cjs +1 -0
- package/dist/add-new-page-CTUiEKzv.js +30 -0
- package/dist/confetti.module-BuUnQuWk.cjs +2 -0
- package/dist/confetti.module-DCmCkDyV.js +409 -0
- package/dist/delete-page-8MnGZ_mz.js +38 -0
- package/dist/delete-page-jELwTpGY.cjs +1 -0
- package/dist/digital-asset-manager-BJhwyEdT.js +976 -0
- package/dist/digital-asset-manager-ZyQJP6AO.cjs +1 -0
- package/dist/duplicate-page-BGYZLkco.js +120 -0
- package/dist/duplicate-page-BRjKFpBP.cjs +1 -0
- package/dist/dynamic-page-selector-CR-ZpSJ8.cjs +1 -0
- package/dist/dynamic-page-selector-CrbujoYg.js +86 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/index-Byi6-4u1.js +5164 -0
- package/dist/index-DSUpSpeI.cjs +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -22
- package/dist/index.js +18 -19
- package/dist/json-diff-viewer-DKlC7yl6.cjs +8 -0
- package/dist/json-diff-viewer-De2bStRw.js +258 -0
- package/dist/lang-panel-B3bC1gKq.cjs +1 -0
- package/dist/lang-panel-G7RoMOP7.js +218 -0
- package/dist/mark-as-template-B1TpGPms.js +146 -0
- package/dist/mark-as-template-OgR8I38n.cjs +1 -0
- package/dist/nested-path-selector-content-D_iF9Sm3.cjs +1 -0
- package/dist/nested-path-selector-content-DvIL_EoN.js +87 -0
- package/dist/no-language-page-content-CqH4FMNy.js +35 -0
- package/dist/no-language-page-content-iZo2ztXp.cjs +1 -0
- package/dist/page-creator-Chnj3W4j.js +796 -0
- package/dist/page-creator-DUXzx-zg.cjs +1 -0
- package/dist/page-lock-request-D3gmV8Yq.cjs +1 -0
- package/dist/page-lock-request-Dc-JkLEZ.js +64 -0
- package/dist/page-locked-by-dialog-B9pGi6zb.cjs +1 -0
- package/dist/page-locked-by-dialog-DC8UKy9e.js +63 -0
- package/dist/page-manager-new-CFtYUNbS.cjs +1 -0
- package/dist/page-manager-new-DYYWpxWy.js +354 -0
- package/dist/page-manager-search-and-filter-B4xo9IJO.js +197 -0
- package/dist/page-manager-search-and-filter-DT9V9AoS.cjs +1 -0
- package/dist/page-revisions-content-BjIECUPY.cjs +1 -0
- package/dist/page-revisions-content-KJGhm9Pl.js +446 -0
- package/dist/publish-pages-content-BWLQZGjd.js +178 -0
- package/dist/publish-pages-content-CTduLNtg.cjs +1 -0
- package/dist/save-to-lib-B07GbG4I.js +476 -0
- package/dist/save-to-lib-CsrSeusU.cjs +1 -0
- package/dist/seo-panel-B20DCgo0.js +667 -0
- package/dist/seo-panel-QphuqXT2.cjs +1 -0
- package/dist/shared-json-ld-C_vIO-Qk.cjs +1 -0
- package/dist/shared-json-ld-CkOQRUEw.js +337 -0
- package/dist/slug-input-71BuN79c.cjs +1 -0
- package/dist/slug-input-rAe3mMkd.js +87 -0
- package/dist/theme-panel-footer-DFUfCqKP.js +25 -0
- package/dist/theme-panel-footer-DHRs6ag2.cjs +1 -0
- package/dist/translation-warning-modal-DalBhNQy.js +26 -0
- package/dist/translation-warning-modal-Kctu12rQ.cjs +1 -0
- package/dist/unmark-as-template-Cx0CqrpM.cjs +1 -0
- package/dist/unmark-as-template-_VyWoVNk.js +38 -0
- package/dist/unpublish-page-CuSJRr5c.js +26 -0
- package/dist/unpublish-page-D3NM8b3u.cjs +1 -0
- package/dist/use-page-expand-manager-MjYZ3CDZ.cjs +1 -0
- package/dist/use-page-expand-manager-_msrWd0a.js +85 -0
- package/dist/web-preview-BL-vsgoa.js +73 -0
- package/dist/web-preview-CI3Vz7Yp.cjs +1 -0
- package/package.json +1 -1
- package/dist/index-C4j31Yhz.js +0 -11471
- package/dist/index-DnjETHks.cjs +0 -6
- package/dist/page-revisions-content-Gx-Qf_91.cjs +0 -8
- package/dist/page-revisions-content-_-Nd4U11.js +0 -712
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { jsxs as n, Fragment as p, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { ak as C, al as A, A as b, am as q, ax as le, aq as I, av as R, aw as w } from "./index-Byi6-4u1.js";
|
|
3
|
+
import { useQuery as re, useQueryClient as k, useMutation as G } from "@tanstack/react-query";
|
|
4
|
+
import { useLanguages as ie, useSavePage as de } from "@chaibuilder/sdk";
|
|
5
|
+
import { SheetHeader as ce, SheetTitle as oe, ScrollArea as ue, Skeleton as y, Button as g, DropdownMenu as me, DropdownMenuTrigger as he, DropdownMenuContent as fe, DropdownMenuItem as U, DropdownMenuSeparator as pe, Dialog as j, DialogContent as L, DialogHeader as P, DialogTitle as $, DialogDescription as z, DialogFooter as H } from "@chaibuilder/sdk/ui";
|
|
6
|
+
import { format as D, formatDistanceToNow as xe } from "date-fns";
|
|
7
|
+
import { isEmpty as ge } from "lodash-es";
|
|
8
|
+
import { FileJson as Ne, MoreHorizontal as be, Undo2 as J, Trash as Q, CloudOff as ye, Rocket as ve, Save as we, X as De } from "lucide-react";
|
|
9
|
+
import * as v from "react";
|
|
10
|
+
import { useEffect as F, lazy as Se, useState as Ee, Suspense as Re } from "react";
|
|
11
|
+
function Ce(t) {
|
|
12
|
+
const s = C(), a = A();
|
|
13
|
+
return re({
|
|
14
|
+
queryKey: [b.GET_PAGE_REVISIONS, t],
|
|
15
|
+
queryFn: async () => await a(s, {
|
|
16
|
+
action: b.GET_PAGE_REVISIONS,
|
|
17
|
+
data: { pageId: t }
|
|
18
|
+
}),
|
|
19
|
+
enabled: !!t,
|
|
20
|
+
refetchOnMount: !0
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const Ae = () => {
|
|
24
|
+
const t = C(), s = A(), a = k();
|
|
25
|
+
return G({
|
|
26
|
+
mutationFn: async (i) => await s(t, {
|
|
27
|
+
action: b.DELETE_PAGE_REVISION,
|
|
28
|
+
data: { revisionId: i }
|
|
29
|
+
}),
|
|
30
|
+
onSuccess: () => {
|
|
31
|
+
a.invalidateQueries({
|
|
32
|
+
queryKey: ["revisions"]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}, Ie = () => {
|
|
37
|
+
const t = C(), s = A(), a = k();
|
|
38
|
+
return G({
|
|
39
|
+
mutationFn: async ({ revisionId: i, discardCurrent: l }) => await s(t, {
|
|
40
|
+
action: b.RESTORE_PAGE_REVISION,
|
|
41
|
+
data: { revisionId: i, discardCurrent: l }
|
|
42
|
+
}),
|
|
43
|
+
onSuccess: () => {
|
|
44
|
+
a.invalidateQueries({
|
|
45
|
+
queryKey: ["revisions"]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}, ke = Se(() => import("./json-diff-viewer-De2bStRw.js")), N = ({ tag: t }) => t === "draft" ? /* @__PURE__ */ n("div", { className: "flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600", children: [
|
|
50
|
+
/* @__PURE__ */ n("span", { className: "relative flex h-2 w-2", children: [
|
|
51
|
+
/* @__PURE__ */ e("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75" }),
|
|
52
|
+
/* @__PURE__ */ e("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-amber-500" })
|
|
53
|
+
] }),
|
|
54
|
+
/* @__PURE__ */ e("span", { className: "text-[11px] leading-tight", children: "Draft" })
|
|
55
|
+
] }) : t === "live" ? /* @__PURE__ */ n("span", { className: "flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary", children: [
|
|
56
|
+
/* @__PURE__ */ n("span", { className: "relative flex h-2 w-2", children: [
|
|
57
|
+
/* @__PURE__ */ e("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75" }),
|
|
58
|
+
/* @__PURE__ */ e("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-green-500" })
|
|
59
|
+
] }),
|
|
60
|
+
/* @__PURE__ */ e("span", { className: "text-[11px] leading-tight", children: "Live" })
|
|
61
|
+
] }) : t === "published" ? /* @__PURE__ */ n("div", { className: "flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600", children: [
|
|
62
|
+
/* @__PURE__ */ e(ve, { className: "h-3 w-3" }),
|
|
63
|
+
/* @__PURE__ */ e("span", { className: "text-[11px] leading-tight", children: "Published" })
|
|
64
|
+
] }) : t === "unsaved" ? /* @__PURE__ */ n("div", { className: "flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600", children: [
|
|
65
|
+
/* @__PURE__ */ e(we, { className: "h-3 w-3" }),
|
|
66
|
+
/* @__PURE__ */ e("span", { className: "text-[11px] leading-tight", children: "Unsaved changes" })
|
|
67
|
+
] }) : /* @__PURE__ */ e("span", { className: "rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600", children: t });
|
|
68
|
+
function Oe({ compare: t, setCompare: s }) {
|
|
69
|
+
const { data: a } = q(), { saveState: i } = de(), [l] = le();
|
|
70
|
+
if (!a) return null;
|
|
71
|
+
const d = !!t.find((o) => {
|
|
72
|
+
var r;
|
|
73
|
+
return (r = o == null ? void 0 : o.uid) == null ? void 0 : r.startsWith("draft:");
|
|
74
|
+
}), u = t.length >= 2 && !d, m = i === "UNSAVED";
|
|
75
|
+
return /* @__PURE__ */ n("div", { className: "relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50", children: [
|
|
76
|
+
/* @__PURE__ */ n("div", { className: "flex-1 space-y-1", children: [
|
|
77
|
+
/* @__PURE__ */ e("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ n("div", { className: "flex items-center gap-1 text-sm font-medium leading-none", children: [
|
|
78
|
+
/* @__PURE__ */ e(N, { tag: "draft" }),
|
|
79
|
+
/* @__PURE__ */ e("span", { className: "text-xs font-bold", children: "Currently editing" })
|
|
80
|
+
] }) }),
|
|
81
|
+
/* @__PURE__ */ e("div", { className: "flex items-center pl-2 text-[11px] text-muted-foreground", children: !ge(l.lastSaved) && /* @__PURE__ */ n("span", { children: [
|
|
82
|
+
"Last updated",
|
|
83
|
+
" ",
|
|
84
|
+
xe(new Date(l.lastSaved), {
|
|
85
|
+
addSuffix: !0
|
|
86
|
+
})
|
|
87
|
+
] }) }),
|
|
88
|
+
/* @__PURE__ */ e("div", { className: "flex items-center gap-2 pt-0.5", children: m ? /* @__PURE__ */ e(N, { tag: "unsaved" }) : null })
|
|
89
|
+
] }),
|
|
90
|
+
/* @__PURE__ */ e(
|
|
91
|
+
K,
|
|
92
|
+
{
|
|
93
|
+
checked: d,
|
|
94
|
+
disabled: u,
|
|
95
|
+
onChange: () => {
|
|
96
|
+
s(d ? t.filter((o) => o.uid !== `draft:${a == null ? void 0 : a.id}`) : [
|
|
97
|
+
...t,
|
|
98
|
+
{ uid: `draft:${a == null ? void 0 : a.id}`, label: "draft", item: { createdAt: Date.now() } }
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
] });
|
|
104
|
+
}
|
|
105
|
+
function Me() {
|
|
106
|
+
return /* @__PURE__ */ e("div", { className: "mt-2 space-y-2", children: Array.from({ length: 5 }).map((t, s) => /* @__PURE__ */ n("div", { className: "flex items-start gap-3 rounded-md border p-2", children: [
|
|
107
|
+
/* @__PURE__ */ n("div", { className: "flex-1 space-y-1", children: [
|
|
108
|
+
/* @__PURE__ */ e(y, { className: "h-4 w-3/4" }),
|
|
109
|
+
/* @__PURE__ */ e(y, { className: "h-3 w-1/2" }),
|
|
110
|
+
/* @__PURE__ */ e(y, { className: "mt-1 h-5 w-20" })
|
|
111
|
+
] }),
|
|
112
|
+
/* @__PURE__ */ e(y, { className: "h-8 w-8 rounded-full" })
|
|
113
|
+
] }, s)) });
|
|
114
|
+
}
|
|
115
|
+
function V({
|
|
116
|
+
revision: t,
|
|
117
|
+
isLatest: s,
|
|
118
|
+
onRestore: a,
|
|
119
|
+
onDelete: i,
|
|
120
|
+
revisionNumber: l,
|
|
121
|
+
compare: d,
|
|
122
|
+
setCompare: u,
|
|
123
|
+
pageId: m
|
|
124
|
+
}) {
|
|
125
|
+
const { data: o } = I(t.currentEditor), r = (o == null ? void 0 : o.name) || "Unknown", f = !!d.find((h) => {
|
|
126
|
+
var x;
|
|
127
|
+
return s ? (x = h == null ? void 0 : h.uid) == null ? void 0 : x.startsWith("live") : (h == null ? void 0 : h.uid) === t.uid;
|
|
128
|
+
}), S = d.length >= 2 && !f;
|
|
129
|
+
return /* @__PURE__ */ n("div", { className: "relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50", children: [
|
|
130
|
+
/* @__PURE__ */ n("div", { className: "flex-1 space-y-3", children: [
|
|
131
|
+
/* @__PURE__ */ e("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ n("p", { className: "flex items-center gap-1 text-xs leading-none", children: [
|
|
132
|
+
/* @__PURE__ */ e(N, { tag: s ? "live" : `#${l}` }),
|
|
133
|
+
t.type === "published" ? "Published" : "Draft",
|
|
134
|
+
" by ",
|
|
135
|
+
/* @__PURE__ */ e("span", { className: "text-xs font-bold", children: r })
|
|
136
|
+
] }) }),
|
|
137
|
+
/* @__PURE__ */ n("div", { className: "flex items-center gap-x-3", children: [
|
|
138
|
+
/* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: t.type === "published" ? /* @__PURE__ */ e(N, { tag: "published" }) : /* @__PURE__ */ e(N, { tag: "draft" }) }),
|
|
139
|
+
/* @__PURE__ */ e("div", { className: "flex items-center text-[10px] text-muted-foreground", children: /* @__PURE__ */ e("span", { className: "leading-tight", children: D(t.createdAt, "MMM d, h:mm a") }) })
|
|
140
|
+
] })
|
|
141
|
+
] }),
|
|
142
|
+
/* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e(R, { permissions: [w.RESTORE_REVISION, w.DELETE_REVISION], children: /* @__PURE__ */ e(_e, { revision: t, onRestore: a, onDelete: i }) }) }),
|
|
143
|
+
/* @__PURE__ */ e(
|
|
144
|
+
K,
|
|
145
|
+
{
|
|
146
|
+
checked: f,
|
|
147
|
+
disabled: S,
|
|
148
|
+
onChange: () => {
|
|
149
|
+
u(
|
|
150
|
+
f ? d.filter((h) => s ? h.uid !== `live:${m}` : h.uid !== t.uid) : [
|
|
151
|
+
...d,
|
|
152
|
+
{
|
|
153
|
+
uid: s ? `live:${m}` : t.uid,
|
|
154
|
+
label: s ? "live" : `#${l}`,
|
|
155
|
+
item: t
|
|
156
|
+
}
|
|
157
|
+
].sort((h, x) => new Date(h.item.createdAt).getTime() - new Date(x.item.createdAt).getTime())
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
] });
|
|
163
|
+
}
|
|
164
|
+
function Te({ compare: t, setCompare: s, pageId: a }) {
|
|
165
|
+
const [i, l] = Ee(!1), [d, u] = t;
|
|
166
|
+
if (t.length === 0) return null;
|
|
167
|
+
const m = ({ tab: o }) => /* @__PURE__ */ n("span", { className: "flex items-center justify-between rounded border border-blue-100 p-1 font-medium", children: [
|
|
168
|
+
/* @__PURE__ */ e(N, { tag: o.label }),
|
|
169
|
+
/* @__PURE__ */ e(
|
|
170
|
+
"button",
|
|
171
|
+
{
|
|
172
|
+
className: "z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",
|
|
173
|
+
style: { lineHeight: 1 },
|
|
174
|
+
onClick: () => s(t.filter((r) => r.uid !== o.uid)),
|
|
175
|
+
"aria-label": "Remove selection 1",
|
|
176
|
+
children: /* @__PURE__ */ e(De, { className: "h-3 w-3" })
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
] });
|
|
180
|
+
return /* @__PURE__ */ n("div", { className: "mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm", children: [
|
|
181
|
+
/* @__PURE__ */ n("div", { className: "flex items-center gap-x-2 text-xs", children: [
|
|
182
|
+
/* @__PURE__ */ e("span", { className: "font-medium leading-tight text-gray-600", children: "Compare" }),
|
|
183
|
+
d && /* @__PURE__ */ e(m, { tab: d }),
|
|
184
|
+
/* @__PURE__ */ e("span", { className: "font-medium leading-tight text-gray-600", children: "with" }),
|
|
185
|
+
u ? /* @__PURE__ */ e(m, { tab: u }) : /* @__PURE__ */ e("span", { className: "rounded border px-1 text-xs text-muted-foreground", children: "Choose another" })
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2 pb-0.5 pt-2", children: [
|
|
188
|
+
/* @__PURE__ */ e(
|
|
189
|
+
g,
|
|
190
|
+
{
|
|
191
|
+
size: "sm",
|
|
192
|
+
className: "h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",
|
|
193
|
+
variant: "outline",
|
|
194
|
+
onClick: () => s([]),
|
|
195
|
+
children: /* @__PURE__ */ e("span", { children: " Clear" })
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
/* @__PURE__ */ n(
|
|
199
|
+
g,
|
|
200
|
+
{
|
|
201
|
+
size: "sm",
|
|
202
|
+
className: "h-6 gap-1 rounded px-2 text-xs leading-none",
|
|
203
|
+
variant: "default",
|
|
204
|
+
onClick: () => l(!0),
|
|
205
|
+
disabled: t.length < 2,
|
|
206
|
+
children: [
|
|
207
|
+
/* @__PURE__ */ e(Ne, { className: "h-2.5 w-2.5" }),
|
|
208
|
+
/* @__PURE__ */ e("span", { className: "pt-0.5", children: "Show JSON Diff" })
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
] }),
|
|
213
|
+
i && (t == null ? void 0 : t.length) > 1 && a && /* @__PURE__ */ e(
|
|
214
|
+
Re,
|
|
215
|
+
{
|
|
216
|
+
fallback: /* @__PURE__ */ e("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ e("span", { className: "text-sm", children: "Loading diff viewer..." }) }),
|
|
217
|
+
children: /* @__PURE__ */ e(ke, { open: i, onOpenChange: l, compare: t })
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
] });
|
|
221
|
+
}
|
|
222
|
+
function K({ checked: t, disabled: s, onChange: a, label: i = "Compare" }) {
|
|
223
|
+
return /* @__PURE__ */ e("div", { className: "absolute bottom-2 right-2", children: /* @__PURE__ */ n("label", { className: `flex cursor-pointer items-center gap-x-1 text-[11px] ${s ? "opacity-50" : ""}`, children: [
|
|
224
|
+
/* @__PURE__ */ e(
|
|
225
|
+
"input",
|
|
226
|
+
{
|
|
227
|
+
type: "checkbox",
|
|
228
|
+
className: "h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",
|
|
229
|
+
checked: t,
|
|
230
|
+
disabled: s,
|
|
231
|
+
onChange: a
|
|
232
|
+
}
|
|
233
|
+
),
|
|
234
|
+
/* @__PURE__ */ e("span", { className: "select-none leading-tight", children: i })
|
|
235
|
+
] }) });
|
|
236
|
+
}
|
|
237
|
+
function _e({ revision: t, onRestore: s, onDelete: a }) {
|
|
238
|
+
return /* @__PURE__ */ n(me, { children: [
|
|
239
|
+
/* @__PURE__ */ e(he, { asChild: !0, children: /* @__PURE__ */ n(g, { variant: "ghost", size: "icon", className: "h-5 w-5", children: [
|
|
240
|
+
/* @__PURE__ */ e(be, { className: "h-4 w-4" }),
|
|
241
|
+
/* @__PURE__ */ e("span", { className: "sr-only", children: "More options" })
|
|
242
|
+
] }) }),
|
|
243
|
+
/* @__PURE__ */ n(fe, { align: "end", className: "text-xs", children: [
|
|
244
|
+
/* @__PURE__ */ e(R, { permission: w.RESTORE_REVISION, children: /* @__PURE__ */ n(U, { onClick: s, className: "cursor-pointer text-sm", children: [
|
|
245
|
+
/* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
|
|
246
|
+
/* @__PURE__ */ e("span", { children: "Restore this version" })
|
|
247
|
+
] }) }),
|
|
248
|
+
/* @__PURE__ */ e(R, { permission: w.DELETE_REVISION, children: t.uid !== "current" && /* @__PURE__ */ n(p, { children: [
|
|
249
|
+
/* @__PURE__ */ e(pe, {}),
|
|
250
|
+
/* @__PURE__ */ n(U, { onClick: a, className: "cursor-pointer text-destructive", children: [
|
|
251
|
+
/* @__PURE__ */ e(Q, { className: "mr-2 h-4 w-4" }),
|
|
252
|
+
/* @__PURE__ */ e("span", { children: "Delete this version" })
|
|
253
|
+
] })
|
|
254
|
+
] }) })
|
|
255
|
+
] })
|
|
256
|
+
] });
|
|
257
|
+
}
|
|
258
|
+
function Ue({
|
|
259
|
+
open: t,
|
|
260
|
+
onOpenChange: s,
|
|
261
|
+
revision: a,
|
|
262
|
+
onRestore: i,
|
|
263
|
+
isRestoring: l
|
|
264
|
+
}) {
|
|
265
|
+
const { data: d } = I((a == null ? void 0 : a.currentEditor) || ""), u = (d == null ? void 0 : d.name) || "Unknown";
|
|
266
|
+
return a ? /* @__PURE__ */ e(
|
|
267
|
+
j,
|
|
268
|
+
{
|
|
269
|
+
open: t,
|
|
270
|
+
onOpenChange: (m) => {
|
|
271
|
+
l || s(m);
|
|
272
|
+
},
|
|
273
|
+
children: /* @__PURE__ */ n(L, { className: "sm:max-w-md", children: [
|
|
274
|
+
/* @__PURE__ */ n(P, { children: [
|
|
275
|
+
/* @__PURE__ */ e($, { children: "Restore Revision" }),
|
|
276
|
+
/* @__PURE__ */ n(z, { children: [
|
|
277
|
+
"You are about to restore to revision ",
|
|
278
|
+
a.uid.substring(0, 8),
|
|
279
|
+
" from",
|
|
280
|
+
" ",
|
|
281
|
+
D(a.createdAt, "MMM d, yyyy 'at' h:mm a"),
|
|
282
|
+
" by ",
|
|
283
|
+
u
|
|
284
|
+
] })
|
|
285
|
+
] }),
|
|
286
|
+
/* @__PURE__ */ e("div", { className: "py-2", children: /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "How would you like to handle your current edits?" }) }),
|
|
287
|
+
/* @__PURE__ */ n(H, { className: "flex flex-col gap-2 sm:flex-row", children: [
|
|
288
|
+
/* @__PURE__ */ e(g, { variant: "outline", className: "sm:flex-1", onClick: () => i(!1), disabled: l, children: l ? /* @__PURE__ */ n(p, { children: [
|
|
289
|
+
/* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
290
|
+
"Saving as draft..."
|
|
291
|
+
] }) : /* @__PURE__ */ n(p, { children: [
|
|
292
|
+
/* @__PURE__ */ e(ye, { className: "mr-2 h-4 w-4" }),
|
|
293
|
+
"Save as draft"
|
|
294
|
+
] }) }),
|
|
295
|
+
/* @__PURE__ */ e(g, { variant: "default", className: "sm:flex-1", onClick: () => i(!0), disabled: l, children: l ? /* @__PURE__ */ n(p, { children: [
|
|
296
|
+
/* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
297
|
+
"Discarding current..."
|
|
298
|
+
] }) : /* @__PURE__ */ n(p, { children: [
|
|
299
|
+
/* @__PURE__ */ e(J, { className: "mr-2 h-4 w-4" }),
|
|
300
|
+
"Discard current"
|
|
301
|
+
] }) })
|
|
302
|
+
] })
|
|
303
|
+
] })
|
|
304
|
+
}
|
|
305
|
+
) : null;
|
|
306
|
+
}
|
|
307
|
+
function Fe({
|
|
308
|
+
open: t,
|
|
309
|
+
onOpenChange: s,
|
|
310
|
+
revision: a,
|
|
311
|
+
onDelete: i,
|
|
312
|
+
isDeleting: l
|
|
313
|
+
}) {
|
|
314
|
+
const { data: d } = I((a == null ? void 0 : a.currentEditor) || ""), u = (d == null ? void 0 : d.name) || "Unknown";
|
|
315
|
+
return a ? /* @__PURE__ */ e(
|
|
316
|
+
j,
|
|
317
|
+
{
|
|
318
|
+
open: t,
|
|
319
|
+
onOpenChange: (m) => {
|
|
320
|
+
l || s(m);
|
|
321
|
+
},
|
|
322
|
+
children: /* @__PURE__ */ n(L, { className: "sm:max-w-md", children: [
|
|
323
|
+
/* @__PURE__ */ n(P, { children: [
|
|
324
|
+
/* @__PURE__ */ e($, { children: "Delete Revision" }),
|
|
325
|
+
/* @__PURE__ */ n(z, { children: [
|
|
326
|
+
"You are about to delete revision ",
|
|
327
|
+
a.uid.substring(0, 8),
|
|
328
|
+
" from",
|
|
329
|
+
" ",
|
|
330
|
+
D(a.createdAt, "MMM d, yyyy 'at' h:mm a"),
|
|
331
|
+
" by ",
|
|
332
|
+
u
|
|
333
|
+
] })
|
|
334
|
+
] }),
|
|
335
|
+
/* @__PURE__ */ e("div", { className: "py-2", children: /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "This action cannot be undone. Are you sure you want to proceed?" }) }),
|
|
336
|
+
/* @__PURE__ */ n(H, { className: "flex flex-col gap-2 sm:flex-row", children: [
|
|
337
|
+
/* @__PURE__ */ e(g, { variant: "outline", className: "sm:flex-1", onClick: () => s(!1), disabled: l, children: "Cancel" }),
|
|
338
|
+
/* @__PURE__ */ e(g, { variant: "destructive", className: "sm:flex-1", onClick: i, disabled: l, children: l ? /* @__PURE__ */ n(p, { children: [
|
|
339
|
+
/* @__PURE__ */ e("span", { className: "mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" }),
|
|
340
|
+
"Deleting..."
|
|
341
|
+
] }) : /* @__PURE__ */ n(p, { children: [
|
|
342
|
+
/* @__PURE__ */ e(Q, { className: "mr-2 h-4 w-4" }),
|
|
343
|
+
"Delete Revision"
|
|
344
|
+
] }) })
|
|
345
|
+
] })
|
|
346
|
+
] })
|
|
347
|
+
}
|
|
348
|
+
) : null;
|
|
349
|
+
}
|
|
350
|
+
function Je({ isOpen: t }) {
|
|
351
|
+
var T, _;
|
|
352
|
+
const [s, a] = v.useState([]), [i, l] = v.useState(null), [d, u] = v.useState(!1), [m, o] = v.useState(!1), { data: r } = q(), { data: f, isFetching: S, error: h, refetch: x } = Ce(r == null ? void 0 : r.id), { mutate: W, isPending: Y } = Ae(), { mutate: B, isPending: X } = Ie(), Z = k(), { selectedLang: ee, fallbackLang: te } = ie(), ne = ee || te;
|
|
353
|
+
F(() => a([]), [r == null ? void 0 : r.id]);
|
|
354
|
+
const ae = (c) => {
|
|
355
|
+
i && B(
|
|
356
|
+
{ revisionId: i.uid, discardCurrent: c },
|
|
357
|
+
{
|
|
358
|
+
onSuccess: () => {
|
|
359
|
+
u(!1), l(null), Z.invalidateQueries({
|
|
360
|
+
queryKey: [b.GET_DRAFT_PAGE]
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
);
|
|
365
|
+
}, O = (c) => {
|
|
366
|
+
l(c), u(!0);
|
|
367
|
+
}, M = (c) => {
|
|
368
|
+
l(c), o(!0);
|
|
369
|
+
}, se = () => {
|
|
370
|
+
i && W(i.uid, {
|
|
371
|
+
/**
|
|
372
|
+
* Callback for when deletion of a revision is successful. Closes the
|
|
373
|
+
* delete dialog and resets the selected revision to null.
|
|
374
|
+
*/
|
|
375
|
+
onSuccess: () => {
|
|
376
|
+
o(!1), l(null);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
};
|
|
380
|
+
return F(() => {
|
|
381
|
+
t && x();
|
|
382
|
+
}, [t, x]), /* @__PURE__ */ n(p, { children: [
|
|
383
|
+
/* @__PURE__ */ n(ce, { children: [
|
|
384
|
+
/* @__PURE__ */ e(oe, { children: "Revision History" }),
|
|
385
|
+
(r == null ? void 0 : r.createdAt) && /* @__PURE__ */ n("p", { className: "mt-1 text-xs text-muted-foreground", children: [
|
|
386
|
+
"Page created on ",
|
|
387
|
+
D(new Date(r.createdAt), "MMM d, yyyy 'at' h:mm a")
|
|
388
|
+
] })
|
|
389
|
+
] }),
|
|
390
|
+
S ? /* @__PURE__ */ e(Me, {}) : h ? /* @__PURE__ */ e("div", { className: "p-4 text-center text-sm text-muted-foreground", children: "Failed to load revisions. Please try again." }) : /* @__PURE__ */ n("div", { className: "mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2", children: [
|
|
391
|
+
/* @__PURE__ */ e(Te, { lang: ne, compare: s, setCompare: a, pageId: r == null ? void 0 : r.id }),
|
|
392
|
+
/* @__PURE__ */ e(Oe, { compare: s, setCompare: a }),
|
|
393
|
+
(T = f == null ? void 0 : f.filter((c) => c.uid === "current")) == null ? void 0 : T.map((c, E) => /* @__PURE__ */ e(
|
|
394
|
+
V,
|
|
395
|
+
{
|
|
396
|
+
pageId: r == null ? void 0 : r.id,
|
|
397
|
+
revision: c,
|
|
398
|
+
isLatest: !0,
|
|
399
|
+
onRestore: () => O(c),
|
|
400
|
+
onDelete: () => M(c),
|
|
401
|
+
revisionNumber: E,
|
|
402
|
+
compare: s,
|
|
403
|
+
setCompare: a
|
|
404
|
+
},
|
|
405
|
+
c.uid
|
|
406
|
+
)),
|
|
407
|
+
/* @__PURE__ */ e(ue, { className: "min-h-0 flex-1", children: /* @__PURE__ */ e("div", { className: "space-y-2", children: (_ = f == null ? void 0 : f.filter((c) => c.uid !== "current")) == null ? void 0 : _.map((c, E) => /* @__PURE__ */ e(
|
|
408
|
+
V,
|
|
409
|
+
{
|
|
410
|
+
pageId: r == null ? void 0 : r.id,
|
|
411
|
+
revision: c,
|
|
412
|
+
isLatest: c.uid === "current",
|
|
413
|
+
onRestore: () => O(c),
|
|
414
|
+
onDelete: () => M(c),
|
|
415
|
+
revisionNumber: E + 1,
|
|
416
|
+
compare: s,
|
|
417
|
+
setCompare: a
|
|
418
|
+
},
|
|
419
|
+
c.uid
|
|
420
|
+
)) }) })
|
|
421
|
+
] }),
|
|
422
|
+
/* @__PURE__ */ e(
|
|
423
|
+
Ue,
|
|
424
|
+
{
|
|
425
|
+
open: d,
|
|
426
|
+
onOpenChange: u,
|
|
427
|
+
revision: i,
|
|
428
|
+
onRestore: ae,
|
|
429
|
+
isRestoring: X
|
|
430
|
+
}
|
|
431
|
+
),
|
|
432
|
+
/* @__PURE__ */ e(
|
|
433
|
+
Fe,
|
|
434
|
+
{
|
|
435
|
+
open: m,
|
|
436
|
+
onOpenChange: o,
|
|
437
|
+
revision: i,
|
|
438
|
+
onDelete: se,
|
|
439
|
+
isDeleting: Y
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
] });
|
|
443
|
+
}
|
|
444
|
+
export {
|
|
445
|
+
Je as default
|
|
446
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { jsxs as n, jsx as t, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import { LanguageSelector as z } from "./page-manager-search-and-filter-B4xo9IJO.js";
|
|
3
|
+
import { ak as R, al as _, A as L, ay as $, f as K, h as Q, aq as J, T as A, t as V } from "./index-Byi6-4u1.js";
|
|
4
|
+
import { useQuery as W } from "@tanstack/react-query";
|
|
5
|
+
import { DialogContent as X, DialogHeader as Y, DialogTitle as Z, DialogDescription as ee, DialogFooter as te, Button as F } from "@chaibuilder/sdk/ui";
|
|
6
|
+
import { find as G, filter as a, map as y, includes as P, orderBy as b, isEmpty as se, first as le, uniq as U, concat as ne } from "lodash-es";
|
|
7
|
+
import { Lock as ae, GlobeIcon as re, File as ce, Edit as oe } from "lucide-react";
|
|
8
|
+
import { useState as O, useCallback as ie, useMemo as g, useEffect as j } from "react";
|
|
9
|
+
const de = () => {
|
|
10
|
+
const s = R(), d = _();
|
|
11
|
+
return W({
|
|
12
|
+
queryKey: [L.GET_CHANGES],
|
|
13
|
+
queryFn: async () => d(s, { action: L.GET_CHANGES })
|
|
14
|
+
});
|
|
15
|
+
}, ue = ({ page: s, selectedPages: d, handleCheckboxChange: N, getPageType: h, hasSlug: o, currentOwnerId: u }) => {
|
|
16
|
+
const { data: i } = J(u), r = i == null ? void 0 : i.name;
|
|
17
|
+
return /* @__PURE__ */ n("tr", { className: "group relative border-b last:border-b-0 hover:bg-gray-50", children: [
|
|
18
|
+
/* @__PURE__ */ n(
|
|
19
|
+
"td",
|
|
20
|
+
{
|
|
21
|
+
scope: "row",
|
|
22
|
+
className: `flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${r ? "opacity-50" : ""}`,
|
|
23
|
+
children: [
|
|
24
|
+
r ? /* @__PURE__ */ t(ae, { className: "h-4 w-4 fill-red-200 text-red-500" }) : /* @__PURE__ */ t(
|
|
25
|
+
"input",
|
|
26
|
+
{
|
|
27
|
+
checked: P(d, s == null ? void 0 : s.id),
|
|
28
|
+
onClick: (x) => {
|
|
29
|
+
x.stopPropagation(), N(s == null ? void 0 : s.id);
|
|
30
|
+
},
|
|
31
|
+
type: "checkbox",
|
|
32
|
+
className: "cursor-pointer rounded focus:outline-none focus:ring-0"
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
" ",
|
|
36
|
+
o(s.pageType) ? /* @__PURE__ */ t(ce, { className: "h-4 w-4" }) : /* @__PURE__ */ t(re, { className: "h-4 w-4" }),
|
|
37
|
+
/* @__PURE__ */ t(A, { content: s.name, side: "top", showTooltip: s.name.length > 25, children: /* @__PURE__ */ t("span", { className: "max-w-[200px] truncate font-medium text-black", children: s.name }) }),
|
|
38
|
+
s.slug && /* @__PURE__ */ t(A, { content: s.slug, side: "top", showTooltip: s.slug.length > 25, children: /* @__PURE__ */ t("span", { className: "max-w-[200px] truncate font-mono text-xs text-muted-foreground", children: s.slug }) })
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ t("td", { className: "px-2", children: h(s == null ? void 0 : s.pageType) }),
|
|
43
|
+
/* @__PURE__ */ t("td", { className: "px-4 text-right", children: le(s.changes) || "" }),
|
|
44
|
+
/* @__PURE__ */ t(H, { children: r && /* @__PURE__ */ n("button", { className: "absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100", children: [
|
|
45
|
+
/* @__PURE__ */ t(oe, { size: 12, className: "stroke-[3]" }),
|
|
46
|
+
" ",
|
|
47
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: r }),
|
|
48
|
+
" is editing this page"
|
|
49
|
+
] }) })
|
|
50
|
+
] }, s == null ? void 0 : s.id);
|
|
51
|
+
}, ke = ({
|
|
52
|
+
onClose: s = () => {
|
|
53
|
+
},
|
|
54
|
+
isPending: d,
|
|
55
|
+
publishPage: N
|
|
56
|
+
}) => {
|
|
57
|
+
const [h] = $(), [o, u] = O([]), i = K(), [r, x] = O(i), { data: k, isFetching: C } = de(), { data: m } = Q(), w = ie((e) => {
|
|
58
|
+
var l;
|
|
59
|
+
return (l = G(m, { key: e })) == null ? void 0 : l.hasSlug;
|
|
60
|
+
}, [m]), f = g(
|
|
61
|
+
() => a(m, (e) => !w(e.key)).map((e) => e.key),
|
|
62
|
+
[w, m]
|
|
63
|
+
), v = U(y(k, "lang")).filter(Boolean), c = g(
|
|
64
|
+
() => a(k, (e) => e.pageType === "theme" ? !1 : r === i ? e.lang === r || e.lang === "" : e.lang === r),
|
|
65
|
+
[k, r, i]
|
|
66
|
+
), T = g(
|
|
67
|
+
() => a(c, (e) => !f.includes(e.pageType)),
|
|
68
|
+
[c, f]
|
|
69
|
+
), S = g(
|
|
70
|
+
() => a(c, (e) => f.includes(e.pageType)),
|
|
71
|
+
[c, f]
|
|
72
|
+
);
|
|
73
|
+
j(() => {
|
|
74
|
+
const e = y(a(c, { online: !0 }), "id");
|
|
75
|
+
u(e);
|
|
76
|
+
}, [c]), j(() => {
|
|
77
|
+
const e = Object.keys(h);
|
|
78
|
+
u((l) => a(l, (p) => !P(e, p)));
|
|
79
|
+
}, [h]);
|
|
80
|
+
const E = o.length === (c == null ? void 0 : c.length), B = (e) => {
|
|
81
|
+
u((l) => P(l, e) ? a(l, (p) => p !== e) : ne(l, e));
|
|
82
|
+
}, D = () => {
|
|
83
|
+
u(E ? [] : y(c, "id"));
|
|
84
|
+
}, q = () => {
|
|
85
|
+
N(
|
|
86
|
+
{ ids: U(o) },
|
|
87
|
+
{
|
|
88
|
+
onSuccess: () => {
|
|
89
|
+
s(), V("CENTER_CENTER"), x(i);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}, I = (e) => {
|
|
94
|
+
if (e === "theme") return "Theme";
|
|
95
|
+
const l = G(m, { key: e });
|
|
96
|
+
return l ? l == null ? void 0 : l.name : e;
|
|
97
|
+
}, M = g(() => {
|
|
98
|
+
const e = [
|
|
99
|
+
{ label: "Updated", top: "pt-2" },
|
|
100
|
+
...b(a(T, { online: !0 }), "pageType"),
|
|
101
|
+
...b(a(S, { online: !0 }), "pageType")
|
|
102
|
+
].filter((p) => p.pageType !== "theme"), l = [
|
|
103
|
+
{ label: "Offline", top: "pt-6" },
|
|
104
|
+
...b(a(T, { online: !1 }), "pageType"),
|
|
105
|
+
...b(a(S, { online: !1 }), "pageType")
|
|
106
|
+
];
|
|
107
|
+
return [...e, ...l];
|
|
108
|
+
}, [T, S]);
|
|
109
|
+
return /* @__PURE__ */ n(X, { className: "flex max-h-[80%] max-w-4xl flex-col", children: [
|
|
110
|
+
/* @__PURE__ */ n(Y, { children: [
|
|
111
|
+
/* @__PURE__ */ t(Z, { children: "Publish changes" }),
|
|
112
|
+
/* @__PURE__ */ t(ee, { className: "text-xs", children: "Select the pages you want to publish. Click publish when you're done." })
|
|
113
|
+
] }),
|
|
114
|
+
v.length > 0 && /* @__PURE__ */ t("div", { className: "my-[2px] mt-0", children: /* @__PURE__ */ t(
|
|
115
|
+
z,
|
|
116
|
+
{
|
|
117
|
+
languages: [i, ...v],
|
|
118
|
+
selectedLanguage: r,
|
|
119
|
+
setSelectedLanguage: x
|
|
120
|
+
}
|
|
121
|
+
) }),
|
|
122
|
+
/* @__PURE__ */ t("div", { className: "no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto", children: C ? /* @__PURE__ */ n("div", { className: "space-y-2 px-1", children: [
|
|
123
|
+
/* @__PURE__ */ t("div", { className: "mt-2 h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
124
|
+
/* @__PURE__ */ t("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
125
|
+
/* @__PURE__ */ t("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
126
|
+
/* @__PURE__ */ t("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
127
|
+
] }) : /* @__PURE__ */ n("table", { className: "w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right", children: [
|
|
128
|
+
/* @__PURE__ */ t("thead", { className: "sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400", children: /* @__PURE__ */ n("tr", { children: [
|
|
129
|
+
/* @__PURE__ */ n("th", { scope: "col", className: "w-[1 50px] flex items-center gap-x-2 px-6 py-3", children: [
|
|
130
|
+
/* @__PURE__ */ t(
|
|
131
|
+
"input",
|
|
132
|
+
{
|
|
133
|
+
checked: E,
|
|
134
|
+
onClick: (e) => {
|
|
135
|
+
e.stopPropagation(), D();
|
|
136
|
+
},
|
|
137
|
+
type: "checkbox",
|
|
138
|
+
className: "mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
"Name"
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ t("th", { scope: "col", className: "w-[150px] px-2 py-3", children: "Type" }),
|
|
144
|
+
/* @__PURE__ */ t("th", { scope: "col", className: "w-[150px] px-4 py-3 text-right", children: "Status" })
|
|
145
|
+
] }) }),
|
|
146
|
+
/* @__PURE__ */ t("tbody", { children: y(
|
|
147
|
+
M,
|
|
148
|
+
(e) => e.label ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ n("td", { colSpan: 3, className: `relative px-6 py-2 text-xs font-medium text-gray-800 ${e.top}`, children: [
|
|
149
|
+
/* @__PURE__ */ t("div", { className: "absolute inset-0 left-6 flex items-center", children: /* @__PURE__ */ t("div", { className: "order-gray-300 w-full" }) }),
|
|
150
|
+
/* @__PURE__ */ t("div", { className: "relative flex justify-start", children: /* @__PURE__ */ t("span", { className: "bg-gray-50 pr-2", children: e.label }) })
|
|
151
|
+
] }) }, "separator") : /* @__PURE__ */ t(
|
|
152
|
+
ue,
|
|
153
|
+
{
|
|
154
|
+
page: e,
|
|
155
|
+
selectedPages: o,
|
|
156
|
+
handleCheckboxChange: B,
|
|
157
|
+
getPageType: I,
|
|
158
|
+
hasSlug: w,
|
|
159
|
+
currentOwnerId: h[(e == null ? void 0 : e.primaryPage) || (e == null ? void 0 : e.id)]
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
) })
|
|
163
|
+
] }) }),
|
|
164
|
+
/* @__PURE__ */ n(te, { className: "mt-10 flex items-center justify-center", children: [
|
|
165
|
+
o.length > 0 && /* @__PURE__ */ n("span", { className: "text-center text-sm text-muted-foreground", children: [
|
|
166
|
+
o.length,
|
|
167
|
+
" Page",
|
|
168
|
+
o.length !== 1 ? "s" : "",
|
|
169
|
+
" Selected"
|
|
170
|
+
] }),
|
|
171
|
+
/* @__PURE__ */ t(F, { disabled: d, variant: "outline", onClick: s, children: "Cancel" }),
|
|
172
|
+
/* @__PURE__ */ t(F, { disabled: d || C || se(o), onClick: q, children: d ? "Publishing..." : "Publish Selected" })
|
|
173
|
+
] })
|
|
174
|
+
] });
|
|
175
|
+
};
|
|
176
|
+
export {
|
|
177
|
+
ke as default
|
|
178
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),B=require("./page-manager-search-and-filter-DT9V9AoS.cjs"),r=require("./index-DSUpSpeI.cjs"),L=require("@tanstack/react-query"),h=require("@chaibuilder/sdk/ui"),t=require("lodash-es"),j=require("lucide-react"),i=require("react"),F=()=>{const l=r.useApiUrl(),u=r.useFetch();return L.useQuery({queryKey:[r.ACTIONS.GET_CHANGES],queryFn:async()=>u(l,{action:r.ACTIONS.GET_CHANGES})})},O=({page:l,selectedPages:u,handleCheckboxChange:b,getPageType:m,hasSlug:o,currentOwnerId:x})=>{const{data:d}=r.useChaiUserInfo(x),a=d==null?void 0:d.name;return e.jsxs("tr",{className:"group relative border-b last:border-b-0 hover:bg-gray-50",children:[e.jsxs("td",{scope:"row",className:`flex items-center gap-x-1 whitespace-nowrap px-6 py-2 text-gray-900 dark:text-white ${a?"opacity-50":""}`,children:[a?e.jsx(j.Lock,{className:"h-4 w-4 fill-red-200 text-red-500"}):e.jsx("input",{checked:t.includes(u,l==null?void 0:l.id),onClick:p=>{p.stopPropagation(),b(l==null?void 0:l.id)},type:"checkbox",className:"cursor-pointer rounded focus:outline-none focus:ring-0"})," ",o(l.pageType)?e.jsx(j.File,{className:"h-4 w-4"}):e.jsx(j.GlobeIcon,{className:"h-4 w-4"}),e.jsx(r.Tooltip,{content:l.name,side:"top",showTooltip:l.name.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-medium text-black",children:l.name})}),l.slug&&e.jsx(r.Tooltip,{content:l.slug,side:"top",showTooltip:l.slug.length>25,children:e.jsx("span",{className:"max-w-[200px] truncate font-mono text-xs text-muted-foreground",children:l.slug})})]}),e.jsx("td",{className:"px-2",children:m(l==null?void 0:l.pageType)}),e.jsx("td",{className:"px-4 text-right",children:t.first(l.changes)||""}),e.jsx(e.Fragment,{children:a&&e.jsxs("button",{className:"absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100",children:[e.jsx(j.Edit,{size:12,className:"stroke-[3]"})," ",e.jsx("span",{className:"font-medium",children:a})," is editing this page"]})})]},l==null?void 0:l.id)},G=({onClose:l=()=>{},isPending:u,publishPage:b})=>{const[m]=r.usePageUserMapping(),[o,x]=i.useState([]),d=r.useFallbackLang(),[a,p]=i.useState(d),{data:N,isFetching:T}=F(),{data:g}=r.usePageTypes(),k=i.useCallback(s=>{var n;return(n=t.find(g,{key:s}))==null?void 0:n.hasSlug},[g]),y=i.useMemo(()=>t.filter(g,s=>!k(s.key)).map(s=>s.key),[k,g]),P=t.uniq(t.map(N,"lang")).filter(Boolean),c=i.useMemo(()=>t.filter(N,s=>s.pageType==="theme"?!1:a===d?s.lang===a||s.lang==="":s.lang===a),[N,a,d]),w=i.useMemo(()=>t.filter(c,s=>!y.includes(s.pageType)),[c,y]),S=i.useMemo(()=>t.filter(c,s=>y.includes(s.pageType)),[c,y]);i.useEffect(()=>{const s=t.map(t.filter(c,{online:!0}),"id");x(s)},[c]),i.useEffect(()=>{const s=Object.keys(m);x(n=>t.filter(n,f=>!t.includes(s,f)))},[m]);const C=o.length===(c==null?void 0:c.length),v=s=>{x(n=>t.includes(n,s)?t.filter(n,f=>f!==s):t.concat(n,s))},E=()=>{x(C?[]:t.map(c,"id"))},q=()=>{b({ids:t.uniq(o)},{onSuccess:()=>{l(),r.throwConfetti("CENTER_CENTER"),p(d)}})},M=s=>{if(s==="theme")return"Theme";const n=t.find(g,{key:s});return n?n==null?void 0:n.name:s},A=i.useMemo(()=>{const s=[{label:"Updated",top:"pt-2"},...t.orderBy(t.filter(w,{online:!0}),"pageType"),...t.orderBy(t.filter(S,{online:!0}),"pageType")].filter(f=>f.pageType!=="theme"),n=[{label:"Offline",top:"pt-6"},...t.orderBy(t.filter(w,{online:!1}),"pageType"),...t.orderBy(t.filter(S,{online:!1}),"pageType")];return[...s,...n]},[w,S]);return e.jsxs(h.DialogContent,{className:"flex max-h-[80%] max-w-4xl flex-col",children:[e.jsxs(h.DialogHeader,{children:[e.jsx(h.DialogTitle,{children:"Publish changes"}),e.jsx(h.DialogDescription,{className:"text-xs",children:"Select the pages you want to publish. Click publish when you're done."})]}),P.length>0&&e.jsx("div",{className:"my-[2px] mt-0",children:e.jsx(B.LanguageSelector,{languages:[d,...P],selectedLanguage:a,setSelectedLanguage:p})}),e.jsx("div",{className:"no-scrollbar relative -mx-4 -mt-4 h-full max-h-full overflow-y-auto",children:T?e.jsxs("div",{className:"space-y-2 px-1",children:[e.jsx("div",{className:"mt-2 h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-6 w-full animate-pulse rounded bg-gray-200"})]}):e.jsxs("table",{className:"w-full text-left text-xs text-gray-500 dark:text-gray-400 rtl:text-right",children:[e.jsx("thead",{className:"sticky top-0 z-10 border-b bg-gray-50 text-gray-700 dark:bg-gray-700 dark:text-gray-400",children:e.jsxs("tr",{children:[e.jsxs("th",{scope:"col",className:"w-[1 50px] flex items-center gap-x-2 px-6 py-3",children:[e.jsx("input",{checked:C,onClick:s=>{s.stopPropagation(),E()},type:"checkbox",className:"mt-1 cursor-pointer rounded focus:outline-none focus:ring-0"}),"Name"]}),e.jsx("th",{scope:"col",className:"w-[150px] px-2 py-3",children:"Type"}),e.jsx("th",{scope:"col",className:"w-[150px] px-4 py-3 text-right",children:"Status"})]})}),e.jsx("tbody",{children:t.map(A,s=>s.label?e.jsx("tr",{children:e.jsxs("td",{colSpan:3,className:`relative px-6 py-2 text-xs font-medium text-gray-800 ${s.top}`,children:[e.jsx("div",{className:"absolute inset-0 left-6 flex items-center",children:e.jsx("div",{className:"order-gray-300 w-full"})}),e.jsx("div",{className:"relative flex justify-start",children:e.jsx("span",{className:"bg-gray-50 pr-2",children:s.label})})]})},"separator"):e.jsx(O,{page:s,selectedPages:o,handleCheckboxChange:v,getPageType:M,hasSlug:k,currentOwnerId:m[(s==null?void 0:s.primaryPage)||(s==null?void 0:s.id)]}))})]})}),e.jsxs(h.DialogFooter,{className:"mt-10 flex items-center justify-center",children:[o.length>0&&e.jsxs("span",{className:"text-center text-sm text-muted-foreground",children:[o.length," Page",o.length!==1?"s":""," Selected"]}),e.jsx(h.Button,{disabled:u,variant:"outline",onClick:l,children:"Cancel"}),e.jsx(h.Button,{disabled:u||T||t.isEmpty(o),onClick:q,children:u?"Publishing...":"Publish Selected"})]})]})};exports.default=G;
|