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