@sensinum/strapi-plugin-multi-domain 5.2.1 → 5.3.1

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 (63) hide show
  1. package/dist/{_chunks/About-CrezKPYG.js → admin/About-Cqb0Poxw.js} +2 -2
  2. package/dist/{_chunks/About-DD6q90XE.mjs → admin/About-DaHQ_Yhm.mjs} +5 -5
  3. package/dist/admin/QueryProvider-CCX1cgmZ.js +1 -0
  4. package/dist/{_chunks/QueryProvider-DLzv0qqi.mjs → admin/QueryProvider-oO97LaUB.mjs} +2 -2
  5. package/dist/{_chunks/Settings-82rkWMJ-.js → admin/Settings-CDBzsWbm.js} +1 -1
  6. package/dist/{_chunks/Settings-DVTWa7UL.mjs → admin/Settings-CyMoV2x8.mjs} +3 -3
  7. package/dist/{_chunks/TenantCustomField-aaNqlkBO.js → admin/TenantCustomField-BVJXtOh1.js} +1 -1
  8. package/dist/{_chunks/TenantCustomField-MX6zdr0Y.mjs → admin/TenantCustomField-ZM7ZfiGu.mjs} +24 -24
  9. package/dist/admin/TenantEdit-DBJoQv4w.mjs +490 -0
  10. package/dist/admin/TenantEdit-GAMHwYkP.js +1 -0
  11. package/dist/{_chunks/TenantList-Dw1EqqA7.mjs → admin/TenantList-C6xsvthy.mjs} +43 -45
  12. package/dist/admin/TenantList-D8hgcBHM.js +1 -0
  13. package/dist/admin/index-BwgjJmHR.js +1 -0
  14. package/dist/{_chunks/index-DFrXw6xt.mjs → admin/index-CQxsvheX.mjs} +80 -80
  15. package/dist/admin/index-CwsztY3K.mjs +187 -0
  16. package/dist/admin/index-eSOlzCRc.js +1 -0
  17. package/dist/admin/index.js +1 -1
  18. package/dist/admin/index.mjs +1 -1
  19. package/dist/{_chunks/useGetMessage-BQOJqwKY.mjs → admin/useGetMessage-Ck4TSmSw.mjs} +1 -1
  20. package/dist/admin/useGetMessage-gI6hxpcF.js +1 -0
  21. package/dist/admin/useSettings-CkTWZxdH.js +1 -0
  22. package/dist/{_chunks/useSettings-HNeo0XZx.mjs → admin/useSettings-DY1d6P_T.mjs} +2 -2
  23. package/dist/admin/useTenants-Ck1OOTGx.js +1 -0
  24. package/dist/{_chunks/useTenants-D2d36FHf.mjs → admin/useTenants-sy0FweCJ.mjs} +4 -4
  25. package/dist/server/index.js +3 -3
  26. package/dist/server/index.mjs +3317 -6503
  27. package/package.json +20 -21
  28. package/dist/_chunks/QueryProvider-DUoM4JhC.js +0 -1
  29. package/dist/_chunks/TenantEdit-BA2xZHAl.js +0 -1
  30. package/dist/_chunks/TenantEdit-QroPNoOH.mjs +0 -494
  31. package/dist/_chunks/TenantList-BOEyqzpU.js +0 -1
  32. package/dist/_chunks/index-B6P81dIL.js +0 -1
  33. package/dist/_chunks/index-DVqQk-cu.mjs +0 -182
  34. package/dist/_chunks/index-lkcweU9g.js +0 -1
  35. package/dist/_chunks/useGetMessage-CkNMUbYX.js +0 -1
  36. package/dist/_chunks/useSettings-DArWTfyj.js +0 -1
  37. package/dist/_chunks/useTenants-DA6GxylQ.js +0 -1
  38. package/dist/shared/config.d.ts +0 -7
  39. package/dist/shared/config.d.ts.map +0 -1
  40. package/dist/shared/permissions.d.ts +0 -35
  41. package/dist/shared/permissions.d.ts.map +0 -1
  42. package/dist/shared/pluginIds.d.ts +0 -9
  43. package/dist/shared/pluginIds.d.ts.map +0 -1
  44. package/dist/shared/schemas/admin.d.ts +0 -26
  45. package/dist/shared/schemas/admin.d.ts.map +0 -1
  46. package/dist/shared/schemas/index.d.ts +0 -8
  47. package/dist/shared/schemas/index.d.ts.map +0 -1
  48. package/dist/shared/schemas/permision.schema.d.ts +0 -28
  49. package/dist/shared/schemas/permision.schema.d.ts.map +0 -1
  50. package/dist/shared/schemas/query-params.schema.d.ts +0 -19
  51. package/dist/shared/schemas/query-params.schema.d.ts.map +0 -1
  52. package/dist/shared/schemas/role.schema.d.ts +0 -101
  53. package/dist/shared/schemas/role.schema.d.ts.map +0 -1
  54. package/dist/shared/schemas/tenant.schema.d.ts +0 -428
  55. package/dist/shared/schemas/tenant.schema.d.ts.map +0 -1
  56. package/dist/shared/schemas/token.schema.d.ts +0 -13
  57. package/dist/shared/schemas/token.schema.d.ts.map +0 -1
  58. package/dist/shared/schemas/uniq-validation.schema.d.ts +0 -18
  59. package/dist/shared/schemas/uniq-validation.schema.d.ts.map +0 -1
  60. package/dist/shared/schemas/utils.d.ts +0 -3
  61. package/dist/shared/schemas/utils.d.ts.map +0 -1
  62. /package/dist/{_chunks → admin}/en-Cf69p5po.mjs +0 -0
  63. /package/dist/{_chunks → admin}/en-hAVH8fH0.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sensinum/strapi-plugin-multi-domain",
