@sensinum/strapi-plugin-multi-domain 5.1.5 → 5.2.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.
Files changed (37) hide show
  1. package/dist/_chunks/About-DNyaGrYn.mjs +435 -0
  2. package/dist/_chunks/About-DaPMT-kj.js +38 -0
  3. package/dist/_chunks/Settings-B823hBAu.mjs +23 -0
  4. package/dist/_chunks/Settings-B_1YuoN9.js +1 -0
  5. package/dist/_chunks/{TenantCustomField-CtCNZEgB.mjs → TenantCustomField-B9Ntpj-S.mjs} +1 -1
  6. package/dist/_chunks/{TenantCustomField-BYDxTP5y.js → TenantCustomField-CHUfO3Xh.js} +1 -1
  7. package/dist/_chunks/TenantEdit-BFvwBQFd.mjs +494 -0
  8. package/dist/_chunks/TenantEdit-Bkw_eaGW.js +1 -0
  9. package/dist/_chunks/TenantList-C9nnIaGg.js +1 -0
  10. package/dist/_chunks/TenantList-DRfWswjS.mjs +266 -0
  11. package/dist/_chunks/{en-BIUQvQi4.mjs → en-Cf69p5po.mjs} +43 -0
  12. package/dist/_chunks/en-hAVH8fH0.js +1 -0
  13. package/dist/_chunks/{index-DkEjJa1n.mjs → index-2nR8Jd1x.mjs} +32 -32
  14. package/dist/_chunks/{index-D9I-QR8y.js → index-Cvs1ZCFy.js} +1 -1
  15. package/dist/_chunks/index-DEoxiYwP.mjs +331 -0
  16. package/dist/_chunks/index-DuSOcmV4.js +1 -0
  17. package/dist/_chunks/useGetMessage-B1Xnqz3k.js +1 -0
  18. package/dist/_chunks/useGetMessage-K3OG9Tv0.mjs +15 -0
  19. package/dist/_chunks/useSettings-BCMuYsbx.js +1 -0
  20. package/dist/_chunks/useSettings-QOof9ZTx.mjs +11 -0
  21. package/dist/_chunks/{useTenants-CE8J0EOu.mjs → useTenants-CT-L6xX1.mjs} +38 -45
  22. package/dist/_chunks/useTenants-_putKXAO.js +1 -0
  23. package/dist/admin/index.js +1 -1
  24. package/dist/admin/index.mjs +2 -2
  25. package/dist/server/index.js +4 -4
  26. package/dist/server/index.mjs +5467 -5332
  27. package/package.json +3 -1
  28. package/dist/_chunks/Settings-BPM919an.mjs +0 -23
  29. package/dist/_chunks/Settings-CT4xmD8_.js +0 -1
  30. package/dist/_chunks/TenantEdit-BdSUNboL.mjs +0 -494
  31. package/dist/_chunks/TenantEdit-C4LHKCAr.js +0 -1
  32. package/dist/_chunks/TenantList-Cl9445sU.js +0 -1
  33. package/dist/_chunks/TenantList-DWA0Z3-T.mjs +0 -272
  34. package/dist/_chunks/en-Dj_hyppO.js +0 -1
  35. package/dist/_chunks/index-Ck1YIRr4.js +0 -1
  36. package/dist/_chunks/index-Ds2z-yoa.mjs +0 -315
  37. package/dist/_chunks/useTenants-XMURO_eU.js +0 -1
package/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "@sensinum/strapi-plugin-multi-domain",
3
- "version": "5.1.5",
3
+ "version": "5.2.0",
4
4
  "description": "Allow to provide multi domain support",
