strapi-plugin-comments 3.0.6 → 3.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/_chunks/en-CgUbWvmQ.js +1 -0
  3. package/dist/_chunks/{en-DZljqkLz.mjs → en-DCsHR-ue.mjs} +2 -2
  4. package/dist/_chunks/fr-BXfxIXq1.js +1 -0
  5. package/dist/_chunks/{fr-oAh2cU0E.mjs → fr-DC9DGoT1.mjs} +2 -2
  6. package/dist/_chunks/index-Bpnqk6JP.js +1 -0
  7. package/dist/_chunks/index-CF4vndXw.mjs +38389 -0
  8. package/dist/_chunks/index-CFIjHfkZ.js +2153 -0
  9. package/dist/_chunks/index-CHDv123w.js +44 -0
  10. package/dist/_chunks/index-CwHmRIcs.mjs +339 -0
  11. package/dist/_chunks/{index-yhf78avJ.mjs → index-DGKkpdmq.mjs} +15352 -25164
  12. package/dist/_chunks/index-YPqaQ-iX.js +600 -0
  13. package/dist/_chunks/index-pLgOJz-6.mjs +5718 -0
  14. package/dist/_chunks/pl-Bl4yP3sZ.js +1 -0
  15. package/dist/_chunks/{pl-BUVUFx9r.mjs → pl-DZiVsGIg.mjs} +2 -2
  16. package/dist/_chunks/{pt-BR-Bchhsf7B.mjs → pt-BR-CW4ugNZj.mjs} +2 -2
  17. package/dist/_chunks/pt-BR-D9T5g0JT.js +1 -0
  18. package/dist/_chunks/{ru-BQ54P0xr.mjs → ru-CfKjYq3M.mjs} +2 -2
  19. package/dist/_chunks/ru-DIZ4pV4l.js +1 -0
  20. package/dist/_chunks/{tr-CkGcBRUv.mjs → tr-BQR2hK7S.mjs} +2 -2
  21. package/dist/_chunks/tr-Dl2hdLCx.js +1 -0
  22. package/dist/_chunks/zh-Hans-BZhnqfei.js +1 -0
  23. package/dist/_chunks/{zh-Hans-Buh0iPWA.mjs → zh-Hans-lNqOn5JS.mjs} +2 -2
  24. package/dist/admin/index.js +1 -4
  25. package/dist/admin/index.mjs +2 -2
  26. package/dist/server/index.js +92 -14968
  27. package/dist/server/index.mjs +8927 -11840
  28. package/dist/server/src/controllers/index.d.ts +105 -0
  29. package/dist/server/src/index.d.ts +420 -0
  30. package/dist/server/src/services/admin/admin.service.d.ts +105 -0
  31. package/dist/server/src/services/client.service.d.ts +105 -0
  32. package/dist/server/src/services/index.d.ts +315 -0
  33. package/dist/server/src/validators/api/controllers/client.controller.validator.d.ts +105 -0
  34. package/dist/style.css +1 -84
  35. package/package.json +9 -9
  36. package/dist/_chunks/en-D1Rj1A_i.js +0 -195
  37. package/dist/_chunks/fr-DbxNAr65.js +0 -146
  38. package/dist/_chunks/index-BMAhFLKR.js +0 -375
  39. package/dist/_chunks/index-CK1XCSqz.mjs +0 -373
  40. package/dist/_chunks/index-DCKroyap.js +0 -51702
  41. package/dist/_chunks/index-DHhRVslt.js +0 -51324
  42. package/dist/_chunks/index-DUWJDJLu.mjs +0 -51309
  43. package/dist/_chunks/index-PCqyAKE7.mjs +0 -8487
  44. package/dist/_chunks/index-_4jTpBrc.js +0 -8503
  45. package/dist/_chunks/pl-CuTgrHph.js +0 -195
  46. package/dist/_chunks/pt-BR-2Z9CtgSm.js +0 -145
  47. package/dist/_chunks/ru-gtnRlbuP.js +0 -195
  48. package/dist/_chunks/tr-Ucl3IKMX.js +0 -193
  49. package/dist/_chunks/zh-Hans-Dhk3gIYb.js +0 -195