3
- "version": "5.2.1",
3
+ "version": "5.3.1",
4
4
  "description": "Allow to provide multi domain support",
5
5
  "homepage": "https://www.sensinum.com/contact",
6
6
  "email": "hello@sensinum.com",
@@ -39,7 +39,7 @@
39
39
  ],
40
40
  "scripts": {
41
41
  "prebuild": "patch-package",
42
- "postbuild": "rm -rf dist/server/src && rm -rf dist/admin/src",
42
+ "postbuild": "rm -rf dist/server/src && rm -rf dist/admin/src && node scripts/cleaner.js",
43
43
  "build": "strapi-plugin build --minify",
44
44
  "watch": "strapi-plugin watch",
45
45
  "watch:link": "strapi-plugin watch:link",
@@ -52,8 +52,8 @@
52
52
  "test:ci": "CI=true jest --coverage --ci"
53
53
  },
54
54
  "dependencies": {
55
- "@strapi/design-system": "^2.0.0-rc.27",
56
- "@strapi/icons": "^2.0.0-rc.27",
55
+ "@strapi/design-system": "2.2.0",
56
+ "@strapi/icons": "2.2.0",
57
57
  "@tanstack/react-query": "^5.83.0",
58
58
  "date-fns": "^4.1.0",
59
59
  "debug": "^4.3.7",
@@ -65,39 +65,39 @@
65
65
  "zod": "^3.25.67"
66
66
  },
67
67
  "devDependencies": {
68
- "@strapi/admin": "^5.30.0",
69
- "@strapi/content-manager": "^5.30.0",
70
- "@strapi/sdk-plugin": "^5.3.2",
71
- "@strapi/strapi": "^5.30.0",
72
- "@strapi/typescript-utils": "^5.30.0",
68
+ "@strapi/admin": "5.47.0",
69
+ "@strapi/content-manager": "5.47.0",
70
+ "@strapi/sdk-plugin": "6.1.0",
71
+ "@strapi/strapi": "5.47.0",
72
+ "@strapi/typescript-utils": "5.47.0",
73
73
  "@types/debug": "^4.1.12",
74
74
  "@types/jest": "^30.0.0",
75
75
  "@types/react": "^18.3.8",
76
76
  "@types/react-dom": "^18.3.0",
77
+ "patch-package": "^8.0.0",
77
78
  "jest": "^30.0.5",
78
79
  "jest-junit": "^16.0.0",
79
- "patch-package": "^8.0.0",
80
80
  "prettier": "^3.6.2",
81
81
  "react": "^18.3.1",
82
82
  "react-dom": "^18.3.1",
83
83
  "react-router-dom": "^6.30.1",
84
84
  "styled-components": "^6.1.19",
85
- "ts-jest": "^29.4.1",
86
- "ts-node": "^10.9.2",
85
+ "ts-node": "10.9.2",
86
+ "ts-jest": "29.4.11",
87
87
  "typescript": "^5.8.3",
88
- "vite-plugin-javascript-obfuscator": "^3.1.0"
88
+ "javascript-obfuscator": "4.2.2"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@strapi/admin": "*",
92
92
  "@strapi/content-manager": "*",
93
- "@strapi/sdk-plugin": "^5.3.2",
93
+ "@strapi/sdk-plugin": "*",
94
94
  "@strapi/strapi": "*",
95
95
  "@strapi/utils": "*",
96
- "koa": "^3.0.0",
97
- "react": "^18.3.1",
98
- "react-dom": "^18.3.1",
99
- "react-router-dom": "^6.30.1",
100
- "styled-components": "^6.1.19",
96
+ "koa": "*",
97
+ "react": "*",
98
+ "react-dom": "*",
99
+ "react-router-dom": "*",
100
+ "styled-components": "*",
101
101
  "undici": "*"
102
102
  },
