@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,331 @@
|
|
|
1
|
+
import { toSnakeCase as W, funnel as V } from "remeda";
|
|
2
|
+
import { z as J } from "zod";
|
|
3
|
+
import { jsx as o, jsxs as m } from "react/jsx-runtime";
|
|
4
|
+
import { unstable_useContentManagerContext as G, getFetchClient as K } from "@strapi/strapi/admin";
|
|
5
|
+
import X, { useRef as Y, useEffect as Z, useState as x } from "react";
|
|
6
|
+
import { CookiesProvider as R, useCookies as D } from "react-cookie";
|
|
7
|
+
import { Avatar as M, Modal as h, Box as k, Field as L, Searchbar as ee, EmptyStateLayout as te, Table as ne, Thead as oe, Tr as P, Th as C, Typography as S, Tbody as ie, Td as T, Checkbox as ae, Button as I, DesignSystemProvider as re, lightTheme as se, darkTheme as ce } from "@strapi/design-system";
|
|
8
|
+
import { createRoot as le } from "react-dom/client";
|
|
9
|
+
import { Search as de } from "@strapi/icons";
|
|
10
|
+
import { QueryClient as ue, QueryClientProvider as me } from "@tanstack/react-query";
|
|
11
|
+
const he = "@sensinum/strapi-plugin-multi-domain", pe = "5.2.0", ge = "https://www.sensinum.com/contact", fe = "hello@sensinum.com", ye = {
|
|
12
|
+
name: "multi-domain"
|
|
13
|
+
}, je = {
|
|
14
|
+
name: he,
|
|
15
|
+
version: pe,
|
|
16
|
+
homepage: ge,
|
|
17
|
+
email: fe
|
|
18
|
+
}, a = J.literal("multi-domain").parse(ye.name);
|
|
19
|
+
W(a);
|
|
20
|
+
const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
21
|
+
read: "read",
|
|
22
|
+
change: "change",
|
|
23
|
+
create: "create",
|
|
24
|
+
delete: "delete"
|
|
25
|
+
}, b = (e) => `plugin::${a}.${H[e]}`, N = {
|
|
26
|
+
admin: {
|
|
27
|
+
access: Object.keys(H).map((e) => ({
|
|
28
|
+
action: b(e),
|
|
29
|
+
subject: null
|
|
30
|
+
})),
|
|
31
|
+
create: [{ action: b("create"), subject: null }],
|
|
32
|
+
edit: [{ action: b("change"), subject: null }],
|
|
33
|
+
delete: [{ action: b("delete"), subject: null }]
|
|
34
|
+
}
|
|
35
|
+
}, f = `data-${g}-initialized`, we = "strapi-super-admin", U = (e) => e?.code === we, Ce = (e) => {
|
|
36
|
+
const t = `/admin/content-manager/collection-types/${e}/create`, n = document.querySelector(`a[href*="${t}"]`);
|
|
37
|
+
n && (n.style.display = "none");
|
|
38
|
+
}, Se = () => {
|
|
39
|
+
const [{ [p]: e }] = D([p]), t = U(e), { slug: n } = G();
|
|
40
|
+
return X.useEffect(() => {
|
|
41
|
+
(t || !e) && Ce(n);
|
|
42
|
+
}, [t, e, n]), null;
|
|
43
|
+
}, Te = () => /* @__PURE__ */ o(R, { children: /* @__PURE__ */ o(Se, {}) }), ve = ({ setPlugin: e }) => {
|
|
44
|
+
const t = Y(e);
|
|
45
|
+
return Z(() => {
|
|
46
|
+
t.current(a);
|
|
47
|
+
}, []), null;
|
|
48
|
+
}, B = {
|
|
49
|
+
en: () => import("./en-Cf69p5po.mjs")
|
|
50
|
+
}, q = (e, t) => {
|
|
51
|
+
if (!e)
|
|
52
|
+
throw new TypeError("Prefix can't be empty");
|
|
53
|
+
return Object.keys(t).reduce(
|
|
54
|
+
(n, i) => (n[`${e}.${i}`] = t[i], n),
|
|
55
|
+
{}
|
|
56
|
+
);
|
|
57
|
+
}, A = (e, t = "") => Object.keys(e).reduce((n, i) => {
|
|
58
|
+
const r = t.length ? `${t}.` : "";
|
|
59
|
+
return typeof e[i] == "object" && e[i] !== null && !Array.isArray(e[i]) ? Object.assign(n, A(e[i], r + i)) : n[r + i] = e[i], n;
|
|
60
|
+
}, {}), Ee = ({ onClose: e, userData: t }) => {
|
|
61
|
+
const [{ [p]: n }, i] = D([p]), [r, d] = x(""), [s, u] = x(n || null), l = (t[E] || []).filter(
|
|
62
|
+
(c) => c.name.toLowerCase().includes(r.toLowerCase())
|
|
63
|
+
), y = (c) => {
|
|
64
|
+
u(s?.id === c.id ? null : c);
|
|
65
|
+
}, Q = () => {
|
|
66
|
+
s && (i(p, JSON.stringify(s), {
|
|
67
|
+
path: "/",
|
|
68
|
+
maxAge: 60 * 60 * 24 * 30,
|
|
69
|
+
// 30 days
|
|
70
|
+
domain: window.location.hostname
|
|
71
|
+
}), window.location.reload());
|
|
72
|
+
};
|
|
73
|
+
return console.log("Avatar", M), /* @__PURE__ */ o(h.Root, { defaultOpen: !0, onOpenChange: e, children: /* @__PURE__ */ m(h.Content, { children: [
|
|
74
|
+
/* @__PURE__ */ o(h.Header, { children: /* @__PURE__ */ o(h.Title, { children: "Select Domain" }) }),
|
|
75
|
+
/* @__PURE__ */ m(h.Body, { children: [
|
|
76
|
+
/* @__PURE__ */ o(k, { paddingBottom: 4, children: /* @__PURE__ */ m(L.Root, { name: "tenant-search", children: [
|
|
77
|
+
/* @__PURE__ */ o(L.Label, { children: "Search domains" }),
|
|
78
|
+
/* @__PURE__ */ o(
|
|
79
|
+
ee,
|
|
80
|
+
{
|
|
81
|
+
name: "tenant-search",
|
|
82
|
+
onClear: () => d(""),
|
|
83
|
+
value: r,
|
|
84
|
+
onChange: (c) => d(c.target.value),
|
|
85
|
+
placeholder: "Search domains...",
|
|
86
|
+
size: "S"
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }) }),
|
|
90
|
+
l.length === 0 ? /* @__PURE__ */ o(
|
|
91
|
+
te,
|
|
92
|
+
{
|
|
93
|
+
icon: /* @__PURE__ */ o(de, {}),
|
|
94
|
+
content: "No domains found matching your search criteria"
|
|
95
|
+
}
|
|
96
|
+
) : /* @__PURE__ */ o(k, { maxHeight: "400px", overflow: "auto", children: /* @__PURE__ */ m(ne, { colCount: 2, rowCount: l.length + 1, children: [
|
|
97
|
+
/* @__PURE__ */ o(oe, { children: /* @__PURE__ */ m(P, { children: [
|
|
98
|
+
/* @__PURE__ */ o(C, { width: "60px", children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Select" }) }),
|
|
99
|
+
/* @__PURE__ */ o(C, { width: "40px" }),
|
|
100
|
+
/* @__PURE__ */ o(C, { children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Domain name" }) })
|
|
101
|
+
] }) }),
|
|
102
|
+
/* @__PURE__ */ o(ie, { children: l.map((c) => /* @__PURE__ */ m(P, { children: [
|
|
103
|
+
/* @__PURE__ */ o(T, { width: "60px", children: /* @__PURE__ */ o(
|
|
104
|
+
ae,
|
|
105
|
+
{
|
|
106
|
+
checked: s?.id === c.id,
|
|
107
|
+
onCheckedChange: () => y(c),
|
|
108
|
+
name: `tenant-${c.id}`
|
|
109
|
+
}
|
|
110
|
+
) }),
|
|
111
|
+
/* @__PURE__ */ o(T, { width: "40px", children: c.logo?.url && /* @__PURE__ */ o(M.Item, { src: c.logo.url, alt: c.name, preview: !1 }) }),
|
|
112
|
+
/* @__PURE__ */ o(T, { children: /* @__PURE__ */ o(S, { fontWeight: "semiBold", textColor: "neutral800", children: c.name }) })
|
|
113
|
+
] }, c.id)) })
|
|
114
|
+
] }) })
|
|
115
|
+
] }),
|
|
116
|
+
/* @__PURE__ */ m(h.Footer, { children: [
|
|
117
|
+
/* @__PURE__ */ o(h.Close, { children: /* @__PURE__ */ o(I, { onClick: e, variant: "tertiary", children: "Cancel" }) }),
|
|
118
|
+
/* @__PURE__ */ o(I, { onClick: Q, disabled: !s, children: "Select domain" })
|
|
119
|
+
] })
|
|
120
|
+
] }) });
|
|
121
|
+
}, Ae = new ue({
|
|
122
|
+
defaultOptions: {
|
|
123
|
+
queries: {
|
|
124
|
+
retry: !1,
|
|
125
|
+
refetchOnWindowFocus: !1
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}), $e = (e, t, n, i) => {
|
|
129
|
+
const r = le(e), d = () => {
|
|
130
|
+
document.body.removeAttribute("style"), r.unmount(), setTimeout(() => {
|
|
131
|
+
document.body.style.pointerEvents = "auto";
|
|
132
|
+
}, 0);
|
|
133
|
+
};
|
|
134
|
+
return t.remove(), r.render(
|
|
135
|
+
/* @__PURE__ */ o(re, { theme: i === "light" ? se : ce, children: /* @__PURE__ */ o(me, { client: Ae, children: /* @__PURE__ */ o(R, { children: /* @__PURE__ */ o(Ee, { onClose: d, userData: n }) }) }) })
|
|
136
|
+
);
|
|
137
|
+
}, w = (e, t) => new Promise((n, i) => {
|
|
138
|
+
const s = (u = 0) => {
|
|
139
|
+
if (u > 50) {
|
|
140
|
+
i(new Error("Button not found after 50 attempts"));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const l = (t || document).querySelector(e);
|
|
144
|
+
if (l) {
|
|
145
|
+
n(l);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setTimeout(() => s(u + 1), 250);
|
|
149
|
+
};
|
|
150
|
+
s();
|
|
151
|
+
}), j = () => {
|
|
152
|
+
try {
|
|
153
|
+
const t = document.cookie.split(";").find((n) => n.trim().startsWith(`${p}=`));
|
|
154
|
+
if (t) {
|
|
155
|
+
const n = t.split("=").at(1);
|
|
156
|
+
if (!n)
|
|
157
|
+
return null;
|
|
158
|
+
const i = decodeURIComponent(n);
|
|
159
|
+
return JSON.parse(i);
|
|
160
|
+
}
|
|
161
|
+
} catch (e) {
|
|
162
|
+
console.error("Error parsing tenant cookie:", e);
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}, xe = (e) => {
|
|
166
|
+
const t = e.firstChild, n = t?.lastChild?.cloneNode(!0);
|
|
167
|
+
if (t && n instanceof HTMLElement) {
|
|
168
|
+
const i = n.firstChild;
|
|
169
|
+
i && n.replaceChildren(i);
|
|
170
|
+
const r = n.querySelector("span");
|
|
171
|
+
if (r) {
|
|
172
|
+
const d = j();
|
|
173
|
+
r.innerText = d ? `${g.toUpperCase()}: ${d.name}` : `No ${g} selected`;
|
|
174
|
+
}
|
|
175
|
+
n.style.paddingTop = "1rem", t.appendChild(n);
|
|
176
|
+
}
|
|
177
|
+
}, $ = async () => {
|
|
178
|
+
try {
|
|
179
|
+
const e = K(), {
|
|
180
|
+
data: { data: t }
|
|
181
|
+
} = await e.get("/admin/users/me");
|
|
182
|
+
return t;
|
|
183
|
+
} catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}, F = async () => {
|
|
187
|
+
const e = await $(), t = document.createElement("div");
|
|
188
|
+
document.body.appendChild(t);
|
|
189
|
+
const n = await w('nav button[aria-haspopup="menu"]'), i = "aria-expanded";
|
|
190
|
+
new MutationObserver(async (d) => {
|
|
191
|
+
if (d.some((s) => s.attributeName === i) && n.getAttribute(i) === "true") {
|
|
192
|
+
const s = await w("[data-radix-menu-content]");
|
|
193
|
+
if (!(s instanceof HTMLElement))
|
|
194
|
+
return;
|
|
195
|
+
xe(s);
|
|
196
|
+
const u = await w('[role="menuitem"]', s), l = u.cloneNode(!0);
|
|
197
|
+
if (e?.[E] && e?.[E].length > 1) {
|
|
198
|
+
if (!(l instanceof HTMLElement))
|
|
199
|
+
return;
|
|
200
|
+
l.querySelector("span").innerText = `Select ${g}`, l.addEventListener("mouseenter", function() {
|
|
201
|
+
this.setAttribute("data-highlighted", "true");
|
|
202
|
+
}), l.addEventListener("mouseleave", function() {
|
|
203
|
+
this.removeAttribute("data-highlighted");
|
|
204
|
+
}), l.addEventListener("click", (y) => {
|
|
205
|
+
y.preventDefault(), y.stopPropagation(), $e(
|
|
206
|
+
t,
|
|
207
|
+
s,
|
|
208
|
+
e,
|
|
209
|
+
localStorage.getItem("STRAPI_THEME") || "dark"
|
|
210
|
+
);
|
|
211
|
+
}), u.insertAdjacentElement("afterend", l);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}).observe(n, {
|
|
215
|
+
attributes: !0
|
|
216
|
+
});
|
|
217
|
+
}, _ = () => window.location.pathname === "/admin/auth/login", Me = () => window.location.pathname.startsWith("/admin/plugins/upload"), ke = () => {
|
|
218
|
+
const e = j(), t = document.querySelector('[data-strapi-header="true"]');
|
|
219
|
+
if (!e || U(e)) {
|
|
220
|
+
const n = t?.querySelectorAll("button");
|
|
221
|
+
n && n.forEach((i) => {
|
|
222
|
+
i.style.display = "none";
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}, O = V(ke, {
|
|
226
|
+
minQuietPeriodMs: 250
|
|
227
|
+
}), z = async () => {
|
|
228
|
+
const e = await w('nav ul > li a[href="/admin/plugins/upload"]');
|
|
229
|
+
e && e.addEventListener("click", () => {
|
|
230
|
+
O.call();
|
|
231
|
+
}), Me() && O.call();
|
|
232
|
+
}, v = async () => {
|
|
233
|
+
if (_()) {
|
|
234
|
+
document.body.removeAttribute(f);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (await $()) {
|
|
238
|
+
document.querySelector(`[${f}]`) || (await Promise.all([F(), z()]), document.body.setAttribute(f, "true"));
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
document.body.removeAttribute(f);
|
|
242
|
+
}, Le = async () => {
|
|
243
|
+
_() || !await $() || (document.body.setAttribute(f, "true"), await Promise.all([F(), z()]));
|
|
244
|
+
}, Fe = {
|
|
245
|
+
register(e) {
|
|
246
|
+
e.registerPlugin({
|
|
247
|
+
id: a,
|
|
248
|
+
initializer: ve,
|
|
249
|
+
isReady: !1,
|
|
250
|
+
name: a
|
|
251
|
+
}), e.customFields.register({
|
|
252
|
+
name: `unique-by-${g}`,
|
|
253
|
+
pluginId: a,
|
|
254
|
+
type: "string",
|
|
255
|
+
intlLabel: {
|
|
256
|
+
id: `${a}.custom-fields.unique-by-domain.label`,
|
|
257
|
+
defaultMessage: "Unique by domain"
|
|
258
|
+
},
|
|
259
|
+
intlDescription: {
|
|
260
|
+
id: `${a}.custom-fields.unique-by-tenant.description`,
|
|
261
|
+
defaultMessage: "Ensures the value is unique within the domain."
|
|
262
|
+
},
|
|
263
|
+
components: {
|
|
264
|
+
Input: () => import("./TenantCustomField-B9Ntpj-S.mjs")
|
|
265
|
+
}
|
|
266
|
+
}), e.router.addSettingsLink({
|
|
267
|
+
id: `${a}.settings`,
|
|
268
|
+
intlLabel: {
|
|
269
|
+
id: `${a}.settings.label`,
|
|
270
|
+
defaultMessage: "Multi-Domain Settings"
|
|
271
|
+
},
|
|
272
|
+
links: [
|
|
273
|
+
{
|
|
274
|
+
id: `${a}.settings.about`,
|
|
275
|
+
intlLabel: {
|
|
276
|
+
id: `${a}.settings.about.label`,
|
|
277
|
+
defaultMessage: "About"
|
|
278
|
+
},
|
|
279
|
+
to: `/settings/${a}/about`,
|
|
280
|
+
Component: () => import("./About-DNyaGrYn.mjs"),
|
|
281
|
+
permissions: N.admin.access
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
id: `${a}.settings.general`,
|
|
285
|
+
intlLabel: {
|
|
286
|
+
id: `${a}.settings.general.label`,
|
|
287
|
+
defaultMessage: "General Settings"
|
|
288
|
+
},
|
|
289
|
+
to: `/settings/${a}/${be}`,
|
|
290
|
+
Component: () => import("./Settings-B823hBAu.mjs"),
|
|
291
|
+
permissions: N.admin.access
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
});
|
|
295
|
+
},
|
|
296
|
+
async registerTrads({ locales: e }) {
|
|
297
|
+
return Promise.all(
|
|
298
|
+
e.map(async (t) => t in B ? B[t]().then(({ default: i }) => ({
|
|
299
|
+
data: q(a, A(i)),
|
|
300
|
+
locale: t
|
|
301
|
+
})) : {
|
|
302
|
+
data: q(a, A({})),
|
|
303
|
+
locale: t
|
|
304
|
+
})
|
|
305
|
+
);
|
|
306
|
+
},
|
|
307
|
+
async bootstrap(e) {
|
|
308
|
+
e.getPlugin("content-manager").injectComponent("listView", "actions", {
|
|
309
|
+
name: "display-create-button",
|
|
310
|
+
Component: Te
|
|
311
|
+
});
|
|
312
|
+
let t = window.location.pathname;
|
|
313
|
+
window.addEventListener("popstate", async () => {
|
|
314
|
+
t !== window.location.pathname && (t = window.location.pathname, await v());
|
|
315
|
+
});
|
|
316
|
+
const n = history.pushState, i = history.replaceState;
|
|
317
|
+
history.pushState = function(...r) {
|
|
318
|
+
n.apply(history, r), t !== window.location.pathname && (t = window.location.pathname, v());
|
|
319
|
+
}, history.replaceState = function(...r) {
|
|
320
|
+
i.apply(history, r), t !== window.location.pathname && (t = window.location.pathname, v());
|
|
321
|
+
}, await Le();
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
export {
|
|
325
|
+
je as a,
|
|
326
|
+
N as b,
|
|
327
|
+
g as c,
|
|
328
|
+
Fe as d,
|
|
329
|
+
be as m,
|
|
330
|
+
a as p
|
|
331
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const q=require("remeda"),D=require("zod"),o=require("react/jsx-runtime"),M=require("@strapi/strapi/admin"),f=require("react"),w=require("react-cookie"),i=require("@strapi/design-system"),H=require("react-dom/client"),U=require("@strapi/icons"),P=require("@tanstack/react-query"),F=e=>e&&e.__esModule?e:{default:e},z=F(f),Q="@sensinum/strapi-plugin-multi-domain",W="5.2.0",J="https://www.sensinum.com/contact",V="hello@sensinum.com",G={name:"multi-domain"},K={name:Q,version:W,homepage:J,email:V},s=D.z.literal("multi-domain").parse(G.name);q.toSnakeCase(s);const h="domain",T="domain",k=`${h}s`,p="domain",L={read:"read",change:"change",create:"create",delete:"delete"},x=e=>`plugin::${s}.${L[e]}`,j={admin:{access:Object.keys(L).map(e=>({action:x(e),subject:null})),create:[{action:x("create"),subject:null}],edit:[{action:x("change"),subject:null}],delete:[{action:x("delete"),subject:null}]}},g=`data-${h}-initialized`,X="strapi-super-admin",I=e=>e?.code===X,Y=e=>{const t=`/admin/content-manager/collection-types/${e}/create`,n=document.querySelector(`a[href*="${t}"]`);n&&(n.style.display="none")},Z=()=>{const[{[p]:e}]=w.useCookies([p]),t=I(e),{slug:n}=M.unstable_useContentManagerContext();return z.default.useEffect(()=>{(t||!e)&&Y(n)},[t,e,n]),null},ee=()=>o.jsx(w.CookiesProvider,{children:o.jsx(Z,{})}),te=({setPlugin:e})=>{const t=f.useRef(e);return f.useEffect(()=>{t.current(s)},[]),null},E={en:()=>Promise.resolve().then(()=>require("./en-hAVH8fH0.js"))},A=(e,t)=>{if(!e)throw new TypeError("Prefix can't be empty");return Object.keys(t).reduce((n,a)=>(n[`${e}.${a}`]=t[a],n),{})},S=(e,t="")=>Object.keys(e).reduce((n,a)=>{const r=t.length?`${t}.`:"";return typeof e[a]=="object"&&e[a]!==null&&!Array.isArray(e[a])?Object.assign(n,S(e[a],r+a)):n[r+a]=e[a],n},{}),ne=({onClose:e,userData:t})=>{const[{[p]:n},a]=w.useCookies([p]),[r,u]=f.useState(""),[c,m]=f.useState(n||null),d=(t[T]||[]).filter(l=>l.name.toLowerCase().includes(r.toLowerCase())),y=l=>{m(c?.id===l.id?null:l)},_=()=>{c&&(a(p,JSON.stringify(c),{path:"/",maxAge:60*60*24*30,domain:window.location.hostname}),window.location.reload())};return console.log("Avatar",i.Avatar),o.jsx(i.Modal.Root,{defaultOpen:!0,onOpenChange:e,children:o.jsxs(i.Modal.Content,{children:[o.jsx(i.Modal.Header,{children:o.jsx(i.Modal.Title,{children:"Select Domain"})}),o.jsxs(i.Modal.Body,{children:[o.jsx(i.Box,{paddingBottom:4,children:o.jsxs(i.Field.Root,{name:"tenant-search",children:[o.jsx(i.Field.Label,{children:"Search domains"}),o.jsx(i.Searchbar,{name:"tenant-search",onClear:()=>u(""),value:r,onChange:l=>u(l.target.value),placeholder:"Search domains...",size:"S"})]})}),d.length===0?o.jsx(i.EmptyStateLayout,{icon:o.jsx(U.Search,{}),content:"No domains found matching your search criteria"}):o.jsx(i.Box,{maxHeight:"400px",overflow:"auto",children:o.jsxs(i.Table,{colCount:2,rowCount:d.length+1,children:[o.jsx(i.Thead,{children:o.jsxs(i.Tr,{children:[o.jsx(i.Th,{width:"60px",children:o.jsx(i.Typography,{variant:"sigma",textColor:"neutral600",children:"Select"})}),o.jsx(i.Th,{width:"40px"}),o.jsx(i.Th,{children:o.jsx(i.Typography,{variant:"sigma",textColor:"neutral600",children:"Domain name"})})]})}),o.jsx(i.Tbody,{children:d.map(l=>o.jsxs(i.Tr,{children:[o.jsx(i.Td,{width:"60px",children:o.jsx(i.Checkbox,{checked:c?.id===l.id,onCheckedChange:()=>y(l),name:`tenant-${l.id}`})}),o.jsx(i.Td,{width:"40px",children:l.logo?.url&&o.jsx(i.Avatar.Item,{src:l.logo.url,alt:l.name,preview:!1})}),o.jsx(i.Td,{children:o.jsx(i.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:l.name})})]},l.id))})]})})]}),o.jsxs(i.Modal.Footer,{children:[o.jsx(i.Modal.Close,{children:o.jsx(i.Button,{onClick:e,variant:"tertiary",children:"Cancel"})}),o.jsx(i.Button,{onClick:_,disabled:!c,children:"Select domain"})]})]})})},oe=new P.QueryClient({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}}),ie=(e,t,n,a)=>{const r=H.createRoot(e),u=()=>{document.body.removeAttribute("style"),r.unmount(),setTimeout(()=>{document.body.style.pointerEvents="auto"},0)};return t.remove(),r.render(o.jsx(i.DesignSystemProvider,{theme:a==="light"?i.lightTheme:i.darkTheme,children:o.jsx(P.QueryClientProvider,{client:oe,children:o.jsx(w.CookiesProvider,{children:o.jsx(ne,{onClose:u,userData:n})})})}))},b=(e,t)=>new Promise((n,a)=>{const c=(m=0)=>{if(m>50){a(new Error("Button not found after 50 attempts"));return}const d=(t||document).querySelector(e);if(d){n(d);return}setTimeout(()=>c(m+1),250)};c()}),B=()=>{try{const t=document.cookie.split(";").find(n=>n.trim().startsWith(`${p}=`));if(t){const n=t.split("=").at(1);if(!n)return null;const a=decodeURIComponent(n);return JSON.parse(a)}}catch(e){console.error("Error parsing tenant cookie:",e)}return null},ae=e=>{const t=e.firstChild,n=t?.lastChild?.cloneNode(!0);if(t&&n instanceof HTMLElement){const a=n.firstChild;a&&n.replaceChildren(a);const r=n.querySelector("span");if(r){const u=B();r.innerText=u?`${h.toUpperCase()}: ${u.name}`:`No ${h} selected`}n.style.paddingTop="1rem",t.appendChild(n)}},v=async()=>{try{const e=M.getFetchClient(),{data:{data:t}}=await e.get("/admin/users/me");return t}catch{return null}},R=async()=>{const e=await v(),t=document.createElement("div");document.body.appendChild(t);const n=await b('nav button[aria-haspopup="menu"]'),a="aria-expanded";new MutationObserver(async u=>{if(u.some(c=>c.attributeName===a)&&n.getAttribute(a)==="true"){const c=await b("[data-radix-menu-content]");if(!(c instanceof HTMLElement))return;ae(c);const m=await b('[role="menuitem"]',c),d=m.cloneNode(!0);if(e?.[T]&&e?.[T].length>1){if(!(d instanceof HTMLElement))return;d.querySelector("span").innerText=`Select ${h}`,d.addEventListener("mouseenter",function(){this.setAttribute("data-highlighted","true")}),d.addEventListener("mouseleave",function(){this.removeAttribute("data-highlighted")}),d.addEventListener("click",y=>{y.preventDefault(),y.stopPropagation(),ie(t,c,e,localStorage.getItem("STRAPI_THEME")||"dark")}),m.insertAdjacentElement("afterend",d)}}}).observe(n,{attributes:!0})},N=()=>window.location.pathname==="/admin/auth/login",se=()=>window.location.pathname.startsWith("/admin/plugins/upload"),re=()=>{const e=B(),t=document.querySelector('[data-strapi-header="true"]');if(!e||I(e)){const n=t?.querySelectorAll("button");n&&n.forEach(a=>{a.style.display="none"})}},$=q.funnel(re,{minQuietPeriodMs:250}),O=async()=>{const e=await b('nav ul > li a[href="/admin/plugins/upload"]');e&&e.addEventListener("click",()=>{$.call()}),se()&&$.call()},C=async()=>{if(N()){document.body.removeAttribute(g);return}if(await v()){document.querySelector(`[${g}]`)||(await Promise.all([R(),O()]),document.body.setAttribute(g,"true"));return}document.body.removeAttribute(g)},ce=async()=>{N()||!await v()||(document.body.setAttribute(g,"true"),await Promise.all([R(),O()]))},le={register(e){e.registerPlugin({id:s,initializer:te,isReady:!1,name:s}),e.customFields.register({name:`unique-by-${h}`,pluginId:s,type:"string",intlLabel:{id:`${s}.custom-fields.unique-by-domain.label`,defaultMessage:"Unique by domain"},intlDescription:{id:`${s}.custom-fields.unique-by-tenant.description`,defaultMessage:"Ensures the value is unique within the domain."},components:{Input:()=>Promise.resolve().then(()=>require("./TenantCustomField-CHUfO3Xh.js"))}}),e.router.addSettingsLink({id:`${s}.settings`,intlLabel:{id:`${s}.settings.label`,defaultMessage:"Multi-Domain Settings"},links:[{id:`${s}.settings.about`,intlLabel:{id:`${s}.settings.about.label`,defaultMessage:"About"},to:`/settings/${s}/about`,Component:()=>Promise.resolve().then(()=>require("./About-DaPMT-kj.js")),permissions:j.admin.access},{id:`${s}.settings.general`,intlLabel:{id:`${s}.settings.general.label`,defaultMessage:"General Settings"},to:`/settings/${s}/${k}`,Component:()=>Promise.resolve().then(()=>require("./Settings-B_1YuoN9.js")),permissions:j.admin.access}]})},async registerTrads({locales:e}){return Promise.all(e.map(async t=>t in E?E[t]().then(({default:a})=>({data:A(s,S(a)),locale:t})):{data:A(s,S({})),locale:t}))},async bootstrap(e){e.getPlugin("content-manager").injectComponent("listView","actions",{name:"display-create-button",Component:ee});let t=window.location.pathname;window.addEventListener("popstate",async()=>{t!==window.location.pathname&&(t=window.location.pathname,await C())});const n=history.pushState,a=history.replaceState;history.pushState=function(...r){n.apply(history,r),t!==window.location.pathname&&(t=window.location.pathname,C())},history.replaceState=function(...r){a.apply(history,r),t!==window.location.pathname&&(t=window.location.pathname,C())},await ce()}};exports.modelId=h;exports.modelRoute=k;exports.packageJson=K;exports.permissions=j;exports.plugin=le;exports.pluginId=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react-intl"),u=require("./index-DuSOcmV4.js"),c=()=>{const{formatMessage:e}=r.useIntl();return(s,{defaultMessage:t,values:n}={})=>e({id:`${u.pluginId}.${s}`,defaultMessage:t},n)};exports.useGetMessage=c;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useIntl as r } from "react-intl";
|
|
2
|
+
import { p as a } from "./index-DEoxiYwP.mjs";
|
|
3
|
+
const p = () => {
|
|
4
|
+
const { formatMessage: s } = r();
|
|
5
|
+
return (e, { defaultMessage: t, values: o } = {}) => s(
|
|
6
|
+
{
|
|
7
|
+
id: `${a}.${e}`,
|
|
8
|
+
defaultMessage: t
|
|
9
|
+
},
|
|
10
|
+
o
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
p as u
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("@tanstack/react-query"),t=require("./index-Cvs1ZCFy.js"),s=()=>e.useQuery({queryKey:["multi-domain-settings"],queryFn:()=>t.api.getSettings(),staleTime:2*60*1e3});exports.useSettings=s;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useQuery as e } from "@tanstack/react-query";
|
|
2
|
+
import { a as t } from "./index-2nR8Jd1x.mjs";
|
|
3
|
+
const i = () => e({
|
|
4
|
+
queryKey: ["multi-domain-settings"],
|
|
5
|
+
queryFn: () => t.getSettings(),
|
|
6
|
+
staleTime: 2 * 60 * 1e3
|
|
7
|
+
// 2 minutes
|
|
8
|
+
});
|
|
9
|
+
export {
|
|
10
|
+
i as u
|
|
11
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as l, Fragment as f } from "react/jsx-runtime";
|
|
2
2
|
import { useFetchClient as q } from "@strapi/strapi/admin";
|
|
3
|
-
import { useQuery as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
3
|
+
import { useQuery as i, useQueryClient as o, useMutation as u } from "@tanstack/react-query";
|
|
4
|
+
import { a as s } from "./index-2nR8Jd1x.mjs";
|
|
5
|
+
import { m as F } from "./index-DEoxiYwP.mjs";
|
|
6
|
+
const T = () => {
|
|
7
7
|
const e = q();
|
|
8
|
-
return
|
|
8
|
+
return i({
|
|
9
9
|
queryKey: ["permissions"],
|
|
10
10
|
queryFn: async () => {
|
|
11
11
|
const { data: t } = await e.get("/admin/users/me/permissions");
|
|
@@ -15,43 +15,37 @@ const g = () => {
|
|
|
15
15
|
refetchOnWindowFocus: !1,
|
|
16
16
|
retry: !1
|
|
17
17
|
});
|
|
18
|
-
},
|
|
18
|
+
}, v = ({
|
|
19
19
|
permissions: e,
|
|
20
20
|
children: t,
|
|
21
|
-
NotAllowed:
|
|
21
|
+
NotAllowed: r = () => null
|
|
22
22
|
}) => {
|
|
23
|
-
const { isLoading:
|
|
24
|
-
if (
|
|
23
|
+
const { isLoading: c, data: y } = T();
|
|
24
|
+
if (c)
|
|
25
25
|
return null;
|
|
26
|
-
const
|
|
27
|
-
return e && !e.every((
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
id: `${F}.${t}`,
|
|
31
|
-
defaultMessage: s
|
|
32
|
-
},
|
|
33
|
-
a
|
|
34
|
-
), n = {
|
|
35
|
-
all: [T],
|
|
26
|
+
const m = (a) => e ? y?.some((d) => d.action === a) : !0;
|
|
27
|
+
return e && !e.every((a) => m(a.action)) ? /* @__PURE__ */ l(r, {}) : t ? /* @__PURE__ */ l(f, { children: t }) : null;
|
|
28
|
+
}, n = {
|
|
29
|
+
all: [F],
|
|
36
30
|
lists: () => [...n.all, "list"],
|
|
37
31
|
list: (e) => [...n.lists(), { filters: e }],
|
|
38
32
|
details: () => [...n.all, "detail"],
|
|
39
33
|
detail: (e) => [...n.details(), e]
|
|
40
|
-
},
|
|
34
|
+
}, S = (e) => i({
|
|
41
35
|
queryKey: [...n.lists(), JSON.stringify(e || {})],
|
|
42
|
-
queryFn: () =>
|
|
36
|
+
queryFn: () => s.getTenants(e),
|
|
43
37
|
staleTime: 2 * 60 * 1e3
|
|
44
38
|
// 2 minutes
|
|
45
|
-
}),
|
|
39
|
+
}), h = (e) => i({
|
|
46
40
|
queryKey: n.detail(e),
|
|
47
|
-
queryFn: () =>
|
|
41
|
+
queryFn: () => s.getTenant(e),
|
|
48
42
|
enabled: !!e,
|
|
49
43
|
staleTime: 2 * 60 * 1e3
|
|
50
44
|
// 2 minutes
|
|
51
|
-
}),
|
|
52
|
-
const e =
|
|
53
|
-
return
|
|
54
|
-
mutationFn: (t) =>
|
|
45
|
+
}), w = () => {
|
|
46
|
+
const e = o();
|
|
47
|
+
return u({
|
|
48
|
+
mutationFn: (t) => s.createTenant(t),
|
|
55
49
|
onSuccess: async () => {
|
|
56
50
|
await e.invalidateQueries({ queryKey: n.lists() });
|
|
57
51
|
},
|
|
@@ -59,10 +53,10 @@ const g = () => {
|
|
|
59
53
|
console.error("Failed to create tenant:", t);
|
|
60
54
|
}
|
|
61
55
|
});
|
|
62
|
-
},
|
|
63
|
-
const e =
|
|
64
|
-
return
|
|
65
|
-
mutationFn: ({ id: t, data:
|
|
56
|
+
}, E = () => {
|
|
57
|
+
const e = o();
|
|
58
|
+
return u({
|
|
59
|
+
mutationFn: ({ id: t, data: r }) => s.updateTenant(t, r),
|
|
66
60
|
onSuccess: (t) => {
|
|
67
61
|
e.setQueryData(n.detail(t.id), t), e.invalidateQueries({ queryKey: n.lists() });
|
|
68
62
|
},
|
|
@@ -70,12 +64,12 @@ const g = () => {
|
|
|
70
64
|
console.error("Failed to update tenant:", t);
|
|
71
65
|
}
|
|
72
66
|
});
|
|
73
|
-
},
|
|
74
|
-
const e =
|
|
75
|
-
return
|
|
76
|
-
mutationFn: (t) =>
|
|
77
|
-
onSuccess: (t,
|
|
78
|
-
e.removeQueries({ queryKey: n.detail(
|
|
67
|
+
}, P = () => {
|
|
68
|
+
const e = o();
|
|
69
|
+
return u({
|
|
70
|
+
mutationFn: (t) => s.deleteTenant(t),
|
|
71
|
+
onSuccess: (t, r) => {
|
|
72
|
+
e.removeQueries({ queryKey: n.detail(r) }), e.invalidateQueries({ queryKey: n.lists() });
|
|
79
73
|
},
|
|
80
74
|
onError: (t) => {
|
|
81
75
|
console.error("Failed to delete tenant:", t);
|
|
@@ -83,11 +77,10 @@ const g = () => {
|
|
|
83
77
|
});
|
|
84
78
|
};
|
|
85
79
|
export {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
x as u
|
|
80
|
+
v as C,
|
|
81
|
+
S as a,
|
|
82
|
+
h as b,
|
|
83
|
+
w as c,
|
|
84
|
+
E as d,
|
|
85
|
+
P as u
|
|
93
86
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),d=require("@strapi/strapi/admin"),s=require("@tanstack/react-query"),u=require("./index-Cvs1ZCFy.js"),q=require("./index-DuSOcmV4.js"),m=()=>{const e=d.useFetchClient();return s.useQuery({queryKey:["permissions"],queryFn:async()=>{const{data:t}=await e.get("/admin/users/me/permissions");return t.data},staleTime:1e3*60*5,refetchOnWindowFocus:!1,retry:!1})},T=({permissions:e,children:t,NotAllowed:r=()=>null})=>{const{isLoading:o,data:l}=m();if(o)return null;const c=a=>e?l?.some(y=>y.action===a):!0;return e&&!e.every(a=>c(a.action))?i.jsx(r,{}):t?i.jsx(i.Fragment,{children:t}):null},n={all:[q.modelRoute],lists:()=>[...n.all,"list"],list:e=>[...n.lists(),{filters:e}],details:()=>[...n.all,"detail"],detail:e=>[...n.details(),e]},F=e=>s.useQuery({queryKey:[...n.lists(),JSON.stringify(e||{})],queryFn:()=>u.api.getTenants(e),staleTime:2*60*1e3}),Q=e=>s.useQuery({queryKey:n.detail(e),queryFn:()=>u.api.getTenant(e),enabled:!!e,staleTime:2*60*1e3}),C=()=>{const e=s.useQueryClient();return s.useMutation({mutationFn:t=>u.api.createTenant(t),onSuccess:async()=>{await e.invalidateQueries({queryKey:n.lists()})},onError:t=>{console.error("Failed to create tenant:",t)}})},f=()=>{const e=s.useQueryClient();return s.useMutation({mutationFn:({id:t,data:r})=>u.api.updateTenant(t,r),onSuccess:t=>{e.setQueryData(n.detail(t.id),t),e.invalidateQueries({queryKey:n.lists()})},onError:t=>{console.error("Failed to update tenant:",t)}})},K=()=>{const e=s.useQueryClient();return s.useMutation({mutationFn:t=>u.api.deleteTenant(t),onSuccess:(t,r)=>{e.removeQueries({queryKey:n.detail(r)}),e.invalidateQueries({queryKey:n.lists()})},onError:t=>{console.error("Failed to delete tenant:",t)}})};exports.CheckPermissions=T;exports.useCreateTenant=C;exports.useDeleteTenant=K;exports.useTenant=Q;exports.useTenants=F;exports.useUpdateTenant=f;
|
package/dist/admin/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("../_chunks/index-
|
|
1
|
+
"use strict";const e=require("../_chunks/index-DuSOcmV4.js");module.exports=e.plugin;
|
package/dist/admin/index.mjs
CHANGED