@@ -1,373 +0,0 @@
1
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
- import { a1 as Alert, e as Button, f as ForwardRef$4x, B as Box, a2 as ForwardRef$1f, F as Flex, T as Typography, Z as Grid, m as Field, a3 as MultiSelect, a4 as MultiSelectOption, a5 as Accordion, a6 as SwitchImpl, a7 as Toggle, a8 as ForwardRef$59 } from "./index-DUWJDJLu.mjs";
3
- import { useTracking, useNotification, Page, Layouts, Form } from "@strapi/strapi/admin";
4
- import { useMutation, useQuery, useQueryClient, QueryClient } from "@tanstack/react-query";
5
- import { u as useAPI, f as CommonProviders, a as usePermissions, g as getMessage, l as lodashExports, e as ConfirmationDialog } from "./index-PCqyAKE7.mjs";
6
- import { useMemo, useRef, useState, useCallback } from "react";
7
- import styled from "styled-components";
8
- const RenderIf = ({
9
- children,
10
- condition
11
- }) => {
12
- return condition ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
13
- };
14
- const useSettingsAPI = (callbacksMutation = {}) => {
15
- const api = useAPI();
16
- const updateSettingsMutation = useMutation({
17
- mutationFn: api.settings.update,
18
- onSuccess: callbacksMutation.updateSettingsMutationSuccess,
19
- onError: callbacksMutation.updateSettingsMutationError
20
- });
21
- const restoreSettingsMutation = useMutation({
22
- mutationFn: api.settings.restore,
23
- onSuccess: callbacksMutation.restoreSettingsMutationSuccess,
24
- onError: callbacksMutation.restoreSettingsMutationError
25
- });
26
- const restartStrapiMutation = useMutation({
27
- mutationFn: api.settings.restart,
28
- onSuccess: callbacksMutation.restartStrapiMutationSuccess,
29
- onError: callbacksMutation.restartStrapiMutationError
30
- });
31
- const config = useQuery({
32
- queryKey: api.config.getKey(),
33
- queryFn: api.config.query
34
- });
35
- const collectionTypes = useQuery({
36
- queryKey: api.contentTypeBuilder.all.getKey(),
37
- queryFn: api.contentTypeBuilder.all.query
38
- });
39
- const roles = useQuery({
40
- queryKey: api.roles.getKey(),
41
- queryFn: api.roles.query
42
- });
43
- return useMemo(() => ({
44
- config,
45
- collectionTypes,
46
- roles,
47
- restoreSettingsMutation,
48
- updateSettingsMutation,
49
- restartStrapiMutation
50
- }), [
51
- config,
52
- roles,
53
- collectionTypes,
54
- restoreSettingsMutation,
55
- updateSettingsMutation,
56
- restartStrapiMutation
57
- ]);
58
- };
59
- const boxDefaultProps = {
60
- background: "neutral0",
61
- hasRadius: true,
62
- shadow: "filterShadow",
63
- padding: 6,
64
- width: "100%"
65
- };
66
- const StyledAlert = styled(Alert)(() => ({
67
- "[role]": {
68
- flexDirection: "column"
69
- }
70
- }));
71
- const Settings = () => {
72
- useTracking();
73
- const formRef = useRef(null);
74
- const { toggleNotification } = useNotification();
75
- const [isRestartRequired, setIsRestartRequired] = useState(false);
76
- const { isLoadingForPermissions, canSettingsChange } = usePermissions();
77
- const queryClient2 = useQueryClient();
78
- const api = useAPI();
79
- const {
80
- config,
81
- collectionTypes,
82
- roles,
83
- restoreSettingsMutation,
84
- updateSettingsMutation,
85
- restartStrapiMutation
86
- } = useSettingsAPI({
87
- restoreSettingsMutationSuccess: () => {
88
- queryClient2.invalidateQueries({
89
- queryKey: api.config.getKey(),
90
- exact: false
91
- });
92
- setIsRestartRequired(true);
93
- toggleNotification({
94
- message: getMessage("page.settings.actions.restore.success"),
95
- type: "success"
96
- });
97
- },
98
- restartStrapiMutationSuccess: () => {
99
- setIsRestartRequired(false);
100
- },
101
- updateSettingsMutationSuccess: () => {
102
- queryClient2.invalidateQueries({
103
- queryKey: api.config.getKey(),
104
- exact: false
105
- });
106
- setIsRestartRequired(true);
107
- }
108
- });
109
- const onTriggerSubmit = useCallback(() => {
110
- formRef.current?.requestSubmit();
111
- }, []);
112
- const onSubmit = useCallback((values) => {
113
- updateSettingsMutation.mutate({
114
- ...values,
115
- blockedAuthorProps: values.blockedAuthorProps.split(",").map((prop) => prop.trim())
116
- });
117
- }, [updateSettingsMutation]);
118
- if (config.status !== "success" || collectionTypes.status !== "success" || roles.status !== "success" || isLoadingForPermissions) {
119
- return getMessage("page.settings.loading");
120
- }
121
- const allCollections = collectionTypes.data.filter((ct) => ct.uid.includes("api::"));
122
- const enabledCollections = config.data.enabledCollections.filter((uid) => allCollections.some((ct) => ct.uid === uid));
123
- const badWords = lodashExports.isNil(config.data.badWords) ? true : config.data?.badWords;
124
- const gqlAuthEnabled = Boolean(config.data.gql?.auth || null);
125
- const moderatorRoles = config.data.moderatorRoles.filter((role) => roles.data.filter((r) => r.code === role));
126
- const clientUrl = config.data.client?.url;
127
- const clientEmail = config.data.client?.contactEmail;
128
- const blockedAuthorProps = config.data.blockedAuthorProps ?? [];
129
- const onDiscardRestart = () => setIsRestartRequired(false);
130
- return /* @__PURE__ */ jsxs(Fragment, { children: [
131
- /* @__PURE__ */ jsx(Page.Title, { children: "Comments - settings" }),
132
- /* @__PURE__ */ jsxs(Page.Main, { children: [
133
- /* @__PURE__ */ jsx(
134
- Layouts.Header,
135
- {
136
- title: getMessage("page.settings.header.title"),
137
- subtitle: getMessage("page.settings.header.description"),
138
- as: "h2",
139
- primaryAction: /* @__PURE__ */ jsx(RenderIf, { condition: canSettingsChange, children: /* @__PURE__ */ jsx(Button, { type: "submit", startIcon: /* @__PURE__ */ jsx(ForwardRef$4x, {}), onClick: onTriggerSubmit, children: getMessage("page.settings.actions.submit") }) })
140
- }
141
- ),
142
- /* @__PURE__ */ jsxs(Layouts.Content, { children: [
143
- isRestartRequired && /* @__PURE__ */ jsx(Box, { marginBottom: 4, children: /* @__PURE__ */ jsx(
144
- StyledAlert,
145
- {
146
- closeLabel: getMessage("page.settings.actions.restart.alert.cancel"),
147
- title: getMessage("page.settings.actions.restart.alert.title"),
148
- onClose: onDiscardRestart,
149
- action: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Button, { onClick: restartStrapiMutation.mutate, startIcon: /* @__PURE__ */ jsx(ForwardRef$1f, {}), children: getMessage("page.settings.actions.restart") }) }),
150
- children: /* @__PURE__ */ jsx(Box, { marginTop: 4, children: getMessage("page.settings.actions.restart.alert.description") })
151
- }
152
- ) }),
153
- /* @__PURE__ */ jsx(
154
- Form,
155
- {
156
- method: "POST",
157
- ref: formRef,
158
- onSubmit,
159
- initialValues: {
160
- enabledCollections,
161
- moderatorRoles,
162
- badWords,
163
- clientEmail,
164
- clientUrl,
165
- gqlAuthEnabled,
166
- approvalFlow: config.data.approvalFlow,
167
- entryLabel: config.data.entryLabel,
168
- blockedAuthorProps: blockedAuthorProps.join(", ")
169
- },
170
- children: ({ values, onChange }) => /* @__PURE__ */ jsxs(Flex, { gap: 4, direction: "column", children: [
171
- /* @__PURE__ */ jsxs(Box, { ...boxDefaultProps, children: [
172
- /* @__PURE__ */ jsx(Typography, { variant: "delta", as: "h2", children: getMessage("page.settings.section.general") }),
173
- /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, marginTop: 4, width: "100%", children: [
174
- /* @__PURE__ */ jsx(Grid.Item, { xs: 12, children: /* @__PURE__ */ jsxs(Field.Root, { width: "100%", hint: getMessage("page.settings.form.enabledCollections.hint"), children: [
175
- /* @__PURE__ */ jsx(Field.Label, { htmlFor: "enabledCollections", children: getMessage("page.settings.form.enabledCollections.label") }),
176
- /* @__PURE__ */ jsx(
177
- MultiSelect,
178
- {
179
- withTags: true,
180
- name: "enabledCollections",
181
- value: values.enabledCollections,
182
- onChange: (value) => {
183
- onChange("enabledCollections", value);
184
- },
185
- children: allCollections.map((collection) => /* @__PURE__ */ jsx(MultiSelectOption, { value: collection.uid, children: collection.schema.displayName }, collection.uid))
186
- }
187
- ),
188
- /* @__PURE__ */ jsx(Field.Hint, {})
189
- ] }) }),
190
- values.enabledCollections.length > 0 && /* @__PURE__ */ jsx(Grid.Item, { children: /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, width: "100%", children: [
191
- /* @__PURE__ */ jsx(Grid.Item, { children: /* @__PURE__ */ jsx(Typography, { children: getMessage("page.settings.form.contentTypesSettings.label") }) }),
192
- /* @__PURE__ */ jsx(Grid.Item, { children: /* @__PURE__ */ jsx(Accordion.Root, { style: { width: "100%" }, children: lodashExports.orderBy(values.enabledCollections).map((uid) => {
193
- const collection = allCollections.find((ct) => ct.uid === uid);
194
- if (collection) {
195
- const { schema: { displayName, attributes } } = collection;
196
- const stringAttributes = Object.keys(attributes).filter((key) => attributes[key].type === "string");
197
- return /* @__PURE__ */ jsxs(Accordion.Item, { value: uid, children: [
198
- /* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", as: "h3", children: displayName }) }) }),
199
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsxs(Grid.Root, { padding: 6, gap: 4, children: [
200
- /* @__PURE__ */ jsx(Grid.Item, { children: /* @__PURE__ */ jsxs(
201
- Field.Root,
202
- {
203
- width: "100%",
204
- hint: getMessage({
205
- id: "page.settings.form.approvalFlow.hint",
206
- props: { name: displayName }
207
- }),
208
- children: [
209
- /* @__PURE__ */ jsx(Field.Label, { children: getMessage("page.settings.form.approvalFlow.label") }),
210
- /* @__PURE__ */ jsx(
211
- SwitchImpl,
212
- {
213
- visibleLabels: true,
214
- onLabel: getMessage("components.toogle.enabled"),
215
- offLabel: getMessage("components.toogle.disabled"),
216
- checked: values.approvalFlow.includes(uid),
217
- onCheckedChange: (checked) => {
218
- onChange("approvalFlow", checked ? [...values.approvalFlow, uid] : values.approvalFlow.filter((c) => c !== uid));
219
- }
220
- }
221
- ),
222
- /* @__PURE__ */ jsx(Field.Hint, {})
223
- ]
224
- }
225
- ) }),
226
- /* @__PURE__ */ jsx(RenderIf, { condition: stringAttributes.length > 0, children: /* @__PURE__ */ jsx(Grid.Item, { children: /* @__PURE__ */ jsxs(
227
- Field.Root,
228
- {
229
- width: "100%",
230
- hint: getMessage("page.settings.form.entryLabel.hint"),
231
- children: [
232
- /* @__PURE__ */ jsx(Field.Label, { children: getMessage("page.settings.form.entryLabel.label") }),
233
- /* @__PURE__ */ jsx(
234
- MultiSelect,
235
- {
236
- withTags: true,
237
- placeholder: getMessage("page.settings.form.entryLabel.placeholder"),
238
- name: "enabledCollections",
239
- value: values.entryLabel[uid] ?? [],
240
- onChange: (value) => {
241
- onChange("entryLabel", { ...values.entryLabel, [uid]: value });
242
- },
243
- children: stringAttributes.map((attr) => /* @__PURE__ */ jsx(MultiSelectOption, { value: attr, children: attr }, attr))
244
- }
245
- ),
246
- /* @__PURE__ */ jsx(Field.Hint, {})
247
- ]
248
- }
249
- ) }) })
250
- ] }) })
251
- ] }, uid);
252
- }
253
- return null;
254
- }) }) })
255
- ] }) })
256
- ] })
257
- ] }),
258
- /* @__PURE__ */ jsxs(Box, { ...boxDefaultProps, children: [
259
- /* @__PURE__ */ jsx(Typography, { variant: "delta", as: "h2", children: getMessage("page.settings.section.additional") }),
260
- /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, marginTop: 4, width: "100%", children: [
261
- /* @__PURE__ */ jsx(Grid.Item, { xs: 4, children: /* @__PURE__ */ jsxs(Field.Root, { width: "100%", hint: getMessage("page.settings.form.enabledCollections.hint"), children: [
262
- /* @__PURE__ */ jsx(Field.Label, { htmlFor: "enabledCollections", children: getMessage("page.settings.form.enabledCollections.label") }),
263
- /* @__PURE__ */ jsx(
264
- Toggle,
265
- {
266
- name: "badWords",
267
- checked: values.badWords,
268
- onChange,
269
- onLabel: getMessage("components.toogle.enabled"),
270
- offLabel: getMessage("components.toogle.disabled"),
271
- width: "100%"
272
- }
273
- ),
274
- /* @__PURE__ */ jsx(Field.Hint, {})
275
- ] }) }),
276
- /* @__PURE__ */ jsx(Grid.Item, { xs: 4, children: /* @__PURE__ */ jsxs(Field.Root, { width: "100%", hint: getMessage("page.settings.form.author.blockedProps.hint"), children: [
277
- /* @__PURE__ */ jsx(Field.Label, { htmlFor: "enabledCollections", children: getMessage("page.settings.form.author.blockedProps.label") }),
278
- /* @__PURE__ */ jsx(Field.Input, { name: "blockedProps", onChange }),
279
- /* @__PURE__ */ jsx(Field.Hint, {})
280
- ] }) }),
281
- /* @__PURE__ */ jsx(Grid.Item, { xs: 4, children: /* @__PURE__ */ jsxs(Field.Root, { width: "100%", hint: getMessage("page.settings.form.gqlAuth.hint"), children: [
282
- /* @__PURE__ */ jsx(Field.Label, { children: getMessage("page.settings.form.gqlAuth.label") }),
283
- /* @__PURE__ */ jsx(
284
- Toggle,
285
- {
286
- name: "gqlAuthEnabled",
287
- checked: values.gqlAuthEnabled,
288
- onChange,
289
- onLabel: getMessage("components.toogle.enabled"),
290
- offLabel: getMessage("components.toogle.disabled"),
291
- width: "100%"
292
- }
293
- ),
294
- /* @__PURE__ */ jsx(Field.Hint, {})
295
- ] }) })
296
- ] })
297
- ] }),
298
- /* @__PURE__ */ jsxs(Box, { ...boxDefaultProps, children: [
299
- /* @__PURE__ */ jsx(Typography, { variant: "delta", as: "h2", children: getMessage("page.settings.section.client") }),
300
- /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, marginTop: 4, width: "100%", children: [
301
- /* @__PURE__ */ jsx(Grid.Item, { xs: 4, children: /* @__PURE__ */ jsxs(Field.Root, { width: "100%", hint: getMessage("page.settings.form.client.url.hint"), children: [
302
- /* @__PURE__ */ jsx(Field.Label, { children: getMessage("page.settings.form.client.url.label") }),
303
- /* @__PURE__ */ jsx(Field.Input, { name: "clientUrl", onChange }),
304
- /* @__PURE__ */ jsx(Field.Hint, {})
305
- ] }) }),
306
- /* @__PURE__ */ jsx(Grid.Item, { xs: 4, children: /* @__PURE__ */ jsxs(Field.Root, { width: "100%", hint: getMessage("page.settings.form.client.email.hint"), children: [
307
- /* @__PURE__ */ jsx(Field.Label, { children: getMessage("page.settings.form.client.email.label") }),
308
- /* @__PURE__ */ jsx(Field.Input, { name: "clientEmail", onChange }),
309
- /* @__PURE__ */ jsx(Field.Hint, {})
310
- ] }) }),
311
- /* @__PURE__ */ jsx(Grid.Item, { xs: 4, children: /* @__PURE__ */ jsxs(
312
- Field.Root,
313
- {
314
- width: "100%",
315
- hint: getMessage("page.settings.form.moderatorRoles.hint"),
316
- children: [
317
- /* @__PURE__ */ jsx(Field.Label, { children: getMessage("page.settings.form.moderatorRoles.label") }),
318
- /* @__PURE__ */ jsx(
319
- MultiSelect,
320
- {
321
- withTags: true,
322
- placeholder: getMessage("page.settings.form.moderatorRoles.placeholder"),
323
- name: "enabledCollections",
324
- value: values.moderatorRoles,
325
- onChange: (value) => {
326
- onChange("moderatorRoles", value);
327
- },
328
- children: roles.data.map((role) => /* @__PURE__ */ jsx(MultiSelectOption, { value: role.code, children: role.name }, role.code))
329
- }
330
- ),
331
- /* @__PURE__ */ jsx(Field.Hint, {})
332
- ]
333
- }
334
- ) })
335
- ] })
336
- ] }),
337
- /* @__PURE__ */ jsx(RenderIf, { condition: canSettingsChange, children: /* @__PURE__ */ jsx(Box, { ...boxDefaultProps, children: /* @__PURE__ */ jsxs(Flex, { gap: 4, direction: "column", alignItems: "flex-start", children: [
338
- /* @__PURE__ */ jsxs(Flex, { gap: 2, direction: "column", alignItems: "flex-start", children: [
339
- /* @__PURE__ */ jsx(Typography, { variant: "delta", as: "h2", children: getMessage("page.settings.section.restore") }),
340
- /* @__PURE__ */ jsx(Typography, { variant: "pi", as: "h4", children: getMessage("page.settings.section.restore.subtitle") })
341
- ] }),
342
- /* @__PURE__ */ jsx(
343
- ConfirmationDialog,
344
- {
345
- Trigger: ({ onClick }) => /* @__PURE__ */ jsx(
346
- Button,
347
- {
348
- variant: "danger-light",
349
- startIcon: /* @__PURE__ */ jsx(ForwardRef$59, {}),
350
- onClick,
351
- children: getMessage("page.settings.actions.restore")
352
- }
353
- ),
354
- onConfirm: restoreSettingsMutation.mutate,
355
- title: getMessage("page.settings.actions.restore.confirmation.header"),
356
- labelConfirm: getMessage("page.settings.actions.restore.confirmation.button.confirm"),
357
- iconConfirm: /* @__PURE__ */ jsx(ForwardRef$59, {}),
358
- children: getMessage("page.settings.actions.restore.confirmation.description")
359
- }
360
- )
361
- ] }) }) })
362
- ] })
363
- }
364
- )
365
- ] })
366
- ] })
367
- ] });
368
- };
369
- new QueryClient();
370
- const index = () => /* @__PURE__ */ jsx(CommonProviders, { children: /* @__PURE__ */ jsx(Settings, {}) });
371
- export {
372
- index as default
373
- };