@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
@@ -1,272 +0,0 @@
1
- import { jsx as e, jsxs as a, Fragment as D } from "react/jsx-runtime";
2
- import { Dialog as u, Flex as $, Button as q, Typography as h, Td as C, Checkbox as E, Badge as ne, IconButton as I, Tr as W, Loader as ie, EmptyStateLayout as oe, Table as re, Thead as ae, Th as y, Tbody as le, Box as se } from "@strapi/design-system";
3
- import { WarningCircle as ce, Trash as N, ArrowUp as de, ArrowDown as he, Pencil as me, Plus as ge, Search as ue } from "@strapi/icons";
4
- import { useNotification as pe, useQueryParams as fe, Page as w, Layouts as v, SearchInput as Ce, Pagination as P } from "@strapi/strapi/admin";
5
- import ye, { useState as R } from "react";
6
- import { useIntl as _ } from "react-intl";
7
- import { useNavigate as F } from "react-router-dom";
8
- import { a as M, p as H, m as Q, b as Se } from "./index-Ds2z-yoa.mjs";
9
- import { C as z, g as i, u as Te, a as be } from "./useTenants-CE8J0EOu.mjs";
10
- import ve from "styled-components";
11
- import { useQuery as ke } from "@tanstack/react-query";
12
- import { a as xe } from "./index-DkEjJa1n.mjs";
13
- const Ae = ({
14
- isOpen: t,
15
- onClose: o,
16
- onConfirm: s,
17
- target: l
18
- }) => /* @__PURE__ */ e(u.Root, { open: t, onOpenChange: o, children: /* @__PURE__ */ a(u.Content, { children: [
19
- /* @__PURE__ */ e(u.Header, { children: "Confirmation" }),
20
- /* @__PURE__ */ e(u.Body, { icon: /* @__PURE__ */ e(N, {}), children: /* @__PURE__ */ e(u.Description, { textAlign: "center", children: /* @__PURE__ */ a($, { gap: 2, direction: "column", children: [
21
- /* @__PURE__ */ e(ce, { fill: "danger600", width: "24", height: "24" }),
22
- "Are you sure you want to delete this ",
23
- l,
24
- "?",
25
- /* @__PURE__ */ e("br", {}),
26
- "All your modifications will be lost"
27
- ] }) }) }),
28
- /* @__PURE__ */ a(u.Footer, { children: [
29
- /* @__PURE__ */ e(u.Action, { children: /* @__PURE__ */ e(q, { fullWidth: !0, onClick: o, variant: "tertiary", size: "S", children: /* @__PURE__ */ e(h, { variant: "omega", children: "Cancel" }) }) }),
30
- /* @__PURE__ */ e(u.Action, { children: /* @__PURE__ */ e(q, { fullWidth: !0, onClick: s, variant: "danger", size: "S", children: /* @__PURE__ */ e(h, { variant: "omega", children: "Confirm" }) }) })
31
- ] })
32
- ] }) }), De = ({
33
- isDisplayed: t,
34
- direction: o
35
- }) => t ? o === "asc" ? /* @__PURE__ */ e(de, {}) : /* @__PURE__ */ e(he, {}) : null, L = ({
36
- label: t,
37
- field: o,
38
- sort: s,
39
- onSort: l
40
- }) => {
41
- const [c, m] = s.split(":");
42
- return /* @__PURE__ */ a(
43
- "div",
44
- {
45
- style: { display: "flex", alignItems: "center", cursor: "pointer" },
46
- onClick: () => l(o)(m === "asc" ? "desc" : "asc"),
47
- children: [
48
- /* @__PURE__ */ e(h, { variant: "sigma", textColor: "neutral600", children: t }),
49
- /* @__PURE__ */ e("span", { style: { marginLeft: 4 }, children: /* @__PURE__ */ e(De, { isDisplayed: o === c, direction: m }) })
50
- ]
51
- }
52
- );
53
- }, we = ve(W)(() => ({
54
- cursor: "pointer"
55
- })), Pe = ({
56
- tenant: t,
57
- selectedTenants: o,
58
- handleSelectTenant: s,
59
- onDeleteTenant: l,
60
- isDeletePending: c = !1
61
- }) => {
62
- const m = F(), { formatMessage: n } = _(), S = (p) => () => m(`/settings/${H}/${Q}/${p.id}`);
63
- return /* @__PURE__ */ a(we, { onClick: S(t), children: [
64
- /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(
65
- E,
66
- {
67
- checked: o.includes(t.id),
68
- onCheckedChange: (p) => s(t.id, p)
69
- }
70
- ) }),
71
- /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(h, { fontWeight: "semiBold", textColor: "neutral800", children: t.id }) }),
72
- /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(h, { fontWeight: "semiBold", textColor: "neutral800", children: t.name }) }),
73
- /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(h, { textColor: "neutral800", children: t.code }) }),
74
- /* @__PURE__ */ e(C, { children: t.role ? /* @__PURE__ */ e(ne, { textColor: "neutral800", backgroundColor: "neutral100", children: t.role.name }) : /* @__PURE__ */ e(h, { textColor: "neutral600", children: "-" }) }),
75
- /* @__PURE__ */ e(C, { children: /* @__PURE__ */ a($, { gap: 1, children: [
76
- /* @__PURE__ */ e(z, { permissions: M.admin.edit, children: /* @__PURE__ */ e(
77
- I,
78
- {
79
- onClick: S(t),
80
- label: i(n, "common.edit"),
81
- children: /* @__PURE__ */ e(me, {})
82
- }
83
- ) }),
84
- /* @__PURE__ */ e(z, { permissions: M.admin.delete, children: /* @__PURE__ */ e(
85
- I,
86
- {
87
- onClick: l(t),
88
- label: i(n, "common.delete"),
89
- disabled: c,
90
- children: /* @__PURE__ */ e(N, {})
91
- }
92
- ) })
93
- ] }) })
94
- ] });
95
- }, Le = () => ke({
96
- queryKey: ["multi-domain-settings"],
97
- queryFn: () => xe.getSettings(),
98
- staleTime: 2 * 60 * 1e3
99
- // 2 minutes
100
- }), He = () => {
101
- const t = F(), { toggleNotification: o } = pe(), [s, l] = R([]), [c, m] = R(), { formatMessage: n } = _(), S = Te(), { data: p, isLoading: j } = Le(), [{ query: f }, O] = fe({
102
- sort: "name:asc",
103
- _q: "",
104
- page: 1,
105
- pageSize: 10
106
- }), { sort: T, _q: K, page: U, pageSize: G } = {
107
- ...f,
108
- sort: f.sort || "name:asc",
109
- _q: f._q || "",
110
- page: f.page || 1,
111
- pageSize: f.pageSize || 10
112
- }, { data: B, isLoading: J, error: b } = be({ sort: T, search: K, page: U, pageSize: G }), g = B?.results || [], k = B?.pagination || { pageCount: 1, total: 0 };
113
- ye.useEffect(() => {
114
- b && o({
115
- type: "danger",
116
- message: b instanceof Error ? b.message : "An error occurred while fetching tenants"
117
- });
118
- }, [b, o]);
119
- const V = (r) => {
120
- l(r ? g.map((d) => d.id) : []);
121
- }, X = (r, d) => {
122
- l(d ? (A) => [...A, r] : (A) => A.filter((te) => te !== r));
123
- }, x = (r) => (d) => {
124
- O({
125
- ...f,
126
- sort: `${r}:${d}`
127
- });
128
- }, Y = (r) => async (d) => {
129
- d.stopPropagation(), m(r);
130
- }, Z = async () => {
131
- if (c)
132
- try {
133
- await S.mutateAsync(c.id), o({
134
- type: "success",
135
- message: i(n, "domain.notifications.deleted", {
136
- values: { name: c.name }
137
- })
138
- }), m(void 0), l((r) => r.filter((d) => d !== c.id));
139
- } catch {
140
- o({
141
- type: "danger",
142
- message: i(n, "domain.notifications.deleteError")
143
- });
144
- }
145
- }, ee = () => {
146
- m(void 0);
147
- };
148
- return J || j ? /* @__PURE__ */ e(w.Main, { children: /* @__PURE__ */ e(v.Content, { children: /* @__PURE__ */ e(ie, { children: i(n, "domain.list.loading") }) }) }) : /* @__PURE__ */ a(D, { children: [
149
- /* @__PURE__ */ e(w.Title, { children: "Tenants" }),
150
- /* @__PURE__ */ a(w.Main, { children: [
151
- /* @__PURE__ */ e(
152
- v.Header,
153
- {
154
- title: i(n, "domain.list.title"),
155
- subtitle: i(n, "domain.list.subtitle", {
156
- values: { count: g.length }
157
- }),
158
- as: "h2"
159
- }
160
- ),
161
- /* @__PURE__ */ e(
162
- v.Action,
163
- {
164
- startActions: /* @__PURE__ */ e(D, { children: /* @__PURE__ */ e(
165
- Ce,
166
- {
167
- label: i(n, "domain.list.search", {
168
- defaultMessage: "Search domains"
169
- })
170
- }
171
- ) }),
172
- endActions: /* @__PURE__ */ e(z, { permissions: M.admin.create, children: /* @__PURE__ */ e(
173
- q,
174
- {
175
- startIcon: /* @__PURE__ */ e(ge, {}),
176
- onClick: () => {
177
- if (!p || p.features.domains <= k.total)
178
- return o({
179
- type: "warning",
180
- message: i(n, "domain.list.limitReached", {
181
- values: {
182
- limit: p?.features.domains || 0
183
- }
184
- })
185
- });
186
- t(`/settings/${H}/${Q}/new`);
187
- },
188
- children: i(n, "common.create")
189
- }
190
- ) })
191
- }
192
- ),
193
- /* @__PURE__ */ e(v.Content, { children: g.length === 0 ? /* @__PURE__ */ e(
194
- oe,
195
- {
196
- icon: /* @__PURE__ */ e(ue, {}),
197
- content: i(n, "domain.list.emptyState", {
198
- defaultMessage: "No domains found matching your search criteria"
199
- })
200
- }
201
- ) : /* @__PURE__ */ a(D, { children: [
202
- /* @__PURE__ */ a(re, { colCount: 6, rowCount: g.length + 1, children: [
203
- /* @__PURE__ */ e(ae, { children: /* @__PURE__ */ a(W, { children: [
204
- /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(
205
- E,
206
- {
207
- checked: s.length === g.length && g.length > 0,
208
- indeterminate: s.length > 0 && s.length < g.length,
209
- onCheckedChange: V
210
- }
211
- ) }),
212
- /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(
213
- L,
214
- {
215
- label: i(n, "domain.list.table.headers.id"),
216
- field: "id",
217
- sort: T,
218
- onSort: x
219
- }
220
- ) }),
221
- /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(
222
- L,
223
- {
224
- label: i(n, "domain.list.table.headers.name"),
225
- field: "name",
226
- sort: T,
227
- onSort: x
228
- }
229
- ) }),
230
- /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(
231
- L,
232
- {
233
- label: i(n, "domain.list.table.headers.code"),
234
- field: "code",
235
- sort: T,
236
- onSort: x
237
- }
238
- ) }),
239
- /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(h, { variant: "sigma", textColor: "neutral600", children: i(n, "domain.list.table.headers.role") }) }),
240
- /* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(h, { variant: "sigma", textColor: "neutral600", children: i(n, "domain.list.table.headers.actions") }) })
241
- ] }) }),
242
- /* @__PURE__ */ e(le, { children: g.map((r) => /* @__PURE__ */ e(
243
- Pe,
244
- {
245
- tenant: r,
246
- selectedTenants: s,
247
- handleSelectTenant: X,
248
- onDeleteTenant: Y
249
- },
250
- r.id
251
- )) })
252
- ] }),
253
- /* @__PURE__ */ e(se, { paddingTop: 4, children: /* @__PURE__ */ a(P.Root, { pageCount: k.pageCount, total: k.total, children: [
254
- /* @__PURE__ */ e(P.PageSize, {}),
255
- /* @__PURE__ */ e(P.Links, {})
256
- ] }) })
257
- ] }) })
258
- ] }),
259
- /* @__PURE__ */ e(
260
- Ae,
261
- {
262
- isOpen: !!c,
263
- onClose: ee,
264
- onConfirm: Z,
265
- target: c?.name || Se
266
- }
267
- )
268
- ] });
269
- };
270
- export {
271
- He as default
272
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={common:{cancel:"Cancel",edit:"Edit",delete:"Delete",loading:"Loading...",create:"Create new entry",back:"Back",update:"Update",save:"Save"},domain:{list:{title:"Domain",subtitle:"{count} entries found",search:"Search domains",create:"Create new entry",emptyState:"No domains found matching your search criteria",limitReached:"You have reached the maximum number of domains allowed ({limit}). Please upgrade your plan to add more.",table:{headers:{id:"ID",name:"NAME",code:"CODE",role:"ROLE",actions:"Actions"}},loading:"Loading domains..."},edit:{title:{create:"Create Domain",edit:"Edit {name}"},loading:"Loading domain...",notifications:{invalidJson:"Invalid JSON in custom fields",updated:"Domain updated successfully",created:"Domain created successfully",saveError:"Failed to save domain"},validation:{invalidJson:"Invalid JSON format in custom fields"},form:{name:{label:"Name",placeholder:"Enter domain name",hint:"A unique name for this domain"},code:{label:"Code",placeholder:"Enter domain code",hint:"A unique identifier for this domain"},role:{label:"Role",placeholder:"Select a role for this domain",hint:"Assign a role to control domain permissions",remove:"Remove role"},tokens:{label:"API Tokens",placeholder:"Select API tokens for this domain",hint:"Optionally associate multiple API tokens with this domain",add:"Add token",remove:"Remove token"},damRootDirectory:{label:"DAM Root Directory",placeholder:"Enter DAM root directory path",hint:"Root directory path for Digital Asset Management"},customFields:{label:"Custom Fields",hint:"Additional data stored as JSON for this domain"},logo:{label:"Logo",hint:"Upload a logo image for this domain",upload:"Upload Logo",change:"Change Logo",remove:"Remove",noImage:"No image selected"}},actions:{entry:"Entry",create:"Create Domain",update:"Update Domain"}},notifications:{deleted:"Domain deleted successfully",deleteError:"Failed to delete domain",updated:"Domain updated successfully",created:"Domain created successfully"}}};exports.default=e;
@@ -1 +0,0 @@
1
- "use strict";const q=require("remeda"),_=require("zod"),o=require("react/jsx-runtime"),M=require("@strapi/strapi/admin"),f=require("react"),w=require("react-cookie"),i=require("@strapi/design-system"),D=require("react-dom/client"),H=require("@strapi/icons"),$=require("@tanstack/react-query"),U=e=>e&&e.__esModule?e:{default:e},F=U(f),z={name:"multi-domain"},s=_.z.literal("multi-domain").parse(z.name);q.toSnakeCase(s);const h="domain",T="domain",Q=`${h}s`,p="domain",P={read:"read",change:"change",create:"create",delete:"delete"},x=e=>`plugin::${s}.${P[e]}`,k={admin:{access:Object.keys(P).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`,W="strapi-super-admin",I=e=>e?.code===W,V=e=>{const t=`/admin/content-manager/collection-types/${e}/create`,n=document.querySelector(`a[href*="${t}"]`);n&&(n.style.display="none")},J=()=>{const[{[p]:e}]=w.useCookies([p]),t=I(e),{slug:n}=M.unstable_useContentManagerContext();return F.default.useEffect(()=>{(t||!e)&&V(n)},[t,e,n]),null},G=()=>o.jsx(w.CookiesProvider,{children:o.jsx(J,{})}),K=({setPlugin:e})=>{const t=f.useRef(e);return f.useEffect(()=>{t.current(s)},[]),null},v={en:()=>Promise.resolve().then(()=>require("./en-Dj_hyppO.js"))},E=(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),{})},j=(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,j(e[a],r+a)):n[r+a]=e[a],n},{}),X=({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)},O=()=>{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(H.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:O,disabled:!c,children:"Select domain"})]})]})})},Y=new $.QueryClient({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}}),Z=(e,t,n,a)=>{const r=D.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($.QueryClientProvider,{client:Y,children:o.jsx(w.CookiesProvider,{children:o.jsx(X,{onClose:u,userData:n})})})}))},C=(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()}),L=()=>{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},ee=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=L();r.innerText=u?`${h.toUpperCase()}: ${u.name}`:`No ${h} selected`}n.style.paddingTop="1rem",t.appendChild(n)}},S=async()=>{try{const e=M.getFetchClient(),{data:{data:t}}=await e.get("/admin/users/me");return t}catch{return null}},B=async()=>{const e=await S(),t=document.createElement("div");document.body.appendChild(t);const n=await C('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 C("[data-radix-menu-content]");if(!(c instanceof HTMLElement))return;ee(c);const m=await C('[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(),Z(t,c,e,localStorage.getItem("STRAPI_THEME")||"dark")}),m.insertAdjacentElement("afterend",d)}}}).observe(n,{attributes:!0})},R=()=>window.location.pathname==="/admin/auth/login",te=()=>window.location.pathname.startsWith("/admin/plugins/upload"),ne=()=>{const e=L(),t=document.querySelector('[data-strapi-header="true"]');if(!e||I(e)){const n=t?.querySelectorAll("button");n&&n.forEach(a=>{a.style.display="none"})}},A=q.funnel(ne,{minQuietPeriodMs:250}),N=async()=>{const e=await C('nav ul > li a[href="/admin/plugins/upload"]');e&&e.addEventListener("click",()=>{A.call()}),te()&&A.call()},b=async()=>{if(R()){document.body.removeAttribute(g);return}if(await S()){document.querySelector(`[${g}]`)||(await Promise.all([B(),N()]),document.body.setAttribute(g,"true"));return}document.body.removeAttribute(g)},oe=async()=>{R()||!await S()||(document.body.setAttribute(g,"true"),await Promise.all([B(),N()]))},ie={register(e){e.registerPlugin({id:s,initializer:K,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-BYDxTP5y.js"))}}),e.addSettingsLink({id:`${s}.settings`,intlLabel:{id:`${s}.settings.label`,defaultMessage:"Multi-Domain Settings"}},{id:`${s}.settings.general`,intlLabel:{id:`${s}.settings.general.label`,defaultMessage:"General Settings"},to:`/settings/${s}`,Component:()=>Promise.resolve().then(()=>require("./Settings-CT4xmD8_.js")),permissions:k.admin.access})},async registerTrads({locales:e}){return Promise.all(e.map(async t=>t in v?v[t]().then(({default:a})=>({data:E(s,j(a)),locale:t})):{data:E(s,j({})),locale:t}))},async bootstrap(e){e.getPlugin("content-manager").injectComponent("listView","actions",{name:"display-create-button",Component:G});let t=window.location.pathname;window.addEventListener("popstate",async()=>{t!==window.location.pathname&&(t=window.location.pathname,await b())});const n=history.pushState,a=history.replaceState;history.pushState=function(...r){n.apply(history,r),t!==window.location.pathname&&(t=window.location.pathname,b())},history.replaceState=function(...r){a.apply(history,r),t!==window.location.pathname&&(t=window.location.pathname,b())},await oe()}};exports.modelId=h;exports.modelRoute=Q;exports.permissions=k;exports.plugin=ie;exports.pluginId=s;
@@ -1,315 +0,0 @@
1
- import { toSnakeCase as Q, funnel as W } from "remeda";
2
- import { z as V } from "zod";
3
- import { jsx as o, jsxs as m } from "react/jsx-runtime";
4
- import { unstable_useContentManagerContext as J, getFetchClient as G } from "@strapi/strapi/admin";
5
- import K, { useRef as X, useEffect as Y, useState as x } from "react";
6
- import { CookiesProvider as O, useCookies as R } from "react-cookie";
7
- import { Avatar as M, Modal as h, Box as P, Field as L, Searchbar as Z, EmptyStateLayout as ee, Table as te, Thead as ne, Tr as k, Th as C, Typography as S, Tbody as oe, Td as T, Checkbox as ie, Button as I, DesignSystemProvider as ae, lightTheme as re, darkTheme as se } from "@strapi/design-system";
8
- import { createRoot as ce } from "react-dom/client";
9
- import { Search as le } from "@strapi/icons";
10
- import { QueryClient as de, QueryClientProvider as ue } from "@tanstack/react-query";
11
- const me = {
12
- name: "multi-domain"
13
- }, c = V.literal("multi-domain").parse(me.name);
14
- Q(c);
15
- const f = "domain", E = "domain", Oe = `${f}s`, p = "domain", D = {
16
- read: "read",
17
- change: "change",
18
- create: "create",
19
- delete: "delete"
20
- }, w = (e) => `plugin::${c}.${D[e]}`, he = {
21
- admin: {
22
- access: Object.keys(D).map((e) => ({
23
- action: w(e),
24
- subject: null
25
- })),
26
- create: [{ action: w("create"), subject: null }],
27
- edit: [{ action: w("change"), subject: null }],
28
- delete: [{ action: w("delete"), subject: null }]
29
- }
30
- }, g = `data-${f}-initialized`, pe = "strapi-super-admin", H = (e) => e?.code === pe, fe = (e) => {
31
- const t = `/admin/content-manager/collection-types/${e}/create`, n = document.querySelector(`a[href*="${t}"]`);
32
- n && (n.style.display = "none");
33
- }, ge = () => {
34
- const [{ [p]: e }] = R([p]), t = H(e), { slug: n } = J();
35
- return K.useEffect(() => {
36
- (t || !e) && fe(n);
37
- }, [t, e, n]), null;
38
- }, ye = () => /* @__PURE__ */ o(O, { children: /* @__PURE__ */ o(ge, {}) }), we = ({ setPlugin: e }) => {
39
- const t = X(e);
40
- return Y(() => {
41
- t.current(c);
42
- }, []), null;
43
- }, N = {
44
- en: () => import("./en-BIUQvQi4.mjs")
45
- }, B = (e, t) => {
46
- if (!e)
47
- throw new TypeError("Prefix can't be empty");
48
- return Object.keys(t).reduce(
49
- (n, i) => (n[`${e}.${i}`] = t[i], n),
50
- {}
51
- );
52
- }, A = (e, t = "") => Object.keys(e).reduce((n, i) => {
53
- const a = t.length ? `${t}.` : "";
54
- return typeof e[i] == "object" && e[i] !== null && !Array.isArray(e[i]) ? Object.assign(n, A(e[i], a + i)) : n[a + i] = e[i], n;
55
- }, {}), be = ({ onClose: e, userData: t }) => {
56
- const [{ [p]: n }, i] = R([p]), [a, d] = x(""), [r, u] = x(n || null), l = (t[E] || []).filter(
57
- (s) => s.name.toLowerCase().includes(a.toLowerCase())
58
- ), y = (s) => {
59
- u(r?.id === s.id ? null : s);
60
- }, z = () => {
61
- r && (i(p, JSON.stringify(r), {
62
- path: "/",
63
- maxAge: 60 * 60 * 24 * 30,
64
- // 30 days
65
- domain: window.location.hostname
66
- }), window.location.reload());
67
- };
68
- return console.log("Avatar", M), /* @__PURE__ */ o(h.Root, { defaultOpen: !0, onOpenChange: e, children: /* @__PURE__ */ m(h.Content, { children: [
69
- /* @__PURE__ */ o(h.Header, { children: /* @__PURE__ */ o(h.Title, { children: "Select Domain" }) }),
70
- /* @__PURE__ */ m(h.Body, { children: [
71
- /* @__PURE__ */ o(P, { paddingBottom: 4, children: /* @__PURE__ */ m(L.Root, { name: "tenant-search", children: [
72
- /* @__PURE__ */ o(L.Label, { children: "Search domains" }),
73
- /* @__PURE__ */ o(
74
- Z,
75
- {
76
- name: "tenant-search",
77
- onClear: () => d(""),
78
- value: a,
79
- onChange: (s) => d(s.target.value),
80
- placeholder: "Search domains...",
81
- size: "S"
82
- }
83
- )
84
- ] }) }),
85
- l.length === 0 ? /* @__PURE__ */ o(
86
- ee,
87
- {
88
- icon: /* @__PURE__ */ o(le, {}),
89
- content: "No domains found matching your search criteria"
90
- }
91
- ) : /* @__PURE__ */ o(P, { maxHeight: "400px", overflow: "auto", children: /* @__PURE__ */ m(te, { colCount: 2, rowCount: l.length + 1, children: [
92
- /* @__PURE__ */ o(ne, { children: /* @__PURE__ */ m(k, { children: [
93
- /* @__PURE__ */ o(C, { width: "60px", children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Select" }) }),
94
- /* @__PURE__ */ o(C, { width: "40px" }),
95
- /* @__PURE__ */ o(C, { children: /* @__PURE__ */ o(S, { variant: "sigma", textColor: "neutral600", children: "Domain name" }) })
96
- ] }) }),
97
- /* @__PURE__ */ o(oe, { children: l.map((s) => /* @__PURE__ */ m(k, { children: [
98
- /* @__PURE__ */ o(T, { width: "60px", children: /* @__PURE__ */ o(
99
- ie,
100
- {
101
- checked: r?.id === s.id,
102
- onCheckedChange: () => y(s),
103
- name: `tenant-${s.id}`
104
- }
105
- ) }),
106
- /* @__PURE__ */ o(T, { width: "40px", children: s.logo?.url && /* @__PURE__ */ o(M.Item, { src: s.logo.url, alt: s.name, preview: !1 }) }),
107
- /* @__PURE__ */ o(T, { children: /* @__PURE__ */ o(S, { fontWeight: "semiBold", textColor: "neutral800", children: s.name }) })
108
- ] }, s.id)) })
109
- ] }) })
110
- ] }),
111
- /* @__PURE__ */ m(h.Footer, { children: [
112
- /* @__PURE__ */ o(h.Close, { children: /* @__PURE__ */ o(I, { onClick: e, variant: "tertiary", children: "Cancel" }) }),
113
- /* @__PURE__ */ o(I, { onClick: z, disabled: !r, children: "Select domain" })
114
- ] })
115
- ] }) });
116
- }, Ce = new de({
117
- defaultOptions: {
118
- queries: {
119
- retry: !1,
120
- refetchOnWindowFocus: !1
121
- }
122
- }
123
- }), Se = (e, t, n, i) => {
124
- const a = ce(e), d = () => {
125
- document.body.removeAttribute("style"), a.unmount(), setTimeout(() => {
126
- document.body.style.pointerEvents = "auto";
127
- }, 0);
128
- };
129
- return t.remove(), a.render(
130
- /* @__PURE__ */ o(ae, { theme: i === "light" ? re : se, children: /* @__PURE__ */ o(ue, { client: Ce, children: /* @__PURE__ */ o(O, { children: /* @__PURE__ */ o(be, { onClose: d, userData: n }) }) }) })
131
- );
132
- }, b = (e, t) => new Promise((n, i) => {
133
- const r = (u = 0) => {
134
- if (u > 50) {
135
- i(new Error("Button not found after 50 attempts"));
136
- return;
137
- }
138
- const l = (t || document).querySelector(e);
139
- if (l) {
140
- n(l);
141
- return;
142
- }
143
- setTimeout(() => r(u + 1), 250);
144
- };
145
- r();
146
- }), U = () => {
147
- try {
148
- const t = document.cookie.split(";").find((n) => n.trim().startsWith(`${p}=`));
149
- if (t) {
150
- const n = t.split("=").at(1);
151
- if (!n)
152
- return null;
153
- const i = decodeURIComponent(n);
154
- return JSON.parse(i);
155
- }
156
- } catch (e) {
157
- console.error("Error parsing tenant cookie:", e);
158
- }
159
- return null;
160
- }, Te = (e) => {
161
- const t = e.firstChild, n = t?.lastChild?.cloneNode(!0);
162
- if (t && n instanceof HTMLElement) {
163
- const i = n.firstChild;
164
- i && n.replaceChildren(i);
165
- const a = n.querySelector("span");
166
- if (a) {
167
- const d = U();
168
- a.innerText = d ? `${f.toUpperCase()}: ${d.name}` : `No ${f} selected`;
169
- }
170
- n.style.paddingTop = "1rem", t.appendChild(n);
171
- }
172
- }, $ = async () => {
173
- try {
174
- const e = G(), {
175
- data: { data: t }
176
- } = await e.get("/admin/users/me");
177
- return t;
178
- } catch {
179
- return null;
180
- }
181
- }, j = async () => {
182
- const e = await $(), t = document.createElement("div");
183
- document.body.appendChild(t);
184
- const n = await b('nav button[aria-haspopup="menu"]'), i = "aria-expanded";
185
- new MutationObserver(async (d) => {
186
- if (d.some((r) => r.attributeName === i) && n.getAttribute(i) === "true") {
187
- const r = await b("[data-radix-menu-content]");
188
- if (!(r instanceof HTMLElement))
189
- return;
190
- Te(r);
191
- const u = await b('[role="menuitem"]', r), l = u.cloneNode(!0);
192
- if (e?.[E] && e?.[E].length > 1) {
193
- if (!(l instanceof HTMLElement))
194
- return;
195
- l.querySelector("span").innerText = `Select ${f}`, l.addEventListener("mouseenter", function() {
196
- this.setAttribute("data-highlighted", "true");
197
- }), l.addEventListener("mouseleave", function() {
198
- this.removeAttribute("data-highlighted");
199
- }), l.addEventListener("click", (y) => {
200
- y.preventDefault(), y.stopPropagation(), Se(
201
- t,
202
- r,
203
- e,
204
- localStorage.getItem("STRAPI_THEME") || "dark"
205
- );
206
- }), u.insertAdjacentElement("afterend", l);
207
- }
208
- }
209
- }).observe(n, {
210
- attributes: !0
211
- });
212
- }, F = () => window.location.pathname === "/admin/auth/login", ve = () => window.location.pathname.startsWith("/admin/plugins/upload"), Ee = () => {
213
- const e = U(), t = document.querySelector('[data-strapi-header="true"]');
214
- if (!e || H(e)) {
215
- const n = t?.querySelectorAll("button");
216
- n && n.forEach((i) => {
217
- i.style.display = "none";
218
- });
219
- }
220
- }, q = W(Ee, {
221
- minQuietPeriodMs: 250
222
- }), _ = async () => {
223
- const e = await b('nav ul > li a[href="/admin/plugins/upload"]');
224
- e && e.addEventListener("click", () => {
225
- q.call();
226
- }), ve() && q.call();
227
- }, v = async () => {
228
- if (F()) {
229
- document.body.removeAttribute(g);
230
- return;
231
- }
232
- if (await $()) {
233
- document.querySelector(`[${g}]`) || (await Promise.all([j(), _()]), document.body.setAttribute(g, "true"));
234
- return;
235
- }
236
- document.body.removeAttribute(g);
237
- }, Ae = async () => {
238
- F() || !await $() || (document.body.setAttribute(g, "true"), await Promise.all([j(), _()]));
239
- }, Re = {
240
- register(e) {
241
- e.registerPlugin({
242
- id: c,
243
- initializer: we,
244
- isReady: !1,
245
- name: c
246
- }), e.customFields.register({
247
- name: `unique-by-${f}`,
248
- pluginId: c,
249
- type: "string",
250
- intlLabel: {
251
- id: `${c}.custom-fields.unique-by-domain.label`,
252
- defaultMessage: "Unique by domain"
253
- },
254
- intlDescription: {
255
- id: `${c}.custom-fields.unique-by-tenant.description`,
256
- defaultMessage: "Ensures the value is unique within the domain."
257
- },
258
- components: {
259
- Input: () => import("./TenantCustomField-CtCNZEgB.mjs")
260
- }
261
- }), e.addSettingsLink(
262
- {
263
- id: `${c}.settings`,
264
- intlLabel: {
265
- id: `${c}.settings.label`,
266
- defaultMessage: "Multi-Domain Settings"
267
- }
268
- },
269
- {
270
- id: `${c}.settings.general`,
271
- intlLabel: {
272
- id: `${c}.settings.general.label`,
273
- defaultMessage: "General Settings"
274
- },
275
- to: `/settings/${c}`,
276
- Component: () => import("./Settings-BPM919an.mjs"),
277
- permissions: he.admin.access
278
- }
279
- );
280
- },
281
- async registerTrads({ locales: e }) {
282
- return Promise.all(
283
- e.map(async (t) => t in N ? N[t]().then(({ default: i }) => ({
284
- data: B(c, A(i)),
285
- locale: t
286
- })) : {
287
- data: B(c, A({})),
288
- locale: t
289
- })
290
- );
291
- },
292
- async bootstrap(e) {
293
- e.getPlugin("content-manager").injectComponent("listView", "actions", {
294
- name: "display-create-button",
295
- Component: ye
296
- });
297
- let t = window.location.pathname;
298
- window.addEventListener("popstate", async () => {
299
- t !== window.location.pathname && (t = window.location.pathname, await v());
300
- });
301
- const n = history.pushState, i = history.replaceState;
302
- history.pushState = function(...a) {
303
- n.apply(history, a), t !== window.location.pathname && (t = window.location.pathname, v());
304
- }, history.replaceState = function(...a) {
305
- i.apply(history, a), t !== window.location.pathname && (t = window.location.pathname, v());
306
- }, await Ae();
307
- }
308
- };
309
- export {
310
- he as a,
311
- f as b,
312
- Re as c,
313
- Oe as m,
314
- c as p
315
- };
@@ -1 +0,0 @@
1
- "use strict";const o=require("react/jsx-runtime"),q=require("@strapi/strapi/admin"),s=require("@tanstack/react-query"),l=require("./index-Ck1YIRr4.js"),u=require("./index-D9I-QR8y.js"),m=()=>{const e=q.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:a,data:c}=m();if(a)return null;const y=i=>e?c?.some(d=>d.action===i):!0;return e&&!e.every(i=>y(i.action))?o.jsx(r,{}):t?o.jsx(o.Fragment,{children:t}):null},F=(e,t,{defaultMessage:r,values:a}={})=>e({id:`${l.pluginId}.${t}`,defaultMessage:r},a),n={all:[l.modelRoute],lists:()=>[...n.all,"list"],list:e=>[...n.lists(),{filters:e}],details:()=>[...n.all,"detail"],detail:e=>[...n.details(),e]},Q=e=>s.useQuery({queryKey:[...n.lists(),JSON.stringify(e||{})],queryFn:()=>u.api.getTenants(e),staleTime:2*60*1e3}),g=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)}})},p=()=>{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.getMessage=F;exports.useCreateTenant=C;exports.useDeleteTenant=p;exports.useTenant=g;exports.useTenants=Q;exports.useUpdateTenant=f;