@sensinum/strapi-plugin-multi-domain 5.2.0-beta.1 → 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/README.md +64 -35
- package/dist/_chunks/About-DNyaGrYn.mjs +435 -0
- package/dist/_chunks/About-DaPMT-kj.js +38 -0
- package/dist/_chunks/{Settings-q2-wnMsh.mjs → Settings-B823hBAu.mjs} +2 -2
- package/dist/_chunks/{Settings-De2gPisD.js → Settings-B_1YuoN9.js} +1 -1
- package/dist/_chunks/{TenantCustomField-B3_kP4Hn.mjs → TenantCustomField-B9Ntpj-S.mjs} +1 -1
- package/dist/_chunks/{TenantCustomField-D-7Si38A.js → TenantCustomField-CHUfO3Xh.js} +1 -1
- package/dist/_chunks/{TenantEdit-Cb072LMV.mjs → TenantEdit-BFvwBQFd.mjs} +4 -4
- package/dist/_chunks/{TenantEdit-BkdAbMuN.js → TenantEdit-Bkw_eaGW.js} +1 -1
- package/dist/_chunks/{TenantList-CL42iP37.js → TenantList-C9nnIaGg.js} +1 -1
- package/dist/_chunks/{TenantList-kV9ECrto.mjs → TenantList-DRfWswjS.mjs} +4 -4
- package/dist/_chunks/{en-BPIaGv4M.mjs → en-Cf69p5po.mjs} +6 -2
- package/dist/_chunks/en-hAVH8fH0.js +1 -0
- package/dist/_chunks/{index-BlQO7jXj.mjs → index-2nR8Jd1x.mjs} +1 -1
- package/dist/_chunks/{index-DAX0vpn7.js → index-Cvs1ZCFy.js} +1 -1
- package/dist/_chunks/{index-ChL08Dcz.mjs → index-DEoxiYwP.mjs} +5 -5
- package/dist/_chunks/index-DuSOcmV4.js +1 -0
- package/dist/_chunks/useGetMessage-B1Xnqz3k.js +1 -0
- package/dist/_chunks/{useGetMessage-2uaqSNHA.mjs → useGetMessage-K3OG9Tv0.mjs} +1 -1
- package/dist/_chunks/{useSettings-Hd_Y-NfK.js → useSettings-BCMuYsbx.js} +1 -1
- package/dist/_chunks/{useSettings-BCXs1q_c.mjs → useSettings-QOof9ZTx.mjs} +1 -1
- package/dist/_chunks/{useTenants-CVYBr-JE.mjs → useTenants-CT-L6xX1.mjs} +2 -2
- package/dist/_chunks/{useTenants-DAdjIYEf.js → useTenants-_putKXAO.js} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +4 -2
- package/dist/server/index.mjs +5544 -5234
- package/package.json +1 -1
- package/dist/_chunks/en-D2iOtyKE.js +0 -1
- package/dist/_chunks/index-1D9AeLxE.mjs +0 -445
- package/dist/_chunks/index-C0pkYQjH.js +0 -3
- package/dist/_chunks/index-TelSPPuG.js +0 -1
- package/dist/_chunks/useGetMessage-R3JXzZcF.js +0 -1
|
@@ -4,7 +4,7 @@ import { unstable_useContentManagerContext as x, useNotification as j } from "@s
|
|
|
4
4
|
import { z as t } from "zod";
|
|
5
5
|
import M from "react";
|
|
6
6
|
import { useMutation as P } from "@tanstack/react-query";
|
|
7
|
-
import { a as T } from "./index-
|
|
7
|
+
import { a as T } from "./index-2nR8Jd1x.mjs";
|
|
8
8
|
import { Q as V } from "./QueryProvider-DLzv0qqi.mjs";
|
|
9
9
|
import { capitalize as z } from "remeda";
|
|
10
10
|
const f = t.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),a=require("@strapi/design-system"),z=require("@strapi/strapi/admin"),e=require("zod"),F=require("react"),S=require("@tanstack/react-query"),q=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),a=require("@strapi/design-system"),z=require("@strapi/strapi/admin"),e=require("zod"),F=require("react"),S=require("@tanstack/react-query"),q=require("./index-Cvs1ZCFy.js"),p=require("./QueryProvider-DUoM4JhC.js"),C=require("remeda"),M=t=>t&&t.__esModule?t:{default:t},_=M(F),g=e.z.object({modified:e.z.boolean(),isSubmitting:e.z.boolean(),disabled:e.z.boolean(),values:e.z.record(e.z.any()),initialValues:e.z.record(e.z.any()),errors:e.z.record(e.z.any()),onChange:e.z.function().args(e.z.object({target:e.z.object({name:e.z.string(),value:e.z.any()})})).returns(e.z.void()),resetForm:e.z.function().returns(e.z.void())}),P=t=>{const r=z.unstable_useContentManagerContext(),{form:o}=r,u=t?g.merge(t):g;return _.default.useMemo(()=>({...r,form:u.passthrough().parse(o)}),[r,o,u])},R=()=>S.useMutation({mutationFn:async t=>q.api.validateCustomField(t)}),T=e.z.object({setSubmitting:e.z.function().args(e.z.boolean()).returns(e.z.void())}),Q=({disabled:t,placeholder:r,required:o,hint:u,value:f,onChange:c,label:b,name:i,rawError:l})=>{const{id:y,model:v,form:d}=P(T),m=R(),{toggleNotification:j}=z.useNotification(),x=async h=>{try{d.setSubmitting(!0);const s=await m.mutateAsync({model:v,field:i,documentId:y,value:h.target.value});c({target:{value:s.value,name:i}})}catch(s){j({type:"danger",message:s instanceof Error?s.message:s.toString()})}finally{d.setSubmitting(!1)}};return n.jsxs(a.Field.Root,{name:i,hint:m.isPending?"Validating...":u,required:o,error:l?.defaultMessage,children:[n.jsx(a.Field.Label,{children:C.capitalize(b)}),n.jsx(a.TextInput,{name:i,value:f,onChange:c,onBlur:x,placeholder:r,disabled:t,error:!!l,"aria-describedby":`${i}-hint`,"aria-required":o}),n.jsx(a.Field.Hint,{}),n.jsx(a.Field.Error,{})]})},V=t=>n.jsx(p.QueryProvider,{children:n.jsx(Q,{...t})});exports.default=V;
|
|
@@ -4,12 +4,12 @@ import { Layouts as O, useStrapiApp as X, useNotification as Y, Page as N, Form
|
|
|
4
4
|
import _, { useCallback as H } from "react";
|
|
5
5
|
import { NavLink as ee, useNavigate as te, useParams as ne } from "react-router-dom";
|
|
6
6
|
import { isEmpty as oe } from "remeda";
|
|
7
|
-
import { b as q, p as C, m as L, c as P } from "./index-
|
|
8
|
-
import { u as b } from "./useGetMessage-
|
|
9
|
-
import { C as ie, b as ae, c as re, d as de } from "./useTenants-
|
|
7
|
+
import { b as q, p as C, m as L, c as P } from "./index-DEoxiYwP.mjs";
|
|
8
|
+
import { u as b } from "./useGetMessage-K3OG9Tv0.mjs";
|
|
9
|
+
import { C as ie, b as ae, c as re, d as de } from "./useTenants-CT-L6xX1.mjs";
|
|
10
10
|
import { ArrowLeft as le, Cross as se } from "@strapi/icons";
|
|
11
11
|
import { useQuery as A, useMutation as ce } from "@tanstack/react-query";
|
|
12
|
-
import { a as M } from "./index-
|
|
12
|
+
import { a as M } from "./index-2nR8Jd1x.mjs";
|
|
13
13
|
const me = ({
|
|
14
14
|
isEditing: t,
|
|
15
15
|
isSaving: d,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),p=require("@strapi/strapi/admin"),v=require("react"),S=require("react-router-dom"),B=require("remeda"),h=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),p=require("@strapi/strapi/admin"),v=require("react"),S=require("react-router-dom"),B=require("remeda"),h=require("./index-DuSOcmV4.js"),j=require("./useGetMessage-B1Xnqz3k.js"),T=require("./useTenants-_putKXAO.js"),I=require("@strapi/icons"),M=require("@tanstack/react-query"),w=require("./index-Cvs1ZCFy.js"),D=n=>n&&n.__esModule?n:{default:n},E=D(v),G=({isEditing:n,isSaving:r,onCancel:o})=>{const a=j.useGetMessage();return e.jsx(t.Flex,{justifyContent:"flex-start",gap:2,direction:"column",height:"100%",width:"100%",children:e.jsxs(t.Box,{background:"neutral0",padding:8,shadow:"filterShadow",hasRadius:!0,width:"100%",children:[e.jsx(t.Typography,{variant:"sigma",textTransform:"uppercase",textColor:"neutral600",tag:"h2",marginBottom:4,children:a("domain.edit.actions.entry")}),e.jsxs(t.Flex,{direction:"column",gap:2,children:[e.jsx(T.CheckPermissions,{permissions:n?h.permissions.admin.edit:h.permissions.admin.create,children:e.jsx(t.Button,{type:"submit",loading:r,width:"100%",children:a(n?"domain.edit.actions.update":"domain.edit.actions.create")})}),e.jsx(t.Button,{variant:"secondary",onClick:o,width:"100%",children:a("common.cancel")})]})]})})},N=({isEditing:n,tenantName:r})=>{const o=j.useGetMessage();return e.jsx(p.Layouts.Header,{title:e.jsx(t.Box,{padding:6,children:e.jsxs(t.Flex,{gap:2,direction:"column",alignItems:"flex-start",children:[e.jsx(t.Link,{variant:"tertiary",tag:S.NavLink,startIcon:e.jsx(I.ArrowLeft,{}),to:`/settings/${h.pluginId}/${h.modelRoute}`,children:o("common.back")}),e.jsx(t.Typography,{variant:"alpha",fontWeight:"bold",marginTop:2,children:n?r||o("domain.edit.title.edit",{values:{name:h.modelId}}):o("domain.edit.title.create")})]})}),as:"h2"})},H=({disabled:n=!1,error:r})=>{const o=j.useGetMessage(),a=p.useStrapiApp("CustomMediaInput",i=>i.fields?.media||{});return a?e.jsxs(t.Field.Root,{name:"logo",hint:o("domain.edit.form.logo.hint"),error:r,children:[e.jsx(a,{label:"Logo",name:"logo",disabled:n,attribute:{allowedTypes:["images"],multiple:!1}}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]}):null},L={all:["roles"],lists:()=>[...L.all,"list"]},P=()=>M.useQuery({queryKey:L.lists(),queryFn:()=>w.api.getRoles(),staleTime:10*60*1e3}),O=({value:n,onChange:r,disabled:o=!1,error:a,onLoadMore:i,onSearch:l})=>{const{data:d=[],isLoading:u}=P(),x=j.useGetMessage(),f=()=>{r({target:{name:"role",value:""}})},F=g=>{r({target:{name:"role",value:g}})},R=v.useCallback(g=>{const k=g.target.value;l&&l(k)},[l]),b=v.useCallback(()=>{i&&!u&&i()},[i,u]);return e.jsxs(t.Field.Root,{name:"role",hint:x("domain.edit.form.role.hint"),error:a,children:[e.jsx(t.Field.Label,{children:x("domain.edit.form.role.label")}),e.jsx(t.Combobox,{loading:u,hasMoreItems:!u,name:"role",disabled:o,value:n,onChange:F,placeholder:x("domain.edit.form.role.placeholder"),onInputChange:R,onLoadMore:b,children:d.map(g=>e.jsx(t.ComboboxOption,{value:g.id.toString(),children:g.name},g.id))}),n&&d.length>0&&e.jsxs(t.Flex,{paddingTop:2,paddingBottom:2,paddingLeft:4,paddingRight:4,hasRadius:!0,borderColor:"neutral200",background:"neutral0",justifyContent:"space-between",children:[e.jsx(t.Typography,{textColor:"neutral800",fontWeight:"bold",children:d.find(g=>g.id.toString()===n)?.name}),o?null:e.jsx(t.Box,{children:e.jsx(t.IconButton,{onClick:f,label:x("domain.edit.form.role.remove"),variant:"ghost",size:"S",children:e.jsx(I.Cross,{})})})]}),e.jsx(t.Field.Hint,{})]})},q={all:["tokens"],lists:()=>[...q.all,"list"]},$=()=>M.useQuery({queryKey:q.lists(),queryFn:()=>w.api.getTokens(),staleTime:10*60*1e3}),A=({value:n=[],onChange:r,disabled:o=!1,error:a})=>{const{data:i=[]}=$(),l=j.useGetMessage(),d=u=>{const x=u.map(f=>Number(f));r({target:{name:"tokens",value:x}})};return e.jsxs(t.Field.Root,{name:"tokens",hint:l("domain.edit.form.tokens.hint"),error:a,children:[e.jsx(t.Field.Label,{children:l("domain.edit.form.tokens.label")}),e.jsx(t.MultiSelect,{withTags:!0,name:"tokens",disabled:o,value:n.map(u=>u.toString()),onChange:d,placeholder:l("domain.edit.form.tokens.placeholder"),children:i.map(u=>e.jsx(t.MultiSelectOption,{value:u.id.toString(),children:u.name},u.id.toString()))}),e.jsx(t.Field.Hint,{})]})},W=({values:n,onChange:r,disabled:o,errors:a})=>{const i=j.useGetMessage(),l=d=>{r({target:{name:"customFields",value:d}})};return e.jsx(t.Box,{background:"neutral0",padding:8,shadow:"filterShadow",hasRadius:!0,width:"100%",children:e.jsxs(t.Flex,{direction:"column",alignItems:"stretch",gap:6,children:[e.jsxs(t.Flex,{gap:4,wrap:"wrap",children:[e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsxs(t.Field.Root,{name:"name",required:!0,hint:i("domain.edit.form.name.hint"),error:a.name,children:[e.jsx(t.Field.Label,{children:i("domain.edit.form.name.label")}),e.jsx(t.TextInput,{disabled:o,name:"name",value:n.name,onChange:r,placeholder:i("domain.edit.form.name.placeholder"),required:!0}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]})}),e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsxs(t.Field.Root,{name:"code",required:!0,hint:i("domain.edit.form.code.hint"),error:a.code,children:[e.jsx(t.Field.Label,{children:i("domain.edit.form.code.label")}),e.jsx(t.TextInput,{disabled:o,name:"code",value:n.code,onChange:r,placeholder:i("domain.edit.form.code.placeholder"),required:!0}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]})})]}),e.jsx(H,{value:n.logo,onChange:r,disabled:o,error:a.logo?.toString()}),e.jsxs(t.Flex,{gap:4,wrap:"wrap",children:[e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsx(O,{value:n.role,onChange:r,disabled:o,error:a.role?.toString()})}),e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsx(A,{value:n.tokens||[],onChange:r,disabled:o,error:a.tokens?.toString()})})]}),e.jsxs(t.Field.Root,{name:"damRootDirectory",hint:i("domain.edit.form.damRootDirectory.hint"),error:a.damRootDirectory,children:[e.jsx(t.Field.Label,{children:i("domain.edit.form.damRootDirectory.label")}),e.jsx(t.TextInput,{disabled:o,name:"damRootDirectory",value:n.damRootDirectory,onChange:r,placeholder:i("domain.edit.form.damRootDirectory.placeholder")}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]}),e.jsxs(t.Field.Root,{name:"customFields",hint:i("domain.edit.form.customFields.hint"),error:a.customFields,children:[e.jsx(t.Field.Label,{children:i("domain.edit.form.customFields.label")}),e.jsx(t.JSONInput,{name:"customFields",value:n.customFields,onChange:l,minHeight:"200px"}),e.jsx(t.Field.Hint,{})]})]})})},J=({message:n="Loading..."})=>e.jsx(t.Box,{padding:8,textAlign:"center",children:e.jsx(t.Loader,{children:n})}),_=()=>M.useMutation({mutationFn:n=>w.api.validateTenant(n),onError:n=>{console.error("Tenant validation failed:",n)}});class K{constructor(r){this.inner=r,this.name="ValidationError"}name}const V=()=>{const n=S.useNavigate(),{id:r}=S.useParams(),o=r!=="new",a=o?parseInt(r):void 0,{toggleNotification:i}=p.useNotification(),l=j.useGetMessage(),{data:d,isLoading:u}=T.useTenant(a),x=_(),f=T.useCreateTenant(),F=T.useUpdateTenant(),R=E.default.useMemo(()=>({name:d?.name||"",code:d?.code||"",role:d?.role?.id?.toString()||"",tokens:d?.tokens?.map(s=>s.id),damRootDirectory:d?.damRootDirectory||"",customFields:JSON.stringify(d?.customFields||{},null,2),logo:d?.logo||null}),[d]),b=d?.code==="strapi-super-admin",g=async s=>{try{let m={};try{m=JSON.parse(s.customFields||"{}")}catch{i({type:"danger",message:l("domain.edit.notifications.invalidJson")});return}if(o&&a){const c={...s,role:s.role?parseInt(s.role):void 0,tokens:s.tokens||[],customFields:m,logo:s.logo||null};await F.mutateAsync({id:a,data:c}),i({type:"success",message:l("domain.edit.notifications.updated")})}else{const c={...s,role:s.role?parseInt(s.role):void 0,tokens:s.tokens||[],customFields:m,logo:s.logo||null},y=await f.mutateAsync(c);i({type:"success",message:l("domain.edit.notifications.created")}),n(`/settings/${h.pluginId}/${h.modelRoute}/${y.id}`)}}catch(m){i({type:"danger",message:m instanceof Error?m.message:l("domain.edit.notifications.saveError")})}},k=async s=>{const m={};if(s.customFields)try{JSON.parse(s.customFields)}catch{m.customFields=l("domain.edit.validation.invalidJson")}if(s.name||s.code)try{const c={excludeId:a};s.name&&(c.name=s.name),s.code&&(c.code=s.code);const y=await x.mutateAsync(c);y.name&&(m.name=y.name||"Name is not available"),y.code&&(m.code=y.code||"Code is not available")}catch(c){i({type:"danger",message:c instanceof Error?c.message:c?.toString()})}if(!B.isEmpty(m))throw new K(Object.keys(m).map(c=>({path:c,message:m[c]})));return s},C=f.isPending||F.isPending;return u?e.jsx(J,{message:l("domain.edit.loading")}):e.jsxs(e.Fragment,{children:[e.jsx(p.Page.Title,{children:o?l("domain.edit.title.edit",{values:{name:d?.name||h.modelId}}):l("domain.edit.title.create")}),e.jsx(p.Page.Main,{children:e.jsx(p.Form,{onSubmit:g,initialValues:R,validate:k,method:"POST",width:"auto",height:"auto",children:({values:s,onChange:m,errors:c})=>e.jsxs(e.Fragment,{children:[e.jsx(N,{isEditing:o,tenantName:d?.name}),e.jsx(p.Layouts.Content,{children:e.jsxs(t.Grid.Root,{gap:4,children:[e.jsx(t.Grid.Item,{col:9,children:e.jsx(W,{values:s,onChange:m,disabled:b,errors:c})}),e.jsx(t.Grid.Item,{col:3,children:e.jsx(G,{isEditing:o,isSaving:C,onCancel:()=>n(`/settings/${h.pluginId}/${h.modelRoute}`)})})]})})]})})})]})};exports.default=V;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),x=require("@strapi/icons"),a=require("@strapi/strapi/admin"),v=require("react"),q=require("react-router-dom"),u=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("@strapi/design-system"),x=require("@strapi/icons"),a=require("@strapi/strapi/admin"),v=require("react"),q=require("react-router-dom"),u=require("./index-DuSOcmV4.js"),p=require("./useTenants-_putKXAO.js"),W=require("styled-components"),P=require("./useGetMessage-B1Xnqz3k.js"),G=require("./useSettings-BCMuYsbx.js"),A=n=>n&&n.__esModule?n:{default:n},H=A(v),O=A(W),Q=({isOpen:n,onClose:i,onConfirm:l,target:r})=>e.jsx(t.Dialog.Root,{open:n,onOpenChange:i,children:e.jsxs(t.Dialog.Content,{children:[e.jsx(t.Dialog.Header,{children:"Confirmation"}),e.jsx(t.Dialog.Body,{icon:e.jsx(x.Trash,{}),children:e.jsx(t.Dialog.Description,{textAlign:"center",children:e.jsxs(t.Flex,{gap:2,direction:"column",children:[e.jsx(x.WarningCircle,{fill:"danger600",width:"24",height:"24"}),"Are you sure you want to delete this ",r,"?",e.jsx("br",{}),"All your modifications will be lost"]})})}),e.jsxs(t.Dialog.Footer,{children:[e.jsx(t.Dialog.Action,{children:e.jsx(t.Button,{fullWidth:!0,onClick:i,variant:"tertiary",size:"S",children:e.jsx(t.Typography,{variant:"omega",children:"Cancel"})})}),e.jsx(t.Dialog.Action,{children:e.jsx(t.Button,{fullWidth:!0,onClick:l,variant:"danger",size:"S",children:e.jsx(t.Typography,{variant:"omega",children:"Confirm"})})})]})]})}),U=({isDisplayed:n,direction:i})=>n?i==="asc"?e.jsx(x.ArrowUp,{}):e.jsx(x.ArrowDown,{}):null,D=({label:n,field:i,sort:l,onSort:r})=>{const[c,h]=l.split(":");return e.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer"},onClick:()=>r(i)(h==="asc"?"desc":"asc"),children:[e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:n}),e.jsx("span",{style:{marginLeft:4},children:e.jsx(U,{isDisplayed:i===c,direction:h})})]})},J=O.default(t.Tr)(()=>({cursor:"pointer"})),K=({tenant:n,selectedTenants:i,handleSelectTenant:l,onDeleteTenant:r,isDeletePending:c=!1})=>{const h=q.useNavigate(),s=P.useGetMessage(),y=m=>()=>h(`/settings/${u.pluginId}/${u.modelRoute}/${m.id}`);return e.jsxs(J,{onClick:y(n),children:[e.jsx(t.Td,{children:e.jsx(t.Checkbox,{checked:i.includes(n.id),onCheckedChange:m=>l(n.id,m)})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:n.id})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:n.name})}),e.jsx(t.Td,{children:e.jsx(t.Typography,{textColor:"neutral800",children:n.code})}),e.jsx(t.Td,{children:n.role?e.jsx(t.Badge,{textColor:"neutral800",backgroundColor:"neutral100",children:n.role.name}):e.jsx(t.Typography,{textColor:"neutral600",children:"-"})}),e.jsx(t.Td,{children:e.jsxs(t.Flex,{gap:1,children:[e.jsx(p.CheckPermissions,{permissions:u.permissions.admin.edit,children:e.jsx(t.IconButton,{onClick:y(n),label:s("common.edit"),children:e.jsx(x.Pencil,{})})}),e.jsx(p.CheckPermissions,{permissions:u.permissions.admin.delete,children:e.jsx(t.IconButton,{onClick:r(n),label:s("common.delete"),disabled:c,children:e.jsx(x.Trash,{})})})]})})]})},V=()=>{const n=q.useNavigate(),{toggleNotification:i}=a.useNotification(),[l,r]=v.useState([]),[c,h]=v.useState(),s=P.useGetMessage(),y=p.useDeleteTenant(),{data:m,isLoading:w}=G.useSettings(),[{query:j},L]=a.useQueryParams({sort:"name:asc",_q:"",page:1,pageSize:10}),{sort:f,_q:M,page:R,pageSize:_}={...j,sort:j.sort||"name:asc",_q:j._q||"",page:j.page||1,pageSize:j.pageSize||10},{data:k,isLoading:B,error:T}=p.useTenants({sort:f,search:M,page:R,pageSize:_}),g=k?.results||[],C=k?.pagination||{pageCount:1,total:0};H.default.useEffect(()=>{T&&i({type:"danger",message:T instanceof Error?T.message:"An error occurred while fetching tenants"})},[T,i]);const I=o=>{r(o?g.map(d=>d.id):[])},z=(o,d)=>{r(d?b=>[...b,o]:b=>b.filter(N=>N!==o))},S=o=>d=>{L({...j,sort:`${o}:${d}`})},$=o=>async d=>{d.stopPropagation(),h(o)},E=async()=>{if(c)try{await y.mutateAsync(c.id),i({type:"success",message:s("domain.notifications.deleted",{values:{name:c.name}})}),h(void 0),r(o=>o.filter(d=>d!==c.id))}catch{i({type:"danger",message:s("domain.notifications.deleteError")})}},F=()=>{h(void 0)};return B||w?e.jsx(a.Page.Main,{children:e.jsx(a.Layouts.Content,{children:e.jsx(t.Loader,{children:s("domain.list.loading")})})}):e.jsxs(e.Fragment,{children:[e.jsx(a.Page.Title,{children:"Tenants"}),e.jsxs(a.Page.Main,{children:[e.jsx(a.Layouts.Header,{title:s("domain.list.title"),subtitle:s("domain.list.subtitle",{values:{count:g.length}}),as:"h2"}),e.jsx(a.Layouts.Action,{startActions:e.jsx(e.Fragment,{children:e.jsx(a.SearchInput,{label:s("domain.list.search",{defaultMessage:"Search domains"})})}),endActions:e.jsx(p.CheckPermissions,{permissions:u.permissions.admin.create,children:e.jsx(t.Button,{startIcon:e.jsx(x.Plus,{}),onClick:()=>{if(!m||m.features.domains<=C.total)return i({type:"warning",message:s("domain.list.limitReached",{values:{limit:m?.features.domains||0}})});n(`/settings/${u.pluginId}/${u.modelRoute}/new`)},children:s("common.create")})})}),e.jsx(a.Layouts.Content,{children:g.length===0?e.jsx(t.EmptyStateLayout,{icon:e.jsx(x.Search,{}),content:s("domain.list.emptyState",{defaultMessage:"No domains found matching your search criteria"})}):e.jsxs(e.Fragment,{children:[e.jsxs(t.Table,{colCount:6,rowCount:g.length+1,children:[e.jsx(t.Thead,{children:e.jsxs(t.Tr,{children:[e.jsx(t.Th,{children:e.jsx(t.Checkbox,{checked:l.length===g.length&&g.length>0,indeterminate:l.length>0?l.length<g.length:void 0,onCheckedChange:I})}),e.jsx(t.Th,{children:e.jsx(D,{label:s("domain.list.table.headers.id"),field:"id",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(D,{label:s("domain.list.table.headers.name"),field:"name",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(D,{label:s("domain.list.table.headers.code"),field:"code",sort:f,onSort:S})}),e.jsx(t.Th,{children:e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:s("domain.list.table.headers.role")})}),e.jsx(t.Th,{children:e.jsx(t.Typography,{variant:"sigma",textColor:"neutral600",children:s("domain.list.table.headers.actions")})})]})}),e.jsx(t.Tbody,{children:g.map(o=>e.jsx(K,{tenant:o,selectedTenants:l,handleSelectTenant:z,onDeleteTenant:$},o.id))})]}),e.jsx(t.Box,{paddingTop:4,children:e.jsxs(a.Pagination.Root,{pageCount:C.pageCount,total:C.total,children:[e.jsx(a.Pagination.PageSize,{}),e.jsx(a.Pagination.Links,{})]})})]})})]}),e.jsx(Q,{isOpen:!!c,onClose:F,onConfirm:E,target:c?.name||u.modelId})]})};exports.default=V;
|
|
@@ -4,11 +4,11 @@ import { WarningCircle as se, Trash as W, ArrowUp as ce, ArrowDown as de, Pencil
|
|
|
4
4
|
import { useNotification as ue, useQueryParams as pe, Page as D, Layouts as b, SearchInput as fe, Pagination as w } from "@strapi/strapi/admin";
|
|
5
5
|
import Ce, { useState as $ } from "react";
|
|
6
6
|
import { useNavigate as N } from "react-router-dom";
|
|
7
|
-
import { b as M, p as _, m as H, c as ye } from "./index-
|
|
8
|
-
import { C as z, u as Se, a as Te } from "./useTenants-
|
|
7
|
+
import { b as M, p as _, m as H, c as ye } from "./index-DEoxiYwP.mjs";
|
|
8
|
+
import { C as z, u as Se, a as Te } from "./useTenants-CT-L6xX1.mjs";
|
|
9
9
|
import be from "styled-components";
|
|
10
|
-
import { u as j } from "./useGetMessage-
|
|
11
|
-
import { u as ve } from "./useSettings-
|
|
10
|
+
import { u as j } from "./useGetMessage-K3OG9Tv0.mjs";
|
|
11
|
+
import { u as ve } from "./useSettings-QOof9ZTx.mjs";
|
|
12
12
|
const ke = ({
|
|
13
13
|
isOpen: t,
|
|
14
14
|
onClose: i,
|
|
@@ -20,15 +20,19 @@ const e = {
|
|
|
20
20
|
},
|
|
21
21
|
about: {
|
|
22
22
|
title: "About",
|
|
23
|
+
pluginName: "Multi Domain Plugin",
|
|
23
24
|
pluginInfo: {
|
|
24
25
|
title: "Plugin Info",
|
|
25
26
|
name: "Name",
|
|
26
|
-
version: "Version"
|
|
27
|
+
version: "Version",
|
|
28
|
+
openNpm: "Open NPM"
|
|
27
29
|
},
|
|
28
30
|
contact: {
|
|
29
31
|
title: "Contact Us",
|
|
30
32
|
website: "Website",
|
|
31
|
-
email: "Email"
|
|
33
|
+
email: "Email",
|
|
34
|
+
talkToOurExperts: "Talk to our experts",
|
|
35
|
+
sensiumCaption: "Sensinum is a company of the VirtusLab Group"
|
|
32
36
|
},
|
|
33
37
|
licenseDetails: {
|
|
34
38
|
title: "Licence Details",
|
|
@@ -0,0 +1 @@
|
|
|
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"},settings:{label:"Multi-Domain Settings",general:{label:"General Settings"},about:{label:"About"}},about:{title:"About",pluginName:"Multi Domain Plugin",pluginInfo:{title:"Plugin Info",name:"Name",version:"Version",openNpm:"Open NPM"},contact:{title:"Contact Us",website:"Website",email:"Email",talkToOurExperts:"Talk to our experts",sensiumCaption:"Sensinum is a company of the VirtusLab Group"},licenseDetails:{title:"Licence Details",planName:"Plan Name",validUntil:"Valid Until",limits:{seats:"Seats",domains:"Domains"},features:{title:"Features",schemas:"Schemas",decorators:"Decorators",extensions:"Extensions",enabled:"enabled",disabled:"disabled"}}},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,6 +1,6 @@
|
|
|
1
1
|
import { getFetchClient as g } from "@strapi/strapi/admin";
|
|
2
2
|
import t, { z as e } from "zod";
|
|
3
|
-
import { p as o, m as s } from "./index-
|
|
3
|
+
import { p as o, m as s } from "./index-DEoxiYwP.mjs";
|
|
4
4
|
e.object({
|
|
5
5
|
name: e.string().min(1, "Name is required").max(255, "Name must be less than 255 characters"),
|
|
6
6
|
code: e.string().min(1, "Code is required").max(100, "Code must be less than 100 characters").regex(/^[a-z0-9-]+$/, "Code must contain only lowercase letters, numbers, and hyphens")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const h=require("@strapi/strapi/admin"),e=require("zod"),r=require("./index-
|
|
1
|
+
"use strict";const h=require("@strapi/strapi/admin"),e=require("zod"),r=require("./index-DuSOcmV4.js"),g=s=>s&&s.__esModule?s:{default:s},t=g(e);e.z.object({name:e.z.string().min(1,"Name is required").max(255,"Name must be less than 255 characters"),code:e.z.string().min(1,"Code is required").max(100,"Code must be less than 100 characters").regex(/^[a-z0-9-]+$/,"Code must contain only lowercase letters, numbers, and hyphens")});e.z.object({isValid:e.z.boolean(),message:e.z.string().optional(),field:e.z.enum(["name","code"]).optional()});const i=t.default.union([t.default.string(),t.default.number()]).transform(s=>{const n=parseInt(s.toString(),10);if(isNaN(n)||n<=0)throw new t.default.ZodError([{message:"ID must be a positive integer",code:"custom",path:["id"]}]);return n}),f=e.z.object({id:i,documentId:e.z.string().min(1,"Document ID is required"),action:e.z.string().min(1,"Action is required"),actionParameters:e.z.record(e.z.any()).optional(),subject:e.z.string().min(1,"Subject is required").nullable().optional(),properties:e.z.record(e.z.any()).optional(),conditions:e.z.array(e.z.record(e.z.any())).optional()});e.z.object({sort:e.z.string().optional(),search:e.z.string().optional(),page:e.z.coerce.number().int().positive().optional(),pageSize:e.z.coerce.number().int().positive().optional()});const z=e.z.object({name:e.z.string().min(1,"Name is required"),code:e.z.string().min(1,"Code is required"),description:e.z.string().optional()}),c=z.merge(e.z.object({id:i,documentId:e.z.string().min(1,"Document ID is required")}));c.merge(e.z.object({permissions:f.array()}));const m=e.z.object({id:i,name:e.z.string().min(1,"Name is required")}),b=t.default.object({id:t.default.number(),name:t.default.string(),url:t.default.string(),width:t.default.number(),height:t.default.number(),ext:t.default.string(),size:t.default.number()}).passthrough(),p=t.default.object({name:t.default.string().min(1,"Name is required"),code:t.default.string().min(1,"Code is required"),customFields:t.default.record(t.default.any()).optional().nullable(),damRootDirectory:t.default.string().optional().nullable(),logo:b.optional().nullable()}),d=p.extend({id:i,documentId:t.default.string()});d.extend({role:c.optional().nullable()});const y=p.extend({role:i.optional().nullable(),tokens:t.default.array(i).optional().nullable()}),w=d.omit({id:!0,documentId:!0}).extend({role:i.optional().nullable(),tokens:t.default.array(i).optional().nullable()}),$=t.default.object({page:t.default.number(),pageCount:t.default.number(),pageSize:t.default.number(),total:t.default.number()}),I=e.z.object({results:e.z.array(d),pagination:$}),u=d.extend({role:c.optional().nullable(),tokens:e.z.array(m).optional().nullable()});class C{fetchClient=h.getFetchClient();async validateTenant(n){try{const a=await this.fetchClient.post(`/${r.pluginId}/validate`,n);return console.log("response.data",a.data),a.data}catch(a){throw a instanceof e.z.ZodError?new Error(`Validation error: ${a.errors.map(o=>o.message).join(", ")}`):a}}async getTenants(n){try{const a=await this.fetchClient.get(`/${r.pluginId}/${r.modelRoute}`,{params:n});return I.parse(a.data)}catch{throw new Error("Failed to fetch tenants")}}async getTenant(n){try{const a=await this.fetchClient.get(`/${r.pluginId}/${r.modelRoute}/${n}`);return u.parseAsync(a.data)}catch{throw new Error("Failed to fetch tenant")}}async createTenant(n){try{const a=y.parse(n),o=await this.fetchClient.post(`/${r.pluginId}/${r.modelRoute}`,a);return u.parseAsync(o.data)}catch(a){throw console.log("error",a),a instanceof e.z.ZodError?new Error(`Validation error: ${a.errors.map(o=>o.message).join(", ")}`):a}}async updateTenant(n,a){try{const o=w.parse(a),l=await this.fetchClient.put(`/${r.pluginId}/${r.modelRoute}/${n}`,o);return u.parseAsync(l.data)}catch(o){throw o instanceof e.z.ZodError?new Error(`Validation error: ${o.errors.map(l=>l.message).join(", ")}`):new Error("Failed to update tenant")}}async deleteTenant(n){try{await this.fetchClient.del(`/${r.pluginId}/${r.modelRoute}/${n}`)}catch{throw new Error("Failed to delete tenant")}}async getRoles(){try{const n=await this.fetchClient.get("/admin/roles");return e.z.array(c).parse(n.data.data)}catch{throw new Error("Failed to fetch roles")}}async getTokens(){try{const n=await this.fetchClient.get("/admin/api-tokens");return e.z.array(m).parse(n.data.data)}catch{throw new Error("Failed to fetch roles")}}async validateCustomField({model:n,documentId:a,field:o,value:l}){return(await this.fetchClient.post(`/${r.pluginId}/${r.modelRoute}/${n}/validate`,{documentId:a,field:o,value:l})).data}async getSettings(){return(await this.fetchClient.get(`/${r.pluginId}/license`)).data}}const S=new C;exports.api=S;
|
|
@@ -8,7 +8,7 @@ import { Avatar as M, Modal as h, Box as k, Field as L, Searchbar as ee, EmptySt
|
|
|
8
8
|
import { createRoot as le } from "react-dom/client";
|
|
9
9
|
import { Search as de } from "@strapi/icons";
|
|
10
10
|
import { QueryClient as ue, QueryClientProvider as me } from "@tanstack/react-query";
|
|
11
|
-
const he = "@sensinum/strapi-plugin-multi-domain", pe = "5.2.0
|
|
11
|
+
const he = "@sensinum/strapi-plugin-multi-domain", pe = "5.2.0", ge = "https://www.sensinum.com/contact", fe = "hello@sensinum.com", ye = {
|
|
12
12
|
name: "multi-domain"
|
|
13
13
|
}, je = {
|
|
14
14
|
name: he,
|
|
@@ -46,7 +46,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
46
46
|
t.current(a);
|
|
47
47
|
}, []), null;
|
|
48
48
|
}, B = {
|
|
49
|
-
en: () => import("./en-
|
|
49
|
+
en: () => import("./en-Cf69p5po.mjs")
|
|
50
50
|
}, q = (e, t) => {
|
|
51
51
|
if (!e)
|
|
52
52
|
throw new TypeError("Prefix can't be empty");
|
|
@@ -261,7 +261,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
261
261
|
defaultMessage: "Ensures the value is unique within the domain."
|
|
262
262
|
},
|
|
263
263
|
components: {
|
|
264
|
-
Input: () => import("./TenantCustomField-
|
|
264
|
+
Input: () => import("./TenantCustomField-B9Ntpj-S.mjs")
|
|
265
265
|
}
|
|
266
266
|
}), e.router.addSettingsLink({
|
|
267
267
|
id: `${a}.settings`,
|
|
@@ -277,7 +277,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
277
277
|
defaultMessage: "About"
|
|
278
278
|
},
|
|
279
279
|
to: `/settings/${a}/about`,
|
|
280
|
-
Component: () => import("./
|
|
280
|
+
Component: () => import("./About-DNyaGrYn.mjs"),
|
|
281
281
|
permissions: N.admin.access
|
|
282
282
|
},
|
|
283
283
|
{
|
|
@@ -287,7 +287,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
287
287
|
defaultMessage: "General Settings"
|
|
288
288
|
},
|
|
289
289
|
to: `/settings/${a}/${be}`,
|
|
290
|
-
Component: () => import("./Settings-
|
|
290
|
+
Component: () => import("./Settings-B823hBAu.mjs"),
|
|
291
291
|
permissions: N.admin.access
|
|
292
292
|
}
|
|
293
293
|
]
|
|
@@ -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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("@tanstack/react-query"),t=require("./index-
|
|
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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as l, Fragment as f } from "react/jsx-runtime";
|
|
2
2
|
import { useFetchClient as q } from "@strapi/strapi/admin";
|
|
3
3
|
import { useQuery as i, useQueryClient as o, useMutation as u } from "@tanstack/react-query";
|
|
4
|
-
import { a as s } from "./index-
|
|
5
|
-
import { m as F } from "./index-
|
|
4
|
+
import { a as s } from "./index-2nR8Jd1x.mjs";
|
|
5
|
+
import { m as F } from "./index-DEoxiYwP.mjs";
|
|
6
6
|
const T = () => {
|
|
7
7
|
const e = q();
|
|
8
8
|
return i({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("react/jsx-runtime"),d=require("@strapi/strapi/admin"),s=require("@tanstack/react-query"),u=require("./index-
|
|
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