@openrails/contentkit-ui 0.71.0 → 0.72.0
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/README.md +98 -10
- package/dist/client/content/bans.d.ts +2 -0
- package/dist/client/content/bans.js +24 -12
- package/dist/client/content/bans.js.map +1 -1
- package/dist/client/content/comments.d.ts +2 -0
- package/dist/client/content/comments.js.map +1 -1
- package/dist/client/content/polls.d.ts +9 -2
- package/dist/client/content/polls.js.map +1 -1
- package/dist/client/generated/routes.d.ts +28 -2
- package/dist/client/generated/routes.js +40 -0
- package/dist/client/generated/routes.js.map +1 -1
- package/dist/client/generated/wire.d.ts +4 -0
- package/dist/client/generated/wire.js.map +1 -1
- package/dist/client/index.d.ts +2 -2
- package/dist/client/taxonomy.d.ts +5 -1
- package/dist/client/taxonomy.js +7 -0
- package/dist/client/taxonomy.js.map +1 -1
- package/dist/components/admin/poll-manager.d.ts +28 -0
- package/dist/components/admin/poll-manager.js +297 -0
- package/dist/components/admin/poll-manager.js.map +1 -0
- package/dist/components/admin/post-manager.d.ts +45 -0
- package/dist/components/admin/post-manager.js +602 -0
- package/dist/components/admin/post-manager.js.map +1 -0
- package/dist/components/admin/shell.d.ts +73 -0
- package/dist/components/admin/shell.js +148 -0
- package/dist/components/admin/shell.js.map +1 -0
- package/dist/components/admin/taxonomy-manager.d.ts +54 -0
- package/dist/components/admin/taxonomy-manager.js +976 -0
- package/dist/components/admin/taxonomy-manager.js.map +1 -0
- package/dist/components/admin/user-comment-standing.d.ts +25 -0
- package/dist/components/admin/user-comment-standing.js +229 -0
- package/dist/components/admin/user-comment-standing.js.map +1 -0
- package/dist/components/social/bans.d.ts +5 -2
- package/dist/components/social/bans.js +132 -134
- package/dist/components/social/bans.js.map +1 -1
- package/dist/components/social/index.d.ts +1 -1
- package/dist/components/social/moderation.d.ts +11 -13
- package/dist/components/social/moderation.js +299 -218
- package/dist/components/social/moderation.js.map +1 -1
- package/dist/components/social/parts.d.ts +3 -2
- package/dist/components/social/parts.js +74 -48
- package/dist/components/social/parts.js.map +1 -1
- package/dist/components/social/poll-editor.js +1 -0
- package/dist/components/social/poll-editor.js.map +1 -1
- package/dist/editor/index.d.ts +1 -0
- package/dist/editor/rich-text-editor.d.ts +13 -0
- package/dist/editor/rich-text-editor.js +228 -0
- package/dist/editor/rich-text-editor.js.map +1 -0
- package/dist/editor.js +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +13 -8
- package/dist/locales/admin/de.d.ts +2 -0
- package/dist/locales/admin/de.js +176 -0
- package/dist/locales/admin/de.js.map +1 -0
- package/dist/locales/admin/en.d.ts +171 -0
- package/dist/locales/admin/en.js +176 -0
- package/dist/locales/admin/en.js.map +1 -0
- package/dist/locales/admin/es.d.ts +2 -0
- package/dist/locales/admin/es.js +176 -0
- package/dist/locales/admin/es.js.map +1 -0
- package/dist/locales/admin/ja.d.ts +2 -0
- package/dist/locales/admin/ja.js +176 -0
- package/dist/locales/admin/ja.js.map +1 -0
- package/dist/locales/admin/ko.d.ts +2 -0
- package/dist/locales/admin/ko.js +176 -0
- package/dist/locales/admin/ko.js.map +1 -0
- package/dist/locales/admin/zh.d.ts +2 -0
- package/dist/locales/admin/zh.js +176 -0
- package/dist/locales/admin/zh.js.map +1 -0
- package/dist/locales/de.js +5 -3
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/en.d.ts +176 -0
- package/dist/locales/en.js +5 -3
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/es.js +5 -3
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/ja.js +5 -3
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/ko.js +5 -3
- package/dist/locales/ko.js.map +1 -1
- package/dist/locales/social/de.js +8 -1
- package/dist/locales/social/de.js.map +1 -1
- package/dist/locales/social/en.d.ts +7 -0
- package/dist/locales/social/en.js +8 -1
- package/dist/locales/social/en.js.map +1 -1
- package/dist/locales/social/es.js +8 -1
- package/dist/locales/social/es.js.map +1 -1
- package/dist/locales/social/ja.js +8 -1
- package/dist/locales/social/ja.js.map +1 -1
- package/dist/locales/social/ko.js +8 -1
- package/dist/locales/social/ko.js.map +1 -1
- package/dist/locales/social/zh.js +8 -1
- package/dist/locales/social/zh.js.map +1 -1
- package/dist/locales/zh.js +5 -3
- package/dist/locales/zh.js.map +1 -1
- package/dist/provider.d.ts +2 -0
- package/dist/provider.js +23 -19
- package/dist/provider.js.map +1 -1
- package/dist/react/admin.d.ts +55 -0
- package/dist/react/admin.js +97 -0
- package/dist/react/admin.js.map +1 -0
- package/dist/react/comments.d.ts +18 -2
- package/dist/react/comments.js +24 -8
- package/dist/react/comments.js.map +1 -1
- package/dist/react/context.d.ts +7 -1
- package/dist/react/context.js +6 -1
- package/dist/react/context.js.map +1 -1
- package/dist/react/index.d.ts +4 -3
- package/dist/react/polls.js +88 -87
- package/dist/react/polls.js.map +1 -1
- package/dist/react/posts.js +123 -122
- package/dist/react/posts.js.map +1 -1
- package/dist/react/resources.js +3 -0
- package/dist/react/resources.js.map +1 -1
- package/dist/react/use-resource.d.ts +16 -0
- package/dist/react/use-resource.js +20 -1
- package/dist/react/use-resource.js.map +1 -1
- package/dist/react.js +21 -20
- package/dist/styles.css +1 -1
- package/package.json +37 -2
|
@@ -1,155 +1,224 @@
|
|
|
1
1
|
import { toContentKitError as e } from "../../client/errors.js";
|
|
2
2
|
import { useMessages as t } from "../../i18n/context.js";
|
|
3
|
-
import {
|
|
4
|
-
import { useErrorReporter as r } from "../../react/context.js";
|
|
3
|
+
import { useErrorReporter as n, useGuarded as r } from "../../react/context.js";
|
|
5
4
|
import { Button as i } from "../../ui/button.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
5
|
+
import { keyOf as a, useContentScope as o, usePaged as s } from "../../react/use-resource.js";
|
|
6
|
+
import { useModerationQueue as c } from "../../react/comments.js";
|
|
7
|
+
import { Badge as l } from "../../ui/badge.js";
|
|
8
|
+
import { Input as u } from "../../ui/input.js";
|
|
9
|
+
import { Label as d } from "../../ui/label.js";
|
|
10
|
+
import { Select as f, SelectContent as p, SelectItem as m, SelectTrigger as h, SelectValue as g } from "../../ui/select.js";
|
|
11
|
+
import { Skeleton as _ } from "../../ui/skeleton.js";
|
|
12
|
+
import { ErrorLine as v, RelativeTime as y, UserAvatar as b, UserName as x, contentError as S } from "./parts.js";
|
|
13
|
+
import { AdminRoot as C, NoAccess as w, Pager as T, Rows as E, pageOf as D } from "../admin/shell.js";
|
|
14
|
+
import { CommentBanDialog as ee, CommentBans as O } from "./bans.js";
|
|
15
|
+
import { useAdminLocation as k, useFlowClient as A, useStaffAccess as j } from "../../react/admin.js";
|
|
16
|
+
import { Tabs as M, TabsContent as N, TabsList as P, TabsTrigger as F } from "../../ui/tabs.js";
|
|
17
|
+
import { useEffect as I, useId as L, useMemo as R, useState as z } from "react";
|
|
18
|
+
import { Fragment as B, jsx as V, jsxs as H } from "react/jsx-runtime";
|
|
19
|
+
import { cn as te } from "cn";
|
|
17
20
|
//#region src/components/social/moderation.tsx
|
|
18
|
-
|
|
21
|
+
var U = [
|
|
19
22
|
"comments",
|
|
20
23
|
"queue",
|
|
21
24
|
"bans"
|
|
22
|
-
]
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
];
|
|
26
|
+
function W(e = {}) {
|
|
27
|
+
return j(U, e);
|
|
28
|
+
}
|
|
29
|
+
function G({ client: e, baseUrl: t, auth: n, guard: r, appearance: i, className: a, language: o, messages: s, sections: c = U, ...l }) {
|
|
30
|
+
let u = A({
|
|
31
|
+
client: e,
|
|
32
|
+
baseUrl: t,
|
|
33
|
+
auth: n
|
|
34
|
+
});
|
|
35
|
+
return /* @__PURE__ */ V(C, {
|
|
36
|
+
flow: "comment-moderation",
|
|
29
37
|
appearance: i,
|
|
30
|
-
className:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
className: a,
|
|
39
|
+
language: o,
|
|
40
|
+
messages: s,
|
|
41
|
+
guard: r,
|
|
42
|
+
children: /* @__PURE__ */ V(K, {
|
|
43
|
+
...l,
|
|
44
|
+
client: u,
|
|
45
|
+
sections: c
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function K({ sections: e, basePath: n, navigation: r, ...i }) {
|
|
50
|
+
let { t: a } = t(), o = k(n, r), s = W({ client: i.client }), c = e.filter((e) => s.allowed[e]), l = {
|
|
51
|
+
comments: a("moderation.all"),
|
|
52
|
+
queue: a("moderation.queue"),
|
|
53
|
+
bans: a("moderation.bans")
|
|
54
|
+
}, u = /* @__PURE__ */ V("h2", {
|
|
55
|
+
className: "text-base font-semibold",
|
|
56
|
+
children: a("moderation.title")
|
|
57
|
+
});
|
|
58
|
+
if (s.loading) return /* @__PURE__ */ H(B, { children: [u, /* @__PURE__ */ V(E, {})] });
|
|
59
|
+
if (!c.length) return /* @__PURE__ */ H(B, { children: [u, /* @__PURE__ */ V(w, { children: a("moderation.noAccess") })] });
|
|
60
|
+
let d = (t) => t === e[0] ? "" : t, f = o.view || e[0], p = c.includes(f) ? f : c[0], m = d(p);
|
|
61
|
+
return /* @__PURE__ */ H(B, { children: [u, /* @__PURE__ */ H(M, {
|
|
62
|
+
value: p,
|
|
63
|
+
onValueChange: (e) => o.go(d(e)),
|
|
64
|
+
children: [c.length > 1 && /* @__PURE__ */ V(P, { children: c.map((e) => /* @__PURE__ */ V(F, {
|
|
65
|
+
value: e,
|
|
66
|
+
children: l[e]
|
|
67
|
+
}, e)) }), /* @__PURE__ */ H(N, {
|
|
68
|
+
value: p,
|
|
69
|
+
className: "pt-3",
|
|
38
70
|
children: [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
e.includes("comments") && /* @__PURE__ */ O(C, {
|
|
44
|
-
value: "comments",
|
|
45
|
-
className: "pt-3",
|
|
46
|
-
children: /* @__PURE__ */ O(N, { ...a })
|
|
71
|
+
p === "comments" && /* @__PURE__ */ V(J, {
|
|
72
|
+
...i,
|
|
73
|
+
loc: o,
|
|
74
|
+
view: m
|
|
47
75
|
}),
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
76
|
+
p === "queue" && /* @__PURE__ */ V(Y, {
|
|
77
|
+
...i,
|
|
78
|
+
loc: o,
|
|
79
|
+
view: m
|
|
52
80
|
}),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
onError: a.onError
|
|
62
|
-
})
|
|
81
|
+
p === "bans" && /* @__PURE__ */ V(O, {
|
|
82
|
+
scope: "global",
|
|
83
|
+
pageSize: i.pageSize,
|
|
84
|
+
page: D(o.query),
|
|
85
|
+
onPageChange: (e) => o.go(m, { page: e > 1 ? e : void 0 }),
|
|
86
|
+
userHref: i.userHref,
|
|
87
|
+
client: i.client,
|
|
88
|
+
onError: i.onError
|
|
63
89
|
})
|
|
64
90
|
]
|
|
65
91
|
})]
|
|
66
|
-
});
|
|
92
|
+
})] });
|
|
67
93
|
}
|
|
68
|
-
function
|
|
94
|
+
function q(e) {
|
|
69
95
|
return e.deleted ? "deleted" : e.moderation === "held" ? "held" : e.moderation === "rejected" ? "rejected" : "published";
|
|
70
96
|
}
|
|
71
|
-
function
|
|
72
|
-
let { t:
|
|
97
|
+
function J({ loc: c, view: _, client: S, ...C }) {
|
|
98
|
+
let { t: w } = t(), E = L(), O = R(() => (C.contentKinds ?? []).map((e) => typeof e == "string" ? {
|
|
73
99
|
value: e,
|
|
74
100
|
label: e
|
|
75
|
-
} : e), [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}),
|
|
80
|
-
|
|
101
|
+
} : e), [C.contentKinds]), k = c.query.get("kind") ?? "", A = c.query.get("author") ?? "", j = D(c.query), M = C.pageSize ?? 25, N = (e) => c.go(_, {
|
|
102
|
+
kind: k,
|
|
103
|
+
author: A,
|
|
104
|
+
...e
|
|
105
|
+
}), [P, F] = z(A);
|
|
106
|
+
I(() => F(A), [A]);
|
|
107
|
+
let { store: B, scope: U } = o(S), W = s(B, a("admin-comments-page", U, k, A, M), { type: "admin-comments" }, j, M, (e, t) => S.comments.adminList({
|
|
108
|
+
...e,
|
|
109
|
+
contentKind: k || void 0,
|
|
110
|
+
author: A || void 0
|
|
111
|
+
}, t)), G = n(C.onError), K = r(), [J, Y] = z(null), [X, Q] = z(null), $ = (t, n) => {
|
|
112
|
+
Y(null), K(n).catch((n) => {
|
|
81
113
|
let r = e(n);
|
|
82
|
-
|
|
114
|
+
Y(r), G(r, t);
|
|
83
115
|
});
|
|
84
|
-
};
|
|
85
|
-
return /* @__PURE__ */
|
|
116
|
+
}, ne = A ? W.items.find((e) => e.user_id === A)?.author?.username ?? A : "";
|
|
117
|
+
return /* @__PURE__ */ H("div", {
|
|
86
118
|
className: "grid gap-3",
|
|
87
119
|
children: [
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
120
|
+
/* @__PURE__ */ H("div", {
|
|
121
|
+
className: "flex flex-wrap items-end gap-2",
|
|
122
|
+
children: [O.length > 0 && /* @__PURE__ */ H(f, {
|
|
123
|
+
value: k,
|
|
124
|
+
onValueChange: (e) => N({ kind: String(e ?? "") }),
|
|
125
|
+
children: [/* @__PURE__ */ V(h, {
|
|
126
|
+
size: "sm",
|
|
127
|
+
"aria-label": w("moderation.kind"),
|
|
128
|
+
children: /* @__PURE__ */ V(g, { children: (e) => e ? O.find((t) => t.value === e)?.label ?? e : w("moderation.allKinds") })
|
|
129
|
+
}), /* @__PURE__ */ H(p, { children: [/* @__PURE__ */ V(m, {
|
|
130
|
+
value: "",
|
|
131
|
+
children: w("moderation.allKinds")
|
|
132
|
+
}), O.map((e) => /* @__PURE__ */ V(m, {
|
|
133
|
+
value: e.value,
|
|
134
|
+
children: e.label
|
|
135
|
+
}, e.value))] })]
|
|
136
|
+
}), /* @__PURE__ */ H("form", {
|
|
137
|
+
className: "flex min-w-56 flex-1 items-end gap-2",
|
|
138
|
+
onSubmit: (e) => {
|
|
139
|
+
e.preventDefault(), N({ author: P.trim() });
|
|
140
|
+
},
|
|
141
|
+
children: [/* @__PURE__ */ H("div", {
|
|
142
|
+
className: "grid flex-1 gap-1",
|
|
143
|
+
children: [/* @__PURE__ */ V(d, {
|
|
144
|
+
htmlFor: `${E}-author`,
|
|
145
|
+
className: "sr-only",
|
|
146
|
+
children: w("moderation.author")
|
|
147
|
+
}), /* @__PURE__ */ V(u, {
|
|
148
|
+
id: `${E}-author`,
|
|
149
|
+
className: "h-8",
|
|
150
|
+
value: P,
|
|
151
|
+
placeholder: w("moderation.authorPlaceholder"),
|
|
152
|
+
onChange: (e) => F(e.target.value)
|
|
153
|
+
})]
|
|
154
|
+
}), /* @__PURE__ */ V(i, {
|
|
155
|
+
type: "submit",
|
|
156
|
+
size: "sm",
|
|
157
|
+
variant: "outline",
|
|
158
|
+
children: w("moderation.filter")
|
|
159
|
+
})]
|
|
160
|
+
})]
|
|
161
|
+
}),
|
|
162
|
+
A && /* @__PURE__ */ H("div", {
|
|
163
|
+
className: "flex flex-wrap items-center gap-2",
|
|
164
|
+
"data-ckui": "author-filter",
|
|
165
|
+
children: [/* @__PURE__ */ V("span", { children: w("moderation.byAuthor", { name: ne }) }), /* @__PURE__ */ V(i, {
|
|
92
166
|
size: "sm",
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
children: o("moderation.allKinds")
|
|
98
|
-
}), c.map((e) => /* @__PURE__ */ O(d, {
|
|
99
|
-
value: e.value,
|
|
100
|
-
children: e.label
|
|
101
|
-
}, e.value))] })]
|
|
167
|
+
variant: "ghost",
|
|
168
|
+
onClick: () => N({ author: "" }),
|
|
169
|
+
children: w("moderation.clearAuthor")
|
|
170
|
+
})]
|
|
102
171
|
}),
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
loading:
|
|
106
|
-
error:
|
|
107
|
-
empty:
|
|
108
|
-
count:
|
|
109
|
-
reload:
|
|
110
|
-
children:
|
|
111
|
-
let t = e.author?.username ?? e.anon_name ?? e.user_id ??
|
|
172
|
+
/* @__PURE__ */ V(v, { error: J }),
|
|
173
|
+
/* @__PURE__ */ V(Z, {
|
|
174
|
+
loading: W.loading,
|
|
175
|
+
error: W.error,
|
|
176
|
+
empty: w("moderation.empty"),
|
|
177
|
+
count: W.items.length,
|
|
178
|
+
reload: W.reload,
|
|
179
|
+
children: W.items.map((e) => {
|
|
180
|
+
let t = e.author?.username ?? e.anon_name ?? e.user_id ?? w("comments.anonymous"), n = q(e), r = C.itemHref?.({
|
|
112
181
|
kind: e.content_kind,
|
|
113
182
|
id: e.content_id
|
|
114
183
|
});
|
|
115
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ H("li", {
|
|
116
185
|
className: "grid gap-2 p-3",
|
|
117
186
|
"data-ckui": "admin-comment",
|
|
118
|
-
"data-status":
|
|
187
|
+
"data-status": n,
|
|
119
188
|
children: [
|
|
120
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ H("div", {
|
|
121
190
|
className: "flex flex-wrap items-center gap-x-2 gap-y-1",
|
|
122
191
|
children: [
|
|
123
|
-
/* @__PURE__ */
|
|
192
|
+
/* @__PURE__ */ V(b, {
|
|
124
193
|
user: e.author,
|
|
125
194
|
name: t,
|
|
126
195
|
size: "sm"
|
|
127
196
|
}),
|
|
128
|
-
/* @__PURE__ */
|
|
197
|
+
/* @__PURE__ */ V(x, {
|
|
129
198
|
user: e.author,
|
|
130
199
|
name: t,
|
|
131
|
-
href:
|
|
200
|
+
href: C.userHref
|
|
132
201
|
}),
|
|
133
|
-
/* @__PURE__ */
|
|
202
|
+
/* @__PURE__ */ V(y, {
|
|
134
203
|
at: e.created_at,
|
|
135
204
|
className: "text-xs text-muted-foreground"
|
|
136
205
|
}),
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
variant:
|
|
139
|
-
children:
|
|
206
|
+
/* @__PURE__ */ V(l, {
|
|
207
|
+
variant: n === "published" ? "outline" : n === "held" ? "secondary" : "destructive",
|
|
208
|
+
children: w(`moderation.${n}`)
|
|
140
209
|
}),
|
|
141
|
-
e.reply_to_id && /* @__PURE__ */
|
|
210
|
+
e.reply_to_id && /* @__PURE__ */ V(l, {
|
|
142
211
|
variant: "outline",
|
|
143
|
-
children:
|
|
212
|
+
children: w("moderation.reply")
|
|
144
213
|
}),
|
|
145
|
-
/* @__PURE__ */
|
|
214
|
+
/* @__PURE__ */ H("span", {
|
|
146
215
|
className: "text-xs text-muted-foreground",
|
|
147
216
|
children: [
|
|
148
|
-
|
|
217
|
+
w("moderation.on"),
|
|
149
218
|
" ",
|
|
150
|
-
|
|
219
|
+
r ? /* @__PURE__ */ H("a", {
|
|
151
220
|
className: "hover:underline",
|
|
152
|
-
href:
|
|
221
|
+
href: r,
|
|
153
222
|
children: [
|
|
154
223
|
e.content_kind,
|
|
155
224
|
"/",
|
|
@@ -160,224 +229,236 @@ function N(n) {
|
|
|
160
229
|
})
|
|
161
230
|
]
|
|
162
231
|
}),
|
|
163
|
-
/* @__PURE__ */
|
|
164
|
-
className:
|
|
232
|
+
/* @__PURE__ */ V("p", {
|
|
233
|
+
className: te("line-clamp-4 break-words whitespace-pre-wrap", e.deleted && "text-muted-foreground line-through"),
|
|
165
234
|
children: e.body
|
|
166
235
|
}),
|
|
167
|
-
e.moderation_reason && /* @__PURE__ */
|
|
236
|
+
e.moderation_reason && /* @__PURE__ */ V("p", {
|
|
168
237
|
className: "text-xs text-muted-foreground",
|
|
169
|
-
children:
|
|
238
|
+
children: w("moderation.heldBecause", { reason: e.moderation_reason })
|
|
170
239
|
}),
|
|
171
|
-
/* @__PURE__ */
|
|
240
|
+
/* @__PURE__ */ H("div", {
|
|
172
241
|
className: "flex flex-wrap gap-2",
|
|
173
|
-
children: [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
242
|
+
children: [
|
|
243
|
+
e.deleted ? /* @__PURE__ */ V(i, {
|
|
244
|
+
size: "sm",
|
|
245
|
+
variant: "outline",
|
|
246
|
+
onClick: () => $("comment.restore", () => S.comments.restore(e.id)),
|
|
247
|
+
children: w("moderation.restore")
|
|
248
|
+
}) : /* @__PURE__ */ V(i, {
|
|
249
|
+
size: "sm",
|
|
250
|
+
variant: "destructive",
|
|
251
|
+
onClick: () => $("comment.delete", () => S.comments.delete(e.id)),
|
|
252
|
+
children: w("moderation.delete")
|
|
253
|
+
}),
|
|
254
|
+
e.user_id && e.user_id !== A && /* @__PURE__ */ V(i, {
|
|
255
|
+
size: "sm",
|
|
256
|
+
variant: "ghost",
|
|
257
|
+
onClick: () => N({ author: e.user_id }),
|
|
258
|
+
children: w("moderation.theirComments")
|
|
189
259
|
}),
|
|
190
|
-
|
|
191
|
-
|
|
260
|
+
e.user_id && /* @__PURE__ */ V(i, {
|
|
261
|
+
size: "sm",
|
|
262
|
+
variant: "ghost",
|
|
263
|
+
onClick: () => Q({
|
|
264
|
+
id: e.user_id,
|
|
265
|
+
name: t
|
|
266
|
+
}),
|
|
267
|
+
children: w("comments.ban")
|
|
268
|
+
})
|
|
269
|
+
]
|
|
192
270
|
})
|
|
193
271
|
]
|
|
194
272
|
}, e.id);
|
|
195
273
|
})
|
|
196
274
|
}),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
disabled:
|
|
201
|
-
|
|
202
|
-
|
|
275
|
+
/* @__PURE__ */ V(T, {
|
|
276
|
+
page: j,
|
|
277
|
+
hasNext: W.hasNext,
|
|
278
|
+
disabled: W.loading,
|
|
279
|
+
onPage: (e) => c.go(_, {
|
|
280
|
+
kind: k,
|
|
281
|
+
author: A,
|
|
282
|
+
page: e > 1 ? e : void 0
|
|
283
|
+
})
|
|
203
284
|
}),
|
|
204
|
-
|
|
285
|
+
X && /* @__PURE__ */ V(ee, {
|
|
205
286
|
open: !0,
|
|
206
|
-
onOpenChange: (e) => !e &&
|
|
207
|
-
user:
|
|
287
|
+
onOpenChange: (e) => !e && Q(null),
|
|
288
|
+
user: X,
|
|
208
289
|
scopes: ["global"],
|
|
209
|
-
client:
|
|
210
|
-
onError:
|
|
290
|
+
client: S,
|
|
291
|
+
onError: C.onError
|
|
211
292
|
})
|
|
212
293
|
]
|
|
213
294
|
});
|
|
214
295
|
}
|
|
215
|
-
function
|
|
216
|
-
let { t:
|
|
217
|
-
kind:
|
|
218
|
-
pageSize:
|
|
219
|
-
client:
|
|
296
|
+
function Y({ loc: e, view: n, ...r }) {
|
|
297
|
+
let { t: a } = t(), o = e.query.get("kind") === "post" ? "post" : "comment", s = c({
|
|
298
|
+
kind: o,
|
|
299
|
+
pageSize: r.pageSize,
|
|
300
|
+
client: r.client
|
|
220
301
|
});
|
|
221
|
-
return /* @__PURE__ */
|
|
302
|
+
return /* @__PURE__ */ H("div", {
|
|
222
303
|
className: "grid gap-3",
|
|
223
304
|
children: [
|
|
224
|
-
/* @__PURE__ */
|
|
305
|
+
/* @__PURE__ */ V("div", {
|
|
225
306
|
className: "flex gap-2",
|
|
226
307
|
role: "group",
|
|
227
|
-
"aria-label":
|
|
228
|
-
children: ["comment", "post"].map((
|
|
308
|
+
"aria-label": a("moderation.queue"),
|
|
309
|
+
children: ["comment", "post"].map((t) => /* @__PURE__ */ V(i, {
|
|
229
310
|
size: "sm",
|
|
230
|
-
variant:
|
|
231
|
-
"aria-pressed":
|
|
232
|
-
onClick: () =>
|
|
233
|
-
children:
|
|
234
|
-
},
|
|
311
|
+
variant: o === t ? "default" : "outline",
|
|
312
|
+
"aria-pressed": o === t,
|
|
313
|
+
onClick: () => e.go(n, { kind: t === "comment" ? void 0 : t }),
|
|
314
|
+
children: a(t === "post" ? "moderation.queuePosts" : "moderation.queueComments")
|
|
315
|
+
}, t))
|
|
235
316
|
}),
|
|
236
|
-
/* @__PURE__ */
|
|
317
|
+
/* @__PURE__ */ V(Z, {
|
|
237
318
|
loading: s.loading,
|
|
238
319
|
error: s.error,
|
|
239
|
-
empty:
|
|
320
|
+
empty: a("moderation.queueEmpty"),
|
|
240
321
|
count: s.items.length,
|
|
241
322
|
reload: s.reload,
|
|
242
|
-
children: s.items.map((
|
|
243
|
-
item:
|
|
244
|
-
itemHref:
|
|
245
|
-
userHref:
|
|
323
|
+
children: s.items.map((e) => /* @__PURE__ */ V(X, {
|
|
324
|
+
item: e,
|
|
325
|
+
itemHref: r.itemHref,
|
|
326
|
+
userHref: r.userHref,
|
|
246
327
|
onResolve: s.resolve,
|
|
247
328
|
reload: s.reload,
|
|
248
|
-
onError:
|
|
249
|
-
},
|
|
329
|
+
onError: r.onError
|
|
330
|
+
}, e.id))
|
|
250
331
|
}),
|
|
251
|
-
s.hasMore && /* @__PURE__ */
|
|
332
|
+
s.hasMore && /* @__PURE__ */ V(i, {
|
|
252
333
|
variant: "outline",
|
|
253
334
|
className: "justify-self-center",
|
|
254
335
|
disabled: s.loadingMore,
|
|
255
336
|
onClick: () => void s.loadMore(),
|
|
256
|
-
children:
|
|
337
|
+
children: a("moderation.loadMore")
|
|
257
338
|
})
|
|
258
339
|
]
|
|
259
340
|
});
|
|
260
341
|
}
|
|
261
|
-
function
|
|
262
|
-
let
|
|
263
|
-
kind:
|
|
264
|
-
id:
|
|
265
|
-
}),
|
|
266
|
-
|
|
342
|
+
function X(a) {
|
|
343
|
+
let o = t(), { t: s } = o, c = n(a.onError), l = r(), { item: d } = a, [f, p] = z(!1), [m, h] = z(""), [g, _] = z(!1), [C, w] = z(null), T = d.author?.username ?? d.anon_name ?? d.author_id ?? s("comments.anonymous"), E = a.itemHref?.({
|
|
344
|
+
kind: d.ref.content_kind,
|
|
345
|
+
id: d.ref.content_id
|
|
346
|
+
}), D = async (t) => {
|
|
347
|
+
_(!0), w(null);
|
|
267
348
|
try {
|
|
268
|
-
await
|
|
349
|
+
await l(() => a.onResolve(d, t, t === "reject" && m.trim() || void 0));
|
|
269
350
|
} catch (t) {
|
|
270
|
-
let
|
|
271
|
-
|
|
351
|
+
let n = e(t);
|
|
352
|
+
c(n, "moderation.resolve"), n.code === "not_found" || n.code === "conflict" ? (w(s("moderation.stale")), a.reload()) : w(S(o, n));
|
|
272
353
|
} finally {
|
|
273
|
-
|
|
354
|
+
_(!1);
|
|
274
355
|
}
|
|
275
356
|
};
|
|
276
|
-
return /* @__PURE__ */
|
|
357
|
+
return /* @__PURE__ */ H("li", {
|
|
277
358
|
className: "grid gap-2 p-3",
|
|
278
359
|
"data-ckui": "held-item",
|
|
279
360
|
children: [
|
|
280
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ H("div", {
|
|
281
362
|
className: "flex flex-wrap items-center gap-x-2 gap-y-1",
|
|
282
363
|
children: [
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
user:
|
|
285
|
-
name:
|
|
364
|
+
/* @__PURE__ */ V(b, {
|
|
365
|
+
user: d.author,
|
|
366
|
+
name: T,
|
|
286
367
|
size: "sm"
|
|
287
368
|
}),
|
|
288
|
-
/* @__PURE__ */
|
|
289
|
-
user:
|
|
290
|
-
name:
|
|
291
|
-
href:
|
|
369
|
+
/* @__PURE__ */ V(x, {
|
|
370
|
+
user: d.author,
|
|
371
|
+
name: T,
|
|
372
|
+
href: a.userHref
|
|
292
373
|
}),
|
|
293
|
-
/* @__PURE__ */
|
|
294
|
-
at:
|
|
374
|
+
/* @__PURE__ */ V(y, {
|
|
375
|
+
at: d.held_at,
|
|
295
376
|
className: "text-xs text-muted-foreground"
|
|
296
377
|
}),
|
|
297
|
-
|
|
378
|
+
E && /* @__PURE__ */ H("a", {
|
|
298
379
|
className: "text-xs text-muted-foreground hover:underline",
|
|
299
|
-
href:
|
|
380
|
+
href: E,
|
|
300
381
|
children: [
|
|
301
|
-
|
|
382
|
+
s("moderation.on"),
|
|
302
383
|
" ",
|
|
303
|
-
|
|
384
|
+
d.ref.content_kind,
|
|
304
385
|
"/",
|
|
305
|
-
|
|
386
|
+
d.ref.content_id
|
|
306
387
|
]
|
|
307
388
|
})
|
|
308
389
|
]
|
|
309
390
|
}),
|
|
310
|
-
|
|
391
|
+
d.title && /* @__PURE__ */ V("p", {
|
|
311
392
|
className: "font-medium",
|
|
312
|
-
children:
|
|
393
|
+
children: d.title
|
|
313
394
|
}),
|
|
314
|
-
/* @__PURE__ */
|
|
395
|
+
/* @__PURE__ */ V("p", {
|
|
315
396
|
className: "line-clamp-6 break-words whitespace-pre-wrap",
|
|
316
|
-
children:
|
|
397
|
+
children: d.body
|
|
317
398
|
}),
|
|
318
|
-
(
|
|
399
|
+
(d.reason || d.error) && /* @__PURE__ */ V("p", {
|
|
319
400
|
className: "text-xs text-muted-foreground",
|
|
320
|
-
children:
|
|
401
|
+
children: s("moderation.heldBecause", { reason: d.reason || d.error || "" })
|
|
321
402
|
}),
|
|
322
|
-
|
|
323
|
-
value:
|
|
403
|
+
f && /* @__PURE__ */ V(u, {
|
|
404
|
+
value: m,
|
|
324
405
|
maxLength: 500,
|
|
325
|
-
placeholder:
|
|
326
|
-
"aria-label":
|
|
327
|
-
onChange: (e) =>
|
|
406
|
+
placeholder: s("moderation.rejectReason"),
|
|
407
|
+
"aria-label": s("moderation.rejectReason"),
|
|
408
|
+
onChange: (e) => h(e.target.value),
|
|
328
409
|
autoFocus: !0
|
|
329
410
|
}),
|
|
330
|
-
/* @__PURE__ */
|
|
411
|
+
/* @__PURE__ */ H("div", {
|
|
331
412
|
className: "flex flex-wrap gap-2",
|
|
332
413
|
children: [
|
|
333
|
-
/* @__PURE__ */
|
|
414
|
+
/* @__PURE__ */ V(i, {
|
|
334
415
|
size: "sm",
|
|
335
|
-
disabled:
|
|
336
|
-
onClick: () => void
|
|
337
|
-
children:
|
|
416
|
+
disabled: g,
|
|
417
|
+
onClick: () => void D("approve"),
|
|
418
|
+
children: s("moderation.approve")
|
|
338
419
|
}),
|
|
339
|
-
/* @__PURE__ */
|
|
420
|
+
/* @__PURE__ */ V(i, {
|
|
340
421
|
size: "sm",
|
|
341
422
|
variant: "destructive",
|
|
342
|
-
disabled:
|
|
343
|
-
onClick: () =>
|
|
344
|
-
children:
|
|
423
|
+
disabled: g,
|
|
424
|
+
onClick: () => f ? void D("reject") : p(!0),
|
|
425
|
+
children: s("moderation.reject")
|
|
345
426
|
}),
|
|
346
|
-
|
|
427
|
+
f && /* @__PURE__ */ V(i, {
|
|
347
428
|
size: "sm",
|
|
348
429
|
variant: "ghost",
|
|
349
|
-
onClick: () =>
|
|
350
|
-
children:
|
|
430
|
+
onClick: () => p(!1),
|
|
431
|
+
children: s("common.cancel")
|
|
351
432
|
})
|
|
352
433
|
]
|
|
353
434
|
}),
|
|
354
|
-
|
|
435
|
+
C && /* @__PURE__ */ V(v, { children: C })
|
|
355
436
|
]
|
|
356
437
|
});
|
|
357
438
|
}
|
|
358
|
-
function
|
|
439
|
+
function Z(e) {
|
|
359
440
|
let n = t(), { t: r } = n;
|
|
360
|
-
return e.loading && !e.count ? /* @__PURE__ */
|
|
441
|
+
return e.loading && !e.count ? /* @__PURE__ */ H("div", {
|
|
361
442
|
className: "grid gap-3",
|
|
362
443
|
"aria-busy": !0,
|
|
363
|
-
children: [/* @__PURE__ */
|
|
364
|
-
}) : e.error && !e.count ? /* @__PURE__ */
|
|
444
|
+
children: [/* @__PURE__ */ V(_, { className: "h-16 w-full" }), /* @__PURE__ */ V(_, { className: "h-16 w-full" })]
|
|
445
|
+
}) : e.error && !e.count ? /* @__PURE__ */ H("div", {
|
|
365
446
|
className: "grid justify-items-start gap-2",
|
|
366
|
-
children: [/* @__PURE__ */
|
|
447
|
+
children: [/* @__PURE__ */ V(v, { children: e.error.code === "forbidden" || e.error.code === "unauthorized" ? S(n, e.error) : r("moderation.loadFailed") }), /* @__PURE__ */ V(i, {
|
|
367
448
|
size: "sm",
|
|
368
449
|
variant: "outline",
|
|
369
450
|
onClick: e.reload,
|
|
370
451
|
children: r("common.retry")
|
|
371
452
|
})]
|
|
372
|
-
}) : e.count ? /* @__PURE__ */
|
|
453
|
+
}) : e.count ? /* @__PURE__ */ V("ul", {
|
|
373
454
|
className: "grid divide-y divide-border rounded-lg border border-border",
|
|
374
455
|
children: e.children
|
|
375
|
-
}) : /* @__PURE__ */
|
|
456
|
+
}) : /* @__PURE__ */ V("p", {
|
|
376
457
|
className: "text-muted-foreground",
|
|
377
458
|
children: e.empty
|
|
378
459
|
});
|
|
379
460
|
}
|
|
380
461
|
//#endregion
|
|
381
|
-
export {
|
|
462
|
+
export { G as CommentModeration, W as useCommentModerationAccess };
|
|
382
463
|
|
|
383
464
|
//# sourceMappingURL=moderation.js.map
|