103
103
  "engines": {
@@ -111,8 +111,7 @@
111
111
  ]
112
112
  },
113
113
  "resolutions": {
114
- "minimatch": "^3.0.0",
115
- "@types/minimatch": "^3.0.0"
114
+ "javascript-obfuscator": "4.2.2"
116
115
  },
117
116
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
118
117
  }
@@ -1 +0,0 @@
1
- "use strict";const t=require("react/jsx-runtime"),e=require("@tanstack/react-query"),i=new e.QueryClient({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,staleTime:5*60*1e3,gcTime:10*60*1e3},mutations:{retry:!1}}}),s=({children:r})=>t.jsx(e.QueryClientProvider,{client:i,children:r});exports.QueryProvider=s;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),p=require("@strapi/strapi/admin"),v=require("react"),S=require("react-router-dom"),B=require("remeda"),h=require("./index-B6P81dIL.js"),j=require("./useGetMessage-CkNMUbYX.js"),T=require("./useTenants-DA6GxylQ.js"),I=require("@strapi/icons"),M=require("@tanstack/react-query"),w=require("./index-lkcweU9g.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;
@@ -1,494 +0,0 @@
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-DFrXw6xt.mjs";
8
- import { u as b } from "./useGetMessage-BQOJqwKY.mjs";
9
- import { C as ie, b as ae, c as re, d as de } from "./useTenants-D2d36FHf.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-DVqQk-cu.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
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),m=require("@strapi/icons"),a=require("@strapi/strapi/admin"),v=require("react"),q=require("react-router-dom"),x=require("./index-B6P81dIL.js"),p=require("./useTenants-DA6GxylQ.js"),W=require("styled-components"),P=require("./useGetMessage-CkNMUbYX.js"),G=require("./useSettings-DArWTfyj.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(m.Trash,{}),children:e.jsx(t.Dialog.Description,{textAlign:"center",children:e.jsxs(t.Flex,{gap:2,direction:"column",children:[e.jsx(m.WarningCircle,{fill:"danger600",width:"24",height:"24"}),"Are you sure you want to delete this ",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(m.ArrowUp,{}):e.jsx(m.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=u=>()=>h(`/settings/${x.pluginId}/${x.modelRoute}/${u.id}`);return e.jsxs(J,{onClick:y(n),children:[e.jsx(t.Td,{children:e.jsx(t.Checkbox,{checked:i.includes(n.id),onCheckedChange:u=>l(n.id,u)})}),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:x.permissions.admin.edit,children:e.jsx(t.IconButton,{onClick:y(n),label:s("common.edit"),children:e.jsx(m.Pencil,{})})}),e.jsx(p.CheckPermissions,{permissions:x.permissions.admin.delete,children:e.jsx(t.IconButton,{onClick:r(n),label:s("common.delete"),disabled:c,children:e.jsx(m.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:u,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:x.permissions.admin.create,children:e.jsx(t.Button,{startIcon:e.jsx(m.Plus,{}),onClick:()=>{if(!u?.features?.unlimited&&u?.features?.domains!=null&&u?.features?.domains<=C.total)return i({type:"warning",message:s("domain.list.limitReached",{values:{limit:u?.features.domains||0}})});n(`/settings/${x.pluginId}/${x.modelRoute}/new`)},children:s("common.create")})})}),e.jsx(a.Layouts.Content,{children:g.length===0?e.jsx(t.EmptyStateLayout,{icon:e.jsx(m.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||x.modelId})]})};exports.default=V;
@@ -1 +0,0 @@
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.1",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-aaNqlkBO.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-CrezKPYG.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-82rkWMJ-.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;