5
+ "homepage": "https://www.sensinum.com/contact",
6
+ "email": "hello@sensinum.com",
5
7
  "strapi": {
6
8
  "kind": "plugin",
7
9
  "name": "multi-domain",
@@ -1,23 +0,0 @@
1
- import { jsx as e, jsxs as i } from "react/jsx-runtime";
2
- import { lightTheme as a, darkTheme as n, DesignSystemProvider as s } from "@strapi/design-system";
3
- import o from "react";
4
- import { Routes as l, Route as t, Navigate as p } from "react-router-dom";
5
- import { m as r, p as d } from "./index-Ds2z-yoa.mjs";
6
- import { Q as h } from "./QueryProvider-DLzv0qqi.mjs";
7
- const c = o.lazy(() => import("./TenantList-DWA0Z3-T.mjs")), g = o.lazy(() => import("./TenantEdit-BdSUNboL.mjs")), P = () => {
8
- const m = localStorage.getItem("STRAPI_THEME") === "light" ? a : n;
9
- return /* @__PURE__ */ e(s, { theme: m, children: /* @__PURE__ */ e(h, { children: /* @__PURE__ */ i(l, { children: [
10
- /* @__PURE__ */ e(t, { path: r, element: /* @__PURE__ */ e(c, {}) }),
11
- /* @__PURE__ */ e(t, { path: `/${r}/:id`, element: /* @__PURE__ */ e(g, {}) }),
12
- /* @__PURE__ */ e(
13
- t,
14
- {
15
- path: "*",
16
- element: /* @__PURE__ */ e(p, { to: `/settings/${d}/${r}`, replace: !0 })
17
- }
18
- )
19
- ] }) }) });
20
- };
21
- export {
22
- P as default
23
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@strapi/design-system"),i=require("react"),r=require("react-router-dom"),o=require("./index-Ck1YIRr4.js"),u=require("./QueryProvider-DUoM4JhC.js"),l=t=>t&&t.__esModule?t:{default:t},n=l(i),a=n.default.lazy(()=>Promise.resolve().then(()=>require("./TenantList-Cl9445sU.js"))),d=n.default.lazy(()=>Promise.resolve().then(()=>require("./TenantEdit-C4LHKCAr.js"))),c=()=>{const t=localStorage.getItem("STRAPI_THEME")==="light"?s.lightTheme:s.darkTheme;return e.jsx(s.DesignSystemProvider,{theme:t,children:e.jsx(u.QueryProvider,{children:e.jsxs(r.Routes,{children:[e.jsx(r.Route,{path:o.modelRoute,element:e.jsx(a,{})}),e.jsx(r.Route,{path:`/${o.modelRoute}/:id`,element:e.jsx(d,{})}),e.jsx(r.Route,{path:"*",element:e.jsx(r.Navigate,{to:`/settings/${o.pluginId}/${o.modelRoute}`,replace:!0})})]})})})};exports.default=c;
@@ -1,494 +0,0 @@
1
- import { jsx as e, jsxs as u, Fragment as E } from "react/jsx-runtime";
2
- import { Flex as b, Box as f, Typography as L, Button as D, Link as B, Field as d, Combobox as K, ComboboxOption as V, IconButton as $, MultiSelect as z, MultiSelectOption as G, TextInput as x, JSONInput as Q, Loader as U, Grid as C } from "@strapi/design-system";
3
- import { Layouts as O, useStrapiApp as X, useNotification as Y, Page as N, Form as Z } from "@strapi/strapi/admin";
4
- import _, { useCallback as H } from "react";
5
- import { useIntl as T } from "react-intl";
6
- import { NavLink as ee, useNavigate as te, useParams as ne } from "react-router-dom";
7
- import { isEmpty as oe } from "remeda";
8
- import { a as q, p as I, b as P } from "./index-Ds2z-yoa.mjs";
9
- import { g as t, C as ie, b as ae, c as re, d as de } from "./useTenants-CE8J0EOu.mjs";
10
- import { ArrowLeft as le, Cross as se } from "@strapi/icons";
11
- import { useQuery as A, useMutation as ce } from "@tanstack/react-query";
12
- import { a as M } from "./index-DkEjJa1n.mjs";
13
- const me = ({
14
- isEditing: n,
15
- isSaving: l,
16
- onCancel: o
17
- }) => {
18
- const { formatMessage: r } = T();
19
- return /* @__PURE__ */ e(b, { justifyContent: "flex-start", gap: 2, direction: "column", height: "100%", width: "100%", children: /* @__PURE__ */ u(f, { background: "neutral0", padding: 8, shadow: "filterShadow", hasRadius: !0, width: "100%", children: [
20
- /* @__PURE__ */ e(
21
- L,
22
- {
23
- variant: "sigma",
24
- textTransform: "uppercase",
25
- textColor: "neutral600",
26
- tag: "h2",
27
- marginBottom: 4,
28
- children: t(r, "domain.edit.actions.entry")
29
- }
30
- ),
31
- /* @__PURE__ */ u(b, { direction: "column", gap: 2, children: [
32
- /* @__PURE__ */ e(
33
- ie,
34
- {
35
- permissions: n ? q.admin.edit : q.admin.create,
36
- children: /* @__PURE__ */ e(D, { type: "submit", loading: l, width: "100%", children: n ? t(r, "domain.edit.actions.update") : t(r, "domain.edit.actions.create") })
37
- }
38
- ),
39
- /* @__PURE__ */ e(D, { variant: "secondary", onClick: o, width: "100%", children: t(r, "common.cancel") })
40
- ] })
41
- ] }) });
42
- }, ue = ({ isEditing: n, tenantName: l }) => {
43
- const { formatMessage: o } = T();
44
- return /* @__PURE__ */ e(
45
- O.Header,
46
- {
47
- title: /* @__PURE__ */ e(f, { padding: 6, children: /* @__PURE__ */ u(b, { gap: 2, direction: "column", alignItems: "flex-start", children: [
48
- /* @__PURE__ */ e(
49
- B,
50
- {
51
- variant: "tertiary",
52
- tag: ee,
53
- startIcon: /* @__PURE__ */ e(le, {}),
54
- to: `/settings/${I}`,
55
- children: t(o, "common.back")
56
- }
57
- ),
58
- /* @__PURE__ */ e(L, { variant: "alpha", fontWeight: "bold", marginTop: 2, children: n ? l || t(o, "domain.edit.title.edit", {
59
- values: { name: P }
60
- }) : t(o, "domain.edit.title.create") })
61
- ] }) }),
62
- as: "h2"
63
- }
64
- );
65
- }, he = ({ disabled: n = !1, error: l }) => {
66
- const { formatMessage: o } = T(), r = X(
67
- "CustomMediaInput",
68
- (i) => i.fields?.media || {}
69
- );
70
- return r ? /* @__PURE__ */ u(
71
- d.Root,
72
- {
73
- name: "logo",
74
- hint: t(o, "domain.edit.form.logo.hint"),
75
- error: l,
76
- children: [
77
- /* @__PURE__ */ e(
78
- r,
79
- {
80
- label: "Logo",
81
- name: "logo",
82
- disabled: n,
83
- attribute: {
84
- allowedTypes: ["images"],
85
- multiple: !1
86
- }
87
- }
88
- ),
89
- /* @__PURE__ */ e(d.Hint, {}),
90
- /* @__PURE__ */ e(d.Error, {})
91
- ]
92
- }
93
- ) : null;
94
- }, W = {
95
- all: ["roles"],
96
- lists: () => [...W.all, "list"]
97
- }, ge = () => A({
98
- queryKey: W.lists(),
99
- queryFn: () => M.getRoles(),
100
- staleTime: 10 * 60 * 1e3
101
- // 10 minutes - roles don't change often
102
- }), pe = ({
103
- value: n,
104
- onChange: l,
105
- disabled: o = !1,
106
- error: r,
107
- onLoadMore: i,
108
- onSearch: c
109
- }) => {
110
- const { data: s = [], isLoading: g } = ge(), { formatMessage: y } = T(), k = () => {
111
- l({ target: { name: "role", value: "" } });
112
- }, v = (p) => {
113
- l({ target: { name: "role", value: p } });
114
- }, F = H(
115
- (p) => {
116
- const w = p.target.value;
117
- c && c(w);
118
- },
119
- [c]
120
- ), S = H(() => {
121
- i && !g && i();
122
- }, [i, g]);
123
- return /* @__PURE__ */ u(
124
- d.Root,
125
- {
126
- name: "role",
127
- hint: t(y, "domain.edit.form.role.hint"),
128
- error: r,
129
- children: [
130
- /* @__PURE__ */ e(d.Label, { children: t(y, "domain.edit.form.role.label") }),
131
- /* @__PURE__ */ e(
132
- K,
133
- {
134
- loading: g,
135
- hasMoreItems: !g,
136
- name: "role",
137
- disabled: o,
138
- value: n,
139
- onChange: v,
140
- placeholder: t(y, "domain.edit.form.role.placeholder"),
141
- onInputChange: F,
142
- onLoadMore: S,
143
- children: s.map((p) => /* @__PURE__ */ e(V, { value: p.id.toString(), children: p.name }, p.id))
144
- }
145
- ),
146
- n && s.length > 0 && /* @__PURE__ */ u(
147
- b,
148
- {
149
- paddingTop: 2,
150
- paddingBottom: 2,
151
- paddingLeft: 4,
152
- paddingRight: 4,
153
- hasRadius: !0,
154
- borderColor: "neutral200",
155
- background: "neutral0",
156
- justifyContent: "space-between",
157
- children: [
158
- /* @__PURE__ */ e(L, { textColor: "neutral800", fontWeight: "bold", children: s.find((p) => p.id.toString() === n)?.name }),
159
- o ? null : /* @__PURE__ */ e(f, { children: /* @__PURE__ */ e(
160
- $,
161
- {
162
- onClick: k,
163
- label: t(y, "domain.edit.form.role.remove"),
164
- variant: "ghost",
165
- size: "S",
166
- children: /* @__PURE__ */ e(se, {})
167
- }
168
- ) })
169
- ]
170
- }
171
- ),
172
- /* @__PURE__ */ e(d.Hint, {})
173
- ]
174
- }
175
- );
176
- }, J = {
177
- all: ["tokens"],
178
- lists: () => [...J.all, "list"]
179
- }, fe = () => A({
180
- queryKey: J.lists(),
181
- queryFn: () => M.getTokens(),
182
- staleTime: 10 * 60 * 1e3
183
- }), ye = ({
184
- value: n = [],
185
- onChange: l,
186
- disabled: o = !1,
187
- error: r
188
- }) => {
189
- const { data: i = [] } = fe(), { formatMessage: c } = T(), s = (g) => {
190
- const y = g.map((k) => Number(k));
191
- l({ target: { name: "tokens", value: y } });
192
- };
193
- return /* @__PURE__ */ u(
194
- d.Root,
195
- {
196
- name: "tokens",
197
- hint: t(c, "domain.edit.form.tokens.hint"),
198
- error: r,
199
- children: [
200
- /* @__PURE__ */ e(d.Label, { children: t(c, "domain.edit.form.tokens.label") }),
201
- /* @__PURE__ */ e(
202
- z,
203
- {
204
- withTags: !0,
205
- name: "tokens",
206
- disabled: o,
207
- value: n.map((g) => g.toString()),
208
- onChange: s,
209
- placeholder: t(c, "domain.edit.form.tokens.placeholder"),
210
- children: i.map((g) => /* @__PURE__ */ e(G, { value: g.id.toString(), children: g.name }, g.id.toString()))
211
- }
212
- ),
213
- /* @__PURE__ */ e(d.Hint, {})
214
- ]
215
- }
216
- );
217
- }, be = ({
218
- values: n,
219
- onChange: l,
220
- disabled: o,
221
- errors: r
222
- }) => {
223
- const { formatMessage: i } = T(), c = (s) => {
224
- l({ target: { name: "customFields", value: s } });
225
- };
226
- return /* @__PURE__ */ e(f, { background: "neutral0", padding: 8, shadow: "filterShadow", hasRadius: !0, width: "100%", children: /* @__PURE__ */ u(b, { direction: "column", alignItems: "stretch", gap: 6, children: [
227
- /* @__PURE__ */ u(b, { gap: 4, wrap: "wrap", children: [
228
- /* @__PURE__ */ e(f, { flex: "1", minWidth: "300px", children: /* @__PURE__ */ u(
229
- d.Root,
230
- {
231
- name: "name",
232
- required: !0,
233
- hint: t(i, "domain.edit.form.name.hint"),
234
- error: r.name,
235
- children: [
236
- /* @__PURE__ */ e(d.Label, { children: t(i, "domain.edit.form.name.label") }),
237
- /* @__PURE__ */ e(
238
- x,
239
- {
240
- disabled: o,
241
- name: "name",
242
- value: n.name,
243
- onChange: l,
244
- placeholder: t(i, "domain.edit.form.name.placeholder"),
245
- required: !0
246
- }
247
- ),
248
- /* @__PURE__ */ e(d.Hint, {}),
249
- /* @__PURE__ */ e(d.Error, {})
250
- ]
251
- }
252
- ) }),
253
- /* @__PURE__ */ e(f, { flex: "1", minWidth: "300px", children: /* @__PURE__ */ u(
254
- d.Root,
255
- {
256
- name: "code",
257
- required: !0,
258
- hint: t(i, "domain.edit.form.code.hint"),
259
- error: r.code,
260
- children: [
261
- /* @__PURE__ */ e(d.Label, { children: t(i, "domain.edit.form.code.label") }),
262
- /* @__PURE__ */ e(
263
- x,
264
- {
265
- disabled: o,
266
- name: "code",
267
- value: n.code,
268
- onChange: l,
269
- placeholder: t(i, "domain.edit.form.code.placeholder"),
270
- required: !0
271
- }
272
- ),
273
- /* @__PURE__ */ e(d.Hint, {}),
274
- /* @__PURE__ */ e(d.Error, {})
275
- ]
276
- }
277
- ) })
278
- ] }),
279
- /* @__PURE__ */ e(
280
- he,
281
- {
282
- value: n.logo,
283
- onChange: l,
284
- disabled: o,
285
- error: r.logo?.toString()
286
- }
287
- ),
288
- /* @__PURE__ */ u(b, { gap: 4, wrap: "wrap", children: [
289
- /* @__PURE__ */ e(f, { flex: "1", minWidth: "300px", children: /* @__PURE__ */ e(
290
- pe,
291
- {
292
- value: n.role,
293
- onChange: l,
294
- disabled: o,
295
- error: r.role?.toString()
296
- }
297
- ) }),
298
- /* @__PURE__ */ e(f, { flex: "1", minWidth: "300px", children: /* @__PURE__ */ e(
299
- ye,
300
- {
301
- value: n.tokens || [],
302
- onChange: l,
303
- disabled: o,
304
- error: r.tokens?.toString()
305
- }
306
- ) })
307
- ] }),
308
- /* @__PURE__ */ u(
309
- d.Root,
310
- {
311
- name: "damRootDirectory",
312
- hint: t(i, "domain.edit.form.damRootDirectory.hint"),
313
- error: r.damRootDirectory,
314
- children: [
315
- /* @__PURE__ */ e(d.Label, { children: t(i, "domain.edit.form.damRootDirectory.label") }),
316
- /* @__PURE__ */ e(
317
- x,
318
- {
319
- disabled: o,
320
- name: "damRootDirectory",
321
- value: n.damRootDirectory,
322
- onChange: l,
323
- placeholder: t(i, "domain.edit.form.damRootDirectory.placeholder")
324
- }
325
- ),
326
- /* @__PURE__ */ e(d.Hint, {}),
327
- /* @__PURE__ */ e(d.Error, {})
328
- ]
329
- }
330
- ),
331
- /* @__PURE__ */ u(
332
- d.Root,
333
- {
334
- name: "customFields",
335
- hint: t(i, "domain.edit.form.customFields.hint"),
336
- error: r.customFields,
337
- children: [
338
- /* @__PURE__ */ e(d.Label, { children: t(i, "domain.edit.form.customFields.label") }),
339
- /* @__PURE__ */ e(
340
- Q,
341
- {
342
- name: "customFields",
343
- value: n.customFields,
344
- onChange: c,
345
- minHeight: "200px"
346
- }
347
- ),
348
- /* @__PURE__ */ e(d.Hint, {})
349
- ]
350
- }
351
- )
352
- ] }) });
353
- }, Te = ({
354
- message: n = "Loading..."
355
- }) => /* @__PURE__ */ e(f, { padding: 8, textAlign: "center", children: /* @__PURE__ */ e(U, { children: n }) }), ke = () => ce({
356
- mutationFn: (n) => M.validateTenant(n),
357
- onError: (n) => {
358
- console.error("Tenant validation failed:", n);
359
- }
360
- });
361
- class Re {
362
- constructor(l) {
363
- this.inner = l, this.name = "ValidationError";
364
- }
365
- name;
366
- }
367
- const He = () => {
368
- const n = te(), { id: l } = ne(), o = l !== "new", r = o ? parseInt(l) : void 0, { toggleNotification: i } = Y(), { formatMessage: c } = T(), { data: s, isLoading: g } = ae(r), y = ke(), k = re(), v = de(), F = _.useMemo(
369
- () => ({
370
- name: s?.name || "",
371
- code: s?.code || "",
372
- role: s?.role?.id?.toString() || "",
373
- tokens: s?.tokens?.map((a) => a.id),
374
- damRootDirectory: s?.damRootDirectory || "",
375
- customFields: JSON.stringify(s?.customFields || {}, null, 2),
376
- logo: s?.logo || null
377
- }),
378
- [s]
379
- ), S = s?.code === "strapi-super-admin", p = async (a) => {
380
- try {
381
- let h = {};
382
- try {
383
- h = JSON.parse(a.customFields || "{}");
384
- } catch {
385
- i({
386
- type: "danger",
387
- message: t(c, "domain.edit.notifications.invalidJson")
388
- });
389
- return;
390
- }
391
- if (o && r) {
392
- const m = {
393
- ...a,
394
- role: a.role ? parseInt(a.role) : void 0,
395
- tokens: a.tokens || [],
396
- customFields: h,
397
- logo: a.logo || null
398
- };
399
- await v.mutateAsync({ id: r, data: m }), i({
400
- type: "success",
401
- message: t(c, "domain.edit.notifications.updated")
402
- });
403
- } else {
404
- const m = {
405
- ...a,
406
- role: a.role ? parseInt(a.role) : void 0,
407
- tokens: a.tokens || [],
408
- customFields: h,
409
- logo: a.logo || null
410
- }, R = await k.mutateAsync(m);
411
- i({
412
- type: "success",
413
- message: t(c, "domain.edit.notifications.created")
414
- }), n(`/settings/${I}/${R.id}`);
415
- }
416
- } catch (h) {
417
- i({
418
- type: "danger",
419
- message: h instanceof Error ? h.message : t(c, "domain.edit.notifications.saveError")
420
- });
421
- }
422
- }, w = async (a) => {
423
- const h = {};
424
- if (a.customFields)
425
- try {
426
- JSON.parse(a.customFields);
427
- } catch {
428
- h.customFields = t(c, "domain.edit.validation.invalidJson");
429
- }
430
- if (a.name || a.code)
431
- try {
432
- const m = {
433
- excludeId: r
434
- };
435
- a.name && (m.name = a.name), a.code && (m.code = a.code);
436
- const R = await y.mutateAsync(m);
437
- R.name && (h.name = R.name || "Name is not available"), R.code && (h.code = R.code || "Code is not available");
438
- } catch (m) {
439
- i({
440
- type: "danger",
441
- message: m instanceof Error ? m.message : m?.toString()
442
- });
443
- }
444
- if (!oe(h))
445
- throw new Re(
446
- Object.keys(h).map((m) => ({
447
- path: m,
448
- message: h[m]
449
- }))
450
- );
451
- return a;
452
- }, j = k.isPending || v.isPending;
453
- return g ? /* @__PURE__ */ e(Te, { message: t(c, "domain.edit.loading") }) : /* @__PURE__ */ u(E, { children: [
454
- /* @__PURE__ */ e(N.Title, { children: o ? t(c, "domain.edit.title.edit", {
455
- values: { name: s?.name || P }
456
- }) : t(c, "domain.edit.title.create") }),
457
- /* @__PURE__ */ e(N.Main, { children: /* @__PURE__ */ e(
458
- Z,
459
- {
460
- onSubmit: p,
461
- initialValues: F,
462
- validate: w,
463
- method: "POST",
464
- width: "auto",
465
- height: "auto",
466
- children: ({ values: a, onChange: h, errors: m }) => /* @__PURE__ */ u(E, { children: [
467
- /* @__PURE__ */ e(ue, { isEditing: o, tenantName: s?.name }),
468
- /* @__PURE__ */ e(O.Content, { children: /* @__PURE__ */ u(C.Root, { gap: 4, children: [
469
- /* @__PURE__ */ e(C.Item, { col: 9, children: /* @__PURE__ */ e(
470
- be,
471
- {
472
- values: a,
473
- onChange: h,
474
- disabled: S,
475
- errors: m
476
- }
477
- ) }),
478
- /* @__PURE__ */ e(C.Item, { col: 3, children: /* @__PURE__ */ e(
479
- me,
480
- {
481
- isEditing: o,
482
- isSaving: j,
483
- onCancel: () => n(`/settings/${I}`)
484
- }
485
- ) })
486
- ] }) })
487
- ] })
488
- }
489
- ) })
490
- ] });
491
- };
492
- export {
493
- He as default
494
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),p=require("@strapi/strapi/admin"),R=require("react"),f=require("react-intl"),k=require("react-router-dom"),B=require("remeda"),j=require("./index-Ck1YIRr4.js"),n=require("./useTenants-XMURO_eU.js"),w=require("@strapi/icons"),v=require("@tanstack/react-query"),S=require("./index-D9I-QR8y.js"),D=o=>o&&o.__esModule?o:{default:o},E=D(R),N=({isEditing:o,isSaving:d,onCancel:i})=>{const{formatMessage:r}=f.useIntl();return e.jsx(t.Flex,{justifyContent:"flex-start",gap:2,direction:"column",height:"100%",width:"100%",children:e.jsxs(t.Box,{background:"neutral0",padding:8,shadow:"filterShadow",hasRadius:!0,width:"100%",children:[e.jsx(t.Typography,{variant:"sigma",textTransform:"uppercase",textColor:"neutral600",tag:"h2",marginBottom:4,children:n.getMessage(r,"domain.edit.actions.entry")}),e.jsxs(t.Flex,{direction:"column",gap:2,children:[e.jsx(n.CheckPermissions,{permissions:o?j.permissions.admin.edit:j.permissions.admin.create,children:e.jsx(t.Button,{type:"submit",loading:d,width:"100%",children:o?n.getMessage(r,"domain.edit.actions.update"):n.getMessage(r,"domain.edit.actions.create")})}),e.jsx(t.Button,{variant:"secondary",onClick:i,width:"100%",children:n.getMessage(r,"common.cancel")})]})]})})},H=({isEditing:o,tenantName:d})=>{const{formatMessage:i}=f.useIntl();return e.jsx(p.Layouts.Header,{title:e.jsx(t.Box,{padding:6,children:e.jsxs(t.Flex,{gap:2,direction:"column",alignItems:"flex-start",children:[e.jsx(t.Link,{variant:"tertiary",tag:k.NavLink,startIcon:e.jsx(w.ArrowLeft,{}),to:`/settings/${j.pluginId}`,children:n.getMessage(i,"common.back")}),e.jsx(t.Typography,{variant:"alpha",fontWeight:"bold",marginTop:2,children:o?d||n.getMessage(i,"domain.edit.title.edit",{values:{name:j.modelId}}):n.getMessage(i,"domain.edit.title.create")})]})}),as:"h2"})},P=({disabled:o=!1,error:d})=>{const{formatMessage:i}=f.useIntl(),r=p.useStrapiApp("CustomMediaInput",s=>s.fields?.media||{});return r?e.jsxs(t.Field.Root,{name:"logo",hint:n.getMessage(i,"domain.edit.form.logo.hint"),error:d,children:[e.jsx(r,{label:"Logo",name:"logo",disabled:o,attribute:{allowedTypes:["images"],multiple:!1}}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]}):null},L={all:["roles"],lists:()=>[...L.all,"list"]},O=()=>v.useQuery({queryKey:L.lists(),queryFn:()=>S.api.getRoles(),staleTime:10*60*1e3}),A=({value:o,onChange:d,disabled:i=!1,error:r,onLoadMore:s,onSearch:c})=>{const{data:l=[],isLoading:u}=O(),{formatMessage:x}=f.useIntl(),y=()=>{d({target:{name:"role",value:""}})},M=h=>{d({target:{name:"role",value:h}})},T=R.useCallback(h=>{const I=h.target.value;c&&c(I)},[c]),b=R.useCallback(()=>{s&&!u&&s()},[s,u]);return e.jsxs(t.Field.Root,{name:"role",hint:n.getMessage(x,"domain.edit.form.role.hint"),error:r,children:[e.jsx(t.Field.Label,{children:n.getMessage(x,"domain.edit.form.role.label")}),e.jsx(t.Combobox,{loading:u,hasMoreItems:!u,name:"role",disabled:i,value:o,onChange:M,placeholder:n.getMessage(x,"domain.edit.form.role.placeholder"),onInputChange:T,onLoadMore:b,children:l.map(h=>e.jsx(t.ComboboxOption,{value:h.id.toString(),children:h.name},h.id))}),o&&l.length>0&&e.jsxs(t.Flex,{paddingTop:2,paddingBottom:2,paddingLeft:4,paddingRight:4,hasRadius:!0,borderColor:"neutral200",background:"neutral0",justifyContent:"space-between",children:[e.jsx(t.Typography,{textColor:"neutral800",fontWeight:"bold",children:l.find(h=>h.id.toString()===o)?.name}),i?null:e.jsx(t.Box,{children:e.jsx(t.IconButton,{onClick:y,label:n.getMessage(x,"domain.edit.form.role.remove"),variant:"ghost",size:"S",children:e.jsx(w.Cross,{})})})]}),e.jsx(t.Field.Hint,{})]})},q={all:["tokens"],lists:()=>[...q.all,"list"]},W=()=>v.useQuery({queryKey:q.lists(),queryFn:()=>S.api.getTokens(),staleTime:10*60*1e3}),J=({value:o=[],onChange:d,disabled:i=!1,error:r})=>{const{data:s=[]}=W(),{formatMessage:c}=f.useIntl(),l=u=>{const x=u.map(y=>Number(y));d({target:{name:"tokens",value:x}})};return e.jsxs(t.Field.Root,{name:"tokens",hint:n.getMessage(c,"domain.edit.form.tokens.hint"),error:r,children:[e.jsx(t.Field.Label,{children:n.getMessage(c,"domain.edit.form.tokens.label")}),e.jsx(t.MultiSelect,{withTags:!0,name:"tokens",disabled:i,value:o.map(u=>u.toString()),onChange:l,placeholder:n.getMessage(c,"domain.edit.form.tokens.placeholder"),children:s.map(u=>e.jsx(t.MultiSelectOption,{value:u.id.toString(),children:u.name},u.id.toString()))}),e.jsx(t.Field.Hint,{})]})},_=({values:o,onChange:d,disabled:i,errors:r})=>{const{formatMessage:s}=f.useIntl(),c=l=>{d({target:{name:"customFields",value:l}})};return e.jsx(t.Box,{background:"neutral0",padding:8,shadow:"filterShadow",hasRadius:!0,width:"100%",children:e.jsxs(t.Flex,{direction:"column",alignItems:"stretch",gap:6,children:[e.jsxs(t.Flex,{gap:4,wrap:"wrap",children:[e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsxs(t.Field.Root,{name:"name",required:!0,hint:n.getMessage(s,"domain.edit.form.name.hint"),error:r.name,children:[e.jsx(t.Field.Label,{children:n.getMessage(s,"domain.edit.form.name.label")}),e.jsx(t.TextInput,{disabled:i,name:"name",value:o.name,onChange:d,placeholder:n.getMessage(s,"domain.edit.form.name.placeholder"),required:!0}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]})}),e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsxs(t.Field.Root,{name:"code",required:!0,hint:n.getMessage(s,"domain.edit.form.code.hint"),error:r.code,children:[e.jsx(t.Field.Label,{children:n.getMessage(s,"domain.edit.form.code.label")}),e.jsx(t.TextInput,{disabled:i,name:"code",value:o.code,onChange:d,placeholder:n.getMessage(s,"domain.edit.form.code.placeholder"),required:!0}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]})})]}),e.jsx(P,{value:o.logo,onChange:d,disabled:i,error:r.logo?.toString()}),e.jsxs(t.Flex,{gap:4,wrap:"wrap",children:[e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsx(A,{value:o.role,onChange:d,disabled:i,error:r.role?.toString()})}),e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsx(J,{value:o.tokens||[],onChange:d,disabled:i,error:r.tokens?.toString()})})]}),e.jsxs(t.Field.Root,{name:"damRootDirectory",hint:n.getMessage(s,"domain.edit.form.damRootDirectory.hint"),error:r.damRootDirectory,children:[e.jsx(t.Field.Label,{children:n.getMessage(s,"domain.edit.form.damRootDirectory.label")}),e.jsx(t.TextInput,{disabled:i,name:"damRootDirectory",value:o.damRootDirectory,onChange:d,placeholder:n.getMessage(s,"domain.edit.form.damRootDirectory.placeholder")}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]}),e.jsxs(t.Field.Root,{name:"customFields",hint:n.getMessage(s,"domain.edit.form.customFields.hint"),error:r.customFields,children:[e.jsx(t.Field.Label,{children:n.getMessage(s,"domain.edit.form.customFields.label")}),e.jsx(t.JSONInput,{name:"customFields",value:o.customFields,onChange:c,minHeight:"200px"}),e.jsx(t.Field.Hint,{})]})]})})},$=({message:o="Loading..."})=>e.jsx(t.Box,{padding:8,textAlign:"center",children:e.jsx(t.Loader,{children:o})}),K=()=>v.useMutation({mutationFn:o=>S.api.validateTenant(o),onError:o=>{console.error("Tenant validation failed:",o)}});class V{constructor(d){this.inner=d,this.name="ValidationError"}name}const G=()=>{const o=k.useNavigate(),{id:d}=k.useParams(),i=d!=="new",r=i?parseInt(d):void 0,{toggleNotification:s}=p.useNotification(),{formatMessage:c}=f.useIntl(),{data:l,isLoading:u}=n.useTenant(r),x=K(),y=n.useCreateTenant(),M=n.useUpdateTenant(),T=E.default.useMemo(()=>({name:l?.name||"",code:l?.code||"",role:l?.role?.id?.toString()||"",tokens:l?.tokens?.map(a=>a.id),damRootDirectory:l?.damRootDirectory||"",customFields:JSON.stringify(l?.customFields||{},null,2),logo:l?.logo||null}),[l]),b=l?.code==="strapi-super-admin",h=async a=>{try{let g={};try{g=JSON.parse(a.customFields||"{}")}catch{s({type:"danger",message:n.getMessage(c,"domain.edit.notifications.invalidJson")});return}if(i&&r){const m={...a,role:a.role?parseInt(a.role):void 0,tokens:a.tokens||[],customFields:g,logo:a.logo||null};await M.mutateAsync({id:r,data:m}),s({type:"success",message:n.getMessage(c,"domain.edit.notifications.updated")})}else{const m={...a,role:a.role?parseInt(a.role):void 0,tokens:a.tokens||[],customFields:g,logo:a.logo||null},F=await y.mutateAsync(m);s({type:"success",message:n.getMessage(c,"domain.edit.notifications.created")}),o(`/settings/${j.pluginId}/${F.id}`)}}catch(g){s({type:"danger",message:g instanceof Error?g.message:n.getMessage(c,"domain.edit.notifications.saveError")})}},I=async a=>{const g={};if(a.customFields)try{JSON.parse(a.customFields)}catch{g.customFields=n.getMessage(c,"domain.edit.validation.invalidJson")}if(a.name||a.code)try{const m={excludeId:r};a.name&&(m.name=a.name),a.code&&(m.code=a.code);const F=await x.mutateAsync(m);F.name&&(g.name=F.name||"Name is not available"),F.code&&(g.code=F.code||"Code is not available")}catch(m){s({type:"danger",message:m instanceof Error?m.message:m?.toString()})}if(!B.isEmpty(g))throw new V(Object.keys(g).map(m=>({path:m,message:g[m]})));return a},C=y.isPending||M.isPending;return u?e.jsx($,{message:n.getMessage(c,"domain.edit.loading")}):e.jsxs(e.Fragment,{children:[e.jsx(p.Page.Title,{children:i?n.getMessage(c,"domain.edit.title.edit",{values:{name:l?.name||j.modelId}}):n.getMessage(c,"domain.edit.title.create")}),e.jsx(p.Page.Main,{children:e.jsx(p.Form,{onSubmit:h,initialValues:T,validate:I,method:"POST",width:"auto",height:"auto",children:({values:a,onChange:g,errors:m})=>e.jsxs(e.Fragment,{children:[e.jsx(H,{isEditing:i,tenantName:l?.name}),e.jsx(p.Layouts.Content,{children:e.jsxs(t.Grid.Root,{gap:4,children:[e.jsx(t.Grid.Item,{col:9,children:e.jsx(_,{values:a,onChange:g,disabled:b,errors:m})}),e.jsx(t.Grid.Item,{col:3,children:e.jsx(N,{isEditing:i,isSaving:C,onCancel:()=>o(`/settings/${j.pluginId}`)})})]})})]})})})]})};exports.default=G;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),m=require("@strapi/icons"),r=require("@strapi/strapi/admin"),D=require("react"),k=require("react-intl"),v=require("react-router-dom"),x=require("./index-Ck1YIRr4.js"),n=require("./useTenants-XMURO_eU.js"),W=require("styled-components"),Q=require("@tanstack/react-query"),H=require("./index-D9I-QR8y.js"),P=s=>s&&s.__esModule?s:{default:s},O=P(D),K=P(W),U=({isOpen:s,onClose:a,onConfirm:c,target:l})=>e.jsx(t.Dialog.Root,{open:s,onOpenChange:a,children:e.jsxs(t.Dialog.Content,{children:[e.jsx(t.Dialog.Header,{children:"Confirmation"}),e.jsx(t.Dialog.Body,{icon:e.jsx(m.Trash,{}),children:e.jsx(t.Dialog.Description,{textAlign:"center",children:e.jsxs(t.Flex,{gap:2,direction:"column",children:[e.jsx(m.WarningCircle,{fill:"danger600",width:"24",height:"24"}),"Are you sure you want to delete this ",l,"?",e.jsx("br",{}),"All your modifications will be lost"]})})}),e.jsxs(t.Dialog.Footer,{children:[e.jsx(t.Dialog.Action,{children:e.jsx(t.Button,{fullWidth:!0,onClick:a,variant:"tertiary",size:"S",children:e.jsx(t.Typography,{variant:"omega",children:"Cancel"})})}),e.jsx(t.Dialog.Action,{children:e.jsx(t.Button,{fullWidth:!0,onClick:c,variant:"danger",size:"S",children:e.jsx(t.Typography,{variant:"omega",children:"Confirm"})})})]})]})}),G=({isDisplayed:s,direction:a})=>s?a==="asc"?e.jsx(m.ArrowUp,{}):e.jsx(m.ArrowDown,{}):null,b=({label:s,field:a,sort:c,onSort:l})=>{const[d,h]=c.split(":");return e.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer"},onClick:()=>l(a)(h==="asc"?"desc":"asc"),children:[e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:s}),e.jsx("span",{style:{marginLeft:4},children:e.jsx(G,{isDisplayed:a===d,direction:h})})]})},J=K.default(t.Tr)(()=>({cursor:"pointer"})),V=({tenant:s,selectedTenants:a,handleSelectTenant:c,onDeleteTenant:l,isDeletePending:d=!1})=>{const h=v.useNavigate(),{formatMessage:i}=k.useIntl(),y=j=>()=>h(`/settings/${x.pluginId}/${x.modelRoute}/${j.id}`);return e.jsxs(J,{onClick:y(s),children:[e.jsx(t.Td,{children:e.jsx(t.Checkbox,{checked:a.includes(s.id),onCheckedChange:j=>c(s.id,j)})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:s.id})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:s.name})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{textColor:"neutral800",children:s.code})}),e.jsx(t.Td,{children:s.role?e.jsx(t.Badge,{textColor:"neutral800",backgroundColor:"neutral100",children:s.role.name}):e.jsx(t.Typography,{textColor:"neutral600",children:"-"})}),e.jsx(t.Td,{children:e.jsxs(t.Flex,{gap:1,children:[e.jsx(n.CheckPermissions,{permissions:x.permissions.admin.edit,children:e.jsx(t.IconButton,{onClick:y(s),label:n.getMessage(i,"common.edit"),children:e.jsx(m.Pencil,{})})}),e.jsx(n.CheckPermissions,{permissions:x.permissions.admin.delete,children:e.jsx(t.IconButton,{onClick:l(s),label:n.getMessage(i,"common.delete"),disabled:d,children:e.jsx(m.Trash,{})})})]})})]})},X=()=>Q.useQuery({queryKey:["multi-domain-settings"],queryFn:()=>H.api.getSettings(),staleTime:2*60*1e3}),Y=()=>{const s=v.useNavigate(),{toggleNotification:a}=r.useNotification(),[c,l]=D.useState([]),[d,h]=D.useState(),{formatMessage:i}=k.useIntl(),y=n.useDeleteTenant(),{data:j,isLoading:A}=X(),[{query:p},w]=r.useQueryParams({sort:"name:asc",_q:"",page:1,pageSize:10}),{sort:f,_q:L,page:I,pageSize:R}={...p,sort:p.sort||"name:asc",_q:p._q||"",page:p.page||1,pageSize:p.pageSize||10},{data:q,isLoading:_,error:T}=n.useTenants({sort:f,search:L,page:I,pageSize:R}),u=q?.results||[],C=q?.pagination||{pageCount:1,total:0};O.default.useEffect(()=>{T&&a({type:"danger",message:T instanceof Error?T.message:"An error occurred while fetching tenants"})},[T,a]);const B=o=>{l(o?u.map(g=>g.id):[])},$=(o,g)=>{l(g?M=>[...M,o]:M=>M.filter(N=>N!==o))},S=o=>g=>{w({...p,sort:`${o}:${g}`})},z=o=>async g=>{g.stopPropagation(),h(o)},F=async()=>{if(d)try{await y.mutateAsync(d.id),a({type:"success",message:n.getMessage(i,"domain.notifications.deleted",{values:{name:d.name}})}),h(void 0),l(o=>o.filter(g=>g!==d.id))}catch{a({type:"danger",message:n.getMessage(i,"domain.notifications.deleteError")})}},E=()=>{h(void 0)};return _||A?e.jsx(r.Page.Main,{children:e.jsx(r.Layouts.Content,{children:e.jsx(t.Loader,{children:n.getMessage(i,"domain.list.loading")})})}):e.jsxs(e.Fragment,{children:[e.jsx(r.Page.Title,{children:"Tenants"}),e.jsxs(r.Page.Main,{children:[e.jsx(r.Layouts.Header,{title:n.getMessage(i,"domain.list.title"),subtitle:n.getMessage(i,"domain.list.subtitle",{values:{count:u.length}}),as:"h2"}),e.jsx(r.Layouts.Action,{startActions:e.jsx(e.Fragment,{children:e.jsx(r.SearchInput,{label:n.getMessage(i,"domain.list.search",{defaultMessage:"Search domains"})})}),endActions:e.jsx(n.CheckPermissions,{permissions:x.permissions.admin.create,children:e.jsx(t.Button,{startIcon:e.jsx(m.Plus,{}),onClick:()=>{if(!j||j.features.domains<=C.total)return a({type:"warning",message:n.getMessage(i,"domain.list.limitReached",{values:{limit:j?.features.domains||0}})});s(`/settings/${x.pluginId}/${x.modelRoute}/new`)},children:n.getMessage(i,"common.create")})})}),e.jsx(r.Layouts.Content,{children:u.length===0?e.jsx(t.EmptyStateLayout,{icon:e.jsx(m.Search,{}),content:n.getMessage(i,"domain.list.emptyState",{defaultMessage:"No domains found matching your search criteria"})}):e.jsxs(e.Fragment,{children:[e.jsxs(t.Table,{colCount:6,rowCount:u.length+1,children:[e.jsx(t.Thead,{children:e.jsxs(t.Tr,{children:[e.jsx(t.Th,{children:e.jsx(t.Checkbox,{checked:c.length===u.length&&u.length>0,indeterminate:c.length>0&&c.length<u.length,onCheckedChange:B})}),e.jsx(t.Th,{children:e.jsx(b,{label:n.getMessage(i,"domain.list.table.headers.id"),field:"id",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(b,{label:n.getMessage(i,"domain.list.table.headers.name"),field:"name",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(b,{label:n.getMessage(i,"domain.list.table.headers.code"),field:"code",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:n.getMessage(i,"domain.list.table.headers.role")})}),e.jsx(t.Th,{children:e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:n.getMessage(i,"domain.list.table.headers.actions")})})]})}),e.jsx(t.Tbody,{children:u.map(o=>e.jsx(V,{tenant:o,selectedTenants:c,handleSelectTenant:$,onDeleteTenant:z},o.id))})]}),e.jsx(t.Box,{paddingTop:4,children:e.jsxs(r.Pagination.Root,{pageCount:C.pageCount,total:C.total,children:[e.jsx(r.Pagination.PageSize,{}),e.jsx(r.Pagination.Links,{})]})})]})})]}),e.jsx(U,{isOpen:!!d,onClose:E,onConfirm:F,target:d?.name||x.modelId})]})};exports.default=Y;