@sensinum/strapi-plugin-multi-domain 5.3.2 → 5.4.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 +23 -0
- package/dist/admin/{About-DfCon-RP.mjs → About--uEAqLIX.mjs} +3 -3
- package/dist/admin/{About-DfcPwQ3q.js → About-CpMJJUxU.js} +1 -1
- package/dist/admin/{Settings-tt-Wetcr.js → Settings-SyBK2mXN.js} +1 -1
- package/dist/admin/{Settings-Dj3h2ayB.mjs → Settings-yCKWEkTW.mjs} +2 -2
- package/dist/admin/{TenantCustomField-Bf6uUoKE.js → TenantCustomField-DLQLr0HX.js} +1 -1
- package/dist/admin/{TenantCustomField-CS8x0CkO.mjs → TenantCustomField-zLI8HKGa.mjs} +1 -1
- package/dist/admin/{TenantEdit-BY_7PPAr.mjs → TenantEdit-Bhpv-xqt.mjs} +4 -4
- package/dist/admin/{TenantEdit-BT3-tB_B.js → TenantEdit-DUZWciyV.js} +1 -1
- package/dist/admin/{TenantList-DrfJNPpi.js → TenantList-Cs5Agguv.js} +1 -1
- package/dist/admin/{TenantList-dIxGcZPl.mjs → TenantList-DFa4aJ9w.mjs} +4 -4
- package/dist/admin/{index-Cci_046h.js → index-B7hXre99.js} +1 -1
- package/dist/admin/{index-Doprxev-.mjs → index-CSqflswp.mjs} +1 -1
- package/dist/admin/{index-7tHbI_K_.mjs → index-ChZO7NH2.mjs} +4 -4
- package/dist/admin/{index-oNXgzV7S.js → index-DjpG-ImS.js} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/useGetMessage-C-9R7SfL.js +1 -0
- package/dist/admin/{useGetMessage-CTdHvgbI.mjs → useGetMessage-CToHlpPZ.mjs} +1 -1
- package/dist/admin/{useSettings-bLTyn7Pl.mjs → useSettings-FYcMKMRt.mjs} +1 -1
- package/dist/admin/{useSettings-C7vR1hfw.js → useSettings-Rpo2aG-K.js} +1 -1
- package/dist/admin/{useTenants-vVkOIEvT.js → useTenants-BU_qERzP.js} +1 -1
- package/dist/admin/{useTenants-Da8khjOe.mjs → useTenants-CmlcxJMg.mjs} +2 -2
- package/dist/server/index.js +3 -4
- package/dist/server/index.mjs +3706 -3311
- package/package.json +1 -1
- package/dist/admin/useGetMessage-DS88gOrN.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@strapi/design-system"),i=require("react"),r=require("react-router-dom"),o=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@strapi/design-system"),i=require("react"),r=require("react-router-dom"),o=require("./index-DjpG-ImS.js"),u=require("./QueryProvider-CCX1cgmZ.js"),a=t=>t&&t.__esModule?t:{default:t},n=a(i),l=n.default.lazy(()=>Promise.resolve().then(()=>require("./TenantList-Cs5Agguv.js"))),c=n.default.lazy(()=>Promise.resolve().then(()=>require("./TenantEdit-DUZWciyV.js"))),d=()=>{const t=localStorage.getItem("STRAPI_THEME")==="light"?s.lightTheme:s.darkTheme;return e.jsx(s.DesignSystemProvider,{theme:t,children:e.jsx(u.QueryProvider,{children:e.jsxs(r.Routes,{children:[e.jsx(r.Route,{path:"",element:e.jsx(l,{})}),e.jsx(r.Route,{path:"/:id",element:e.jsx(c,{})}),e.jsx(r.Route,{path:"*",element:e.jsx(r.Navigate,{to:`/settings/${o.pluginId}/${o.modelRoute}`,replace:!0})})]})})})};exports.default=d;
|
|
@@ -2,9 +2,9 @@ import { jsx as e, jsxs as m } from "react/jsx-runtime";
|
|
|
2
2
|
import { lightTheme as i, darkTheme as a, DesignSystemProvider as n } from "@strapi/design-system";
|
|
3
3
|
import r from "react";
|
|
4
4
|
import { Routes as s, Route as t, Navigate as l } from "react-router-dom";
|
|
5
|
-
import { p, m as d } from "./index-
|
|
5
|
+
import { p, m as d } from "./index-ChZO7NH2.mjs";
|
|
6
6
|
import { Q as h } from "./QueryProvider-oO97LaUB.mjs";
|
|
7
|
-
const c = r.lazy(() => import("./TenantList-
|
|
7
|
+
const c = r.lazy(() => import("./TenantList-DFa4aJ9w.mjs")), g = r.lazy(() => import("./TenantEdit-Bhpv-xqt.mjs")), P = () => {
|
|
8
8
|
const o = localStorage.getItem("STRAPI_THEME") === "light" ? i : a;
|
|
9
9
|
return /* @__PURE__ */ e(n, { theme: o, children: /* @__PURE__ */ e(h, { children: /* @__PURE__ */ m(s, { children: [
|
|
10
10
|
/* @__PURE__ */ e(t, { path: "", element: /* @__PURE__ */ e(c, {}) }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),a=require("@strapi/design-system"),f=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"),f=require("@strapi/strapi/admin"),e=require("zod"),F=require("react"),S=require("@tanstack/react-query"),q=require("./index-B7hXre99.js"),p=require("./QueryProvider-CCX1cgmZ.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=f.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:z,onChange:c,label:b,name:i,rawError:l})=>{const{id:y,model:v,form:d}=P(T),m=R(),{toggleNotification:j}=f.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:z,onChange:c,onBlur:x,placeholder:r,disabled:t,hasError:!!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,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-CSqflswp.mjs";
|
|
8
8
|
import { Q as V } from "./QueryProvider-oO97LaUB.mjs";
|
|
9
9
|
import { capitalize as z } from "remeda";
|
|
10
10
|
const f = t.object({
|
|
@@ -7,12 +7,12 @@ import { Layouts as P, useStrapiApp as ee, useNotification as te, Page as H, For
|
|
|
7
7
|
import oe, { useCallback as q } from "react";
|
|
8
8
|
import { NavLink as ie, useNavigate as ae, useParams as re } from "react-router-dom";
|
|
9
9
|
import { isEmpty as de } from "remeda";
|
|
10
|
-
import { b as A, c as $, p as L, m as M } from "./index-
|
|
11
|
-
import { u as y } from "./useGetMessage-
|
|
12
|
-
import { C as se, b as le, c as ce, d as me } from "./useTenants-
|
|
10
|
+
import { b as A, c as $, p as L, m as M } from "./index-ChZO7NH2.mjs";
|
|
11
|
+
import { u as y } from "./useGetMessage-CToHlpPZ.mjs";
|
|
12
|
+
import { C as se, b as le, c as ce, d as me } from "./useTenants-CmlcxJMg.mjs";
|
|
13
13
|
import { ArrowLeft as ue, Cross as ge } from "@strapi/icons";
|
|
14
14
|
import { useQuery as j, useMutation as he } from "@tanstack/react-query";
|
|
15
|
-
import { a as I } from "./index-
|
|
15
|
+
import { a as I } from "./index-CSqflswp.mjs";
|
|
16
16
|
const pe = ({
|
|
17
17
|
isEditing: t,
|
|
18
18
|
isSaving: n,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var B=Object.defineProperty;var G=(n,o,i)=>o in n?B(n,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[o]=i;var L=(n,o,i)=>G(n,typeof o!="symbol"?o+"":o,i);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"),M=require("react-router-dom"),N=require("remeda"),h=require("./index-
|
|
1
|
+
"use strict";var B=Object.defineProperty;var G=(n,o,i)=>o in n?B(n,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[o]=i;var L=(n,o,i)=>G(n,typeof o!="symbol"?o+"":o,i);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"),M=require("react-router-dom"),N=require("remeda"),h=require("./index-DjpG-ImS.js"),j=require("./useGetMessage-C-9R7SfL.js"),R=require("./useTenants-BU_qERzP.js"),q=require("@strapi/icons"),w=require("@tanstack/react-query"),I=require("./index-B7hXre99.js"),H=n=>n&&n.__esModule?n:{default:n},P=H(v),O=({isEditing:n,isSaving:o,onCancel:i})=>{const s=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:s("domain.edit.actions.entry")}),e.jsxs(t.Flex,{direction:"column",gap:2,children:[e.jsx(R.CheckPermissions,{permissions:n?h.permissions.admin.edit:h.permissions.admin.create,children:e.jsx(t.Button,{type:"submit",loading:o,width:"100%",children:s(n?"domain.edit.actions.update":"domain.edit.actions.create")})}),e.jsx(t.Button,{variant:"secondary",onClick:i,width:"100%",children:s("common.cancel")})]})]})})},A=({isEditing:n,tenantName:o})=>{const i=j.useGetMessage(),s=n?o||i("domain.edit.title.edit",{values:{name:h.modelId}}):i("domain.edit.title.create");return e.jsx(p.Layouts.Header,{title:typeof s=="string"?s:String(s),navigationAction:e.jsx(t.Link,{tag:M.NavLink,startIcon:e.jsx(q.ArrowLeft,{}),to:`/settings/${h.pluginId}/${h.modelRoute}`,children:i("common.back")})})},$=({disabled:n=!1,error:o})=>{const i=j.useGetMessage(),s=p.useStrapiApp("CustomMediaInput",a=>a.fields?.media||{});return s?e.jsxs(t.Field.Root,{name:"logo",hint:i("domain.edit.form.logo.hint"),error:o,children:[e.jsx(s,{label:"Logo",name:"logo",disabled:n,attribute:{allowedTypes:["images"],multiple:!1}}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]}):null},C={all:["roles"],lists:()=>[...C.all,"list"]},J=()=>w.useQuery({queryKey:C.lists(),queryFn:()=>I.api.getRoles(),staleTime:600*1e3}),W=({value:n,onChange:o,disabled:i=!1,error:s,onLoadMore:a,onSearch:l})=>{const{data:d=[],isLoading:u}=J(),x=j.useGetMessage(),f=()=>{o({target:{name:"role",value:""}})},F=g=>{o({target:{name:"role",value:g}})},b=v.useCallback(g=>{const S=g.target.value;l&&l(S)},[l]),k=v.useCallback(()=>{a&&!u&&a()},[a,u]);return e.jsxs(t.Field.Root,{name:"role",hint:x("domain.edit.form.role.hint"),error:s,children:[e.jsx(t.Field.Label,{children:x("domain.edit.form.role.label")}),e.jsx(t.Combobox,{loading:u,hasMoreItems:!u,name:"role",disabled:i,value:n,onChange:F,placeholder:x("domain.edit.form.role.placeholder"),onInputChange:b,onLoadMore:k,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}),i?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(q.Cross,{})})})]}),e.jsx(t.Field.Hint,{})]})},D={all:["tokens"],lists:()=>[...D.all,"list"]},_=()=>w.useQuery({queryKey:D.lists(),queryFn:()=>I.api.getTokens(),staleTime:600*1e3}),K=({value:n=[],onChange:o,disabled:i=!1,error:s})=>{const{data:a=[]}=_(),l=j.useGetMessage(),d=u=>{const x=u.map(f=>Number(f));o({target:{name:"tokens",value:x}})};return e.jsxs(t.Field.Root,{name:"tokens",hint:l("domain.edit.form.tokens.hint"),error:s,children:[e.jsx(t.Field.Label,{children:l("domain.edit.form.tokens.label")}),e.jsx(t.MultiSelect,{withTags:!0,name:"tokens",disabled:i,value:n.map(u=>u.toString()),onChange:d,placeholder:l("domain.edit.form.tokens.placeholder"),children:a.map(u=>e.jsx(t.MultiSelectOption,{value:u.id.toString(),children:u.name},u.id.toString()))}),e.jsx(t.Field.Hint,{})]})},T=n=>{if(typeof n=="string")return n;if(n&&typeof n=="object"&&"defaultMessage"in n){const o=n.defaultMessage;return typeof o=="string"?o:void 0}},V=({values:n,onChange:o,disabled:i,errors:s})=>{const a=j.useGetMessage(),l=d=>{o({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:a("domain.edit.form.name.hint"),error:T(s.name),children:[e.jsx(t.Field.Label,{children:a("domain.edit.form.name.label")}),e.jsx(t.TextInput,{disabled:i,name:"name",value:n.name,onChange:o,placeholder:a("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:a("domain.edit.form.code.hint"),error:T(s.code),children:[e.jsx(t.Field.Label,{children:a("domain.edit.form.code.label")}),e.jsx(t.TextInput,{disabled:i,name:"code",value:n.code,onChange:o,placeholder:a("domain.edit.form.code.placeholder"),required:!0}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]})})]}),e.jsx($,{value:n.logo,onChange:o,disabled:i,error:s.logo?.toString()}),e.jsxs(t.Flex,{gap:4,wrap:"wrap",children:[e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsx(W,{value:n.role,onChange:o,disabled:i,error:s.role?.toString()})}),e.jsx(t.Box,{flex:"1",minWidth:"300px",children:e.jsx(K,{value:n.tokens||[],onChange:o,disabled:i,error:s.tokens?.toString()})})]}),e.jsxs(t.Field.Root,{name:"damRootDirectory",hint:a("domain.edit.form.damRootDirectory.hint"),error:T(s.damRootDirectory),children:[e.jsx(t.Field.Label,{children:a("domain.edit.form.damRootDirectory.label")}),e.jsx(t.TextInput,{disabled:i,name:"damRootDirectory",value:n.damRootDirectory,onChange:o,placeholder:a("domain.edit.form.damRootDirectory.placeholder")}),e.jsx(t.Field.Hint,{}),e.jsx(t.Field.Error,{})]}),e.jsxs(t.Field.Root,{name:"customFields",hint:a("domain.edit.form.customFields.hint"),error:T(s.customFields),children:[e.jsx(t.Field.Label,{children:a("domain.edit.form.customFields.label")}),e.jsx(t.JSONInput,{value:n.customFields,onChange:l,minHeight:"200px"}),e.jsx(t.Field.Hint,{})]})]})})},Q=({message:n="Loading..."})=>e.jsx(t.Box,{padding:8,textAlign:"center",children:e.jsx(t.Loader,{children:n})}),z=()=>w.useMutation({mutationFn:n=>I.api.validateTenant(n),onError:n=>{console.error("Tenant validation failed:",n)}});class U{constructor(o){L(this,"name");this.inner=o,this.name="ValidationError"}}const X=()=>{const n=M.useNavigate(),{id:o}=M.useParams(),i=o!=="new",s=i?parseInt(o):void 0,{toggleNotification:a}=p.useNotification(),l=j.useGetMessage(),{data:d,isLoading:u}=R.useTenant(s),x=z(),f=R.useCreateTenant(),F=R.useUpdateTenant(),b=P.default.useMemo(()=>({name:d?.name||"",code:d?.code||"",role:d?.role?.id?.toString()||"",tokens:d?.tokens?.map(r=>r.id),damRootDirectory:d?.damRootDirectory||"",customFields:JSON.stringify(d?.customFields||{},null,2),logo:d?.logo||null}),[d]),k=d?.code==="strapi-super-admin",g=async r=>{try{let m={};try{m=JSON.parse(r.customFields||"{}")}catch{a({type:"danger",message:l("domain.edit.notifications.invalidJson")});return}if(i&&s){const c={...r,role:r.role?parseInt(r.role):void 0,tokens:r.tokens||[],customFields:m,logo:r.logo||null};await F.mutateAsync({id:s,data:c}),a({type:"success",message:l("domain.edit.notifications.updated")})}else{const c={...r,role:r.role?parseInt(r.role):void 0,tokens:r.tokens||[],customFields:m,logo:r.logo||null},y=await f.mutateAsync(c);a({type:"success",message:l("domain.edit.notifications.created")}),n(`/settings/${h.pluginId}/${h.modelRoute}/${y.id}`)}}catch(m){a({type:"danger",message:m instanceof Error?m.message:l("domain.edit.notifications.saveError")})}},S=async r=>{const m={};if(r.customFields)try{JSON.parse(r.customFields)}catch{m.customFields=l("domain.edit.validation.invalidJson")}if(r.name||r.code)try{const c={excludeId:s};r.name&&(c.name=r.name),r.code&&(c.code=r.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){a({type:"danger",message:c instanceof Error?c.message:c?.toString()})}if(!N.isEmpty(m))throw new U(Object.keys(m).map(c=>({path:c,message:m[c]})));return r},E=f.isPending||F.isPending;return u?e.jsx(Q,{message:l("domain.edit.loading")}):e.jsxs(e.Fragment,{children:[e.jsx(p.Page.Title,{children:i?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:b,validate:S,method:"POST",width:"auto",height:"auto",children:({values:r,onChange:m,errors:c})=>e.jsxs(e.Fragment,{children:[e.jsx(A,{isEditing:i,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(V,{values:r,onChange:m,disabled:k,errors:c})}),e.jsx(t.Grid.Item,{col:3,children:e.jsx(O,{isEditing:i,isSaving:E,onCancel:()=>n(`/settings/${h.pluginId}/${h.modelRoute}`)})})]})})]})})})]})};exports.default=X;
|
|
@@ -1 +1 @@
|
|
|
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"),k=require("react"),q=require("react-router-dom"),x=require("./index-
|
|
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"),k=require("react"),q=require("react-router-dom"),x=require("./index-DjpG-ImS.js"),p=require("./useTenants-BU_qERzP.js"),W=require("styled-components"),P=require("./useGetMessage-C-9R7SfL.js"),G=require("./useSettings-Rpo2aG-K.js"),A=n=>n&&n.__esModule?n:{default:n},H=A(k),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]=k.useState([]),[c,h]=k.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:v,isLoading:B,error:T}=p.useTenants({sort:f,search:M,page:R,pageSize:_}),g=v?.results||[],C=v?.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===!0?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}})}),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>0&&l.length<g.length?"indeterminate":l.length===g.length&&g.length>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;
|
|
@@ -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-ChZO7NH2.mjs";
|
|
8
|
+
import { C as z, u as Se, a as Te } from "./useTenants-CmlcxJMg.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-CToHlpPZ.mjs";
|
|
11
|
+
import { u as ve } from "./useSettings-FYcMKMRt.mjs";
|
|
12
12
|
const ke = ({
|
|
13
13
|
isOpen: t,
|
|
14
14
|
onClose: i,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var f=(o,t,n)=>t in o?g(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var m=(o,t,n)=>f(o,typeof t!="symbol"?t+"":t,n);const z=require("@strapi/strapi/admin"),e=require("zod"),r=require("./index-
|
|
1
|
+
"use strict";var g=Object.defineProperty;var f=(o,t,n)=>t in o?g(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var m=(o,t,n)=>f(o,typeof t!="symbol"?t+"":t,n);const z=require("@strapi/strapi/admin"),e=require("zod"),r=require("./index-DjpG-ImS.js"),b=o=>o&&o.__esModule?o:{default:o},a=b(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 s=a.default.union([a.default.string(),a.default.number()]).transform(o=>{const t=parseInt(o.toString(),10);if(isNaN(t)||t<=0)throw new a.default.ZodError([{message:"ID must be a positive integer",code:"custom",path:["id"]}]);return t}),y=e.z.object({id:s,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 w=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=w.merge(e.z.object({id:s,documentId:e.z.string().min(1,"Document ID is required")}));c.merge(e.z.object({permissions:y.array()}));const p=e.z.object({id:s,name:e.z.string().min(1,"Name is required")}),$=a.default.object({id:a.default.number(),name:a.default.string(),url:a.default.string(),width:a.default.number(),height:a.default.number(),ext:a.default.string(),size:a.default.number()}).passthrough(),h=a.default.object({name:a.default.string().min(1,"Name is required"),code:a.default.string().min(1,"Code is required"),customFields:a.default.record(a.default.any()).optional().nullable(),damRootDirectory:a.default.string().optional().nullable(),logo:$.optional().nullable()}),d=h.extend({id:s,documentId:a.default.string()});d.extend({role:c.optional().nullable()});const I=h.extend({role:s.optional().nullable(),tokens:a.default.array(s).optional().nullable()}),C=d.omit({id:!0,documentId:!0}).extend({role:s.optional().nullable(),tokens:a.default.array(s).optional().nullable()}),S=a.default.object({page:a.default.number(),pageCount:a.default.number(),pageSize:a.default.number(),total:a.default.number()}),j=e.z.object({results:e.z.array(d),pagination:S}),u=d.extend({role:c.optional().nullable(),tokens:e.z.array(p).optional().nullable()});class q{constructor(){m(this,"fetchClient",z.getFetchClient())}async validateTenant(t){try{const n=await this.fetchClient.post(`/${r.pluginId}/validate`,t);return console.log("response.data",n.data),n.data}catch(n){throw n instanceof e.z.ZodError?new Error(`Validation error: ${n.errors.map(i=>i.message).join(", ")}`):n}}async getTenants(t){try{const n=await this.fetchClient.get(`/${r.pluginId}/${r.modelRoute}`,{params:t});return j.parse(n.data)}catch{throw new Error("Failed to fetch tenants")}}async getTenant(t){try{const n=await this.fetchClient.get(`/${r.pluginId}/${r.modelRoute}/${t}`);return u.parseAsync(n.data)}catch{throw new Error("Failed to fetch tenant")}}async createTenant(t){try{const n=I.parse(t),i=await this.fetchClient.post(`/${r.pluginId}/${r.modelRoute}`,n);return u.parseAsync(i.data)}catch(n){throw console.log("error",n),n instanceof e.z.ZodError?new Error(`Validation error: ${n.errors.map(i=>i.message).join(", ")}`):n}}async updateTenant(t,n){try{const i=C.parse(n),l=await this.fetchClient.put(`/${r.pluginId}/${r.modelRoute}/${t}`,i);return u.parseAsync(l.data)}catch(i){throw i instanceof e.z.ZodError?new Error(`Validation error: ${i.errors.map(l=>l.message).join(", ")}`):new Error("Failed to update domain")}}async deleteTenant(t){try{await this.fetchClient.del(`/${r.pluginId}/${r.modelRoute}/${t}`)}catch{throw new Error("Failed to delete tenant")}}async getRoles(){try{const t=await this.fetchClient.get("/admin/roles");return e.z.array(c).parse(t.data.data)}catch{throw new Error("Failed to fetch roles")}}async getTokens(){try{const t=await this.fetchClient.get("/admin/api-tokens");return e.z.array(p).parse(t.data.data)}catch{throw new Error("Failed to fetch roles")}}async validateCustomField({model:t,documentId:n,field:i,value:l}){return(await this.fetchClient.post(`/${r.pluginId}/${r.modelRoute}/${t}/validate`,{documentId:n,field:i,value:l})).data}async getSettings(){return(await this.fetchClient.get(`/${r.pluginId}/license`)).data}}const E=new q;exports.api=E;
|
|
@@ -3,7 +3,7 @@ var y = (o, t, n) => t in o ? b(o, t, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var h = (o, t, n) => y(o, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { getFetchClient as w } from "@strapi/strapi/admin";
|
|
5
5
|
import r, { z as e } from "zod";
|
|
6
|
-
import { p as i, m as c } from "./index-
|
|
6
|
+
import { p as i, m as c } from "./index-ChZO7NH2.mjs";
|
|
7
7
|
e.object({
|
|
8
8
|
name: e.string().min(1, "Name is required").max(255, "Name must be less than 255 characters"),
|
|
9
9
|
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")
|
|
@@ -9,7 +9,7 @@ import { Avatar as k, Modal as h, Box as L, Field as P, Searchbar as ee, EmptySt
|
|
|
9
9
|
import { createRoot as le } from "react-dom/client";
|
|
10
10
|
import { Search as de } from "@strapi/icons";
|
|
11
11
|
import { QueryClient as ue, QueryClientProvider as me } from "@tanstack/react-query";
|
|
12
|
-
const he = "@sensinum/strapi-plugin-multi-domain", pe = "5.
|
|
12
|
+
const he = "@sensinum/strapi-plugin-multi-domain", pe = "5.4.0", ge = "https://www.sensinum.com/contact", fe = "hello@sensinum.com", ye = { name: "multi-domain" }, Fe = {
|
|
13
13
|
name: he,
|
|
14
14
|
version: pe,
|
|
15
15
|
homepage: ge,
|
|
@@ -262,7 +262,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
262
262
|
defaultMessage: "Ensures the value is unique within the domain."
|
|
263
263
|
},
|
|
264
264
|
components: {
|
|
265
|
-
Input: () => import("./TenantCustomField-
|
|
265
|
+
Input: () => import("./TenantCustomField-zLI8HKGa.mjs")
|
|
266
266
|
}
|
|
267
267
|
}), e.router.addSettingsLink({
|
|
268
268
|
id: `${a}.settings`,
|
|
@@ -278,7 +278,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
278
278
|
defaultMessage: "About"
|
|
279
279
|
},
|
|
280
280
|
to: `/settings/${a}/about`,
|
|
281
|
-
Component: () => import("./About
|
|
281
|
+
Component: () => import("./About--uEAqLIX.mjs"),
|
|
282
282
|
permissions: N.admin.access
|
|
283
283
|
},
|
|
284
284
|
{
|
|
@@ -288,7 +288,7 @@ const g = "domain", E = "domain", be = `${g}s`, p = "domain", H = {
|
|
|
288
288
|
defaultMessage: "General Settings"
|
|
289
289
|
},
|
|
290
290
|
to: `/settings/${a}/${be}`,
|
|
291
|
-
Component: () => import("./Settings-
|
|
291
|
+
Component: () => import("./Settings-yCKWEkTW.mjs"),
|
|
292
292
|
permissions: N.admin.access
|
|
293
293
|
}
|
|
294
294
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const $=require("remeda"),D=require("zod"),o=require("react/jsx-runtime"),f=require("react"),w=require("react-cookie"),_=require("react-router-dom"),H=require("@strapi/strapi/admin"),i=require("@strapi/design-system"),U=require("react-dom/client"),F=require("@strapi/icons"),M=require("@tanstack/react-query"),z=e=>e&&e.__esModule?e:{default:e},Q=z(f),W="@sensinum/strapi-plugin-multi-domain",J="5.
|
|
1
|
+
"use strict";const $=require("remeda"),D=require("zod"),o=require("react/jsx-runtime"),f=require("react"),w=require("react-cookie"),_=require("react-router-dom"),H=require("@strapi/strapi/admin"),i=require("@strapi/design-system"),U=require("react-dom/client"),F=require("@strapi/icons"),M=require("@tanstack/react-query"),z=e=>e&&e.__esModule?e:{default:e},Q=z(f),W="@sensinum/strapi-plugin-multi-domain",J="5.4.0",V="https://www.sensinum.com/contact",G="hello@sensinum.com",K={name:"multi-domain"},X={name:W,version:J,homepage:V,email:G},r=D.z.literal("multi-domain").parse(K.name);$.toSnakeCase(r);const h="domain",T="domain",P=`${h}s`,p="domain",k={read:"read",change:"change",create:"create",delete:"delete"},x=e=>`plugin::${r}.${k[e]}`,j={admin:{access:Object.keys(k).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`,Y="strapi-super-admin",L=e=>e?.code===Y,Z=e=>{const t=`/admin/content-manager/collection-types/${e}/create`,n=document.querySelector(`a[href*="${t}"]`);n&&(n.style.display="none")},ee=()=>{const[{[p]:e}]=w.useCookies([p]),t=L(e),{slug:n}=_.useParams();return Q.default.useEffect(()=>{n&&(t||!e)&&Z(n)},[t,e,n]),null},te=()=>o.jsx(w.CookiesProvider,{children:o.jsx(ee,{})}),ne=({setPlugin:e})=>{const t=f.useRef(e);return f.useEffect(()=>{t.current(r)},[]),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 s=t.length?`${t}.`:"";return typeof e[a]=="object"&&e[a]!==null&&!Array.isArray(e[a])?Object.assign(n,S(e[a],s+a)):n[s+a]=e[a],n},{}),oe=({onClose:e,userData:t})=>{const[{[p]:n},a]=w.useCookies([p]),[s,u]=f.useState(""),[l,m]=f.useState(n||null),d=(t[T]||[]).filter(c=>c.name.toLowerCase().includes(s.toLowerCase())),y=c=>{m(l?.id===c.id?null:c)},O=()=>{l&&(a(p,JSON.stringify(l),{path:"/",maxAge:3600*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:s,onChange:c=>u(c.target.value),placeholder:"Search domains...",size:"S",clearLabel:"Clear search",children:"Search domains"})]})}),d.length===0?o.jsx(i.EmptyStateLayout,{icon:o.jsx(F.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",children:null}),o.jsx(i.Th,{children:o.jsx(i.Typography,{variant:"sigma",textColor:"neutral600",children:"Domain name"})})]})}),o.jsx(i.Tbody,{children:d.map(c=>o.jsxs(i.Tr,{children:[o.jsx(i.Td,{width:"60px",children:o.jsx(i.Checkbox,{checked:l?.id===c.id,onCheckedChange:()=>y(c),name:`tenant-${c.id}`})}),o.jsx(i.Td,{width:"40px",children:c.logo?.url&&o.jsx(i.Avatar.Item,{src:c.logo.url,alt:c.name,preview:!1,fallback:c.name[0]})}),o.jsx(i.Td,{children:o.jsx(i.Typography,{fontWeight:"semiBold",textColor:"neutral800",children:c.name})})]},c.id))})]})})]}),o.jsxs(i.Modal.Footer,{children:[o.jsx(i.Modal.Close,{children:o.jsx(i.Button,{onClick:e,variant:"tertiary",children:"Cancel"})}),o.jsx(i.Button,{onClick:O,disabled:!l,children:"Select domain"})]})]})})},ie=new M.QueryClient({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}}),ae=(e,t,n,a)=>{const s=U.createRoot(e),u=()=>{document.body.removeAttribute("style"),s.unmount(),setTimeout(()=>{document.body.style.pointerEvents="auto"},0)};return t.remove(),s.render(o.jsx(i.DesignSystemProvider,{theme:a==="light"?i.lightTheme:i.darkTheme,children:o.jsx(M.QueryClientProvider,{client:ie,children:o.jsx(w.CookiesProvider,{children:o.jsx(oe,{onClose:u,userData:n})})})}))},b=(e,t)=>new Promise((n,a)=>{const l=(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(()=>l(m+1),250)};l()}),I=()=>{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},re=e=>{const t=e.firstChild,n=t?.lastChild?.cloneNode(!0);if(t&&n instanceof HTMLElement){const a=n.firstChild;a&&n.replaceChildren(a);const s=n.querySelector("span");if(s){const u=I();s.innerText=u?`${h.toUpperCase()}: ${u.name}`:`No ${h} selected`}n.style.paddingTop="1rem",t.appendChild(n)}},v=async()=>{try{const e=H.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(l=>l.attributeName===a)&&n.getAttribute(a)==="true"){const l=await b("[data-radix-menu-content]");if(!(l instanceof HTMLElement))return;re(l);const m=await b('[role="menuitem"]',l),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(),ae(t,l,e,localStorage.getItem("STRAPI_THEME")||"dark")}),m.insertAdjacentElement("afterend",d)}}}).observe(n,{attributes:!0})},B=()=>window.location.pathname==="/admin/auth/login",se=()=>window.location.pathname.startsWith("/admin/plugins/upload"),ce=()=>{const e=I(),t=document.querySelector('[data-strapi-header="true"]');if(!e||L(e)){const n=t?.querySelectorAll("button");n&&n.forEach(a=>{a.style.display="none"})}},q=$.funnel(ce,{minQuietPeriodMs:250}),N=async()=>{const e=await b('nav ul > li a[href="/admin/plugins/upload"]');e&&e.addEventListener("click",()=>{q.call()}),se()&&q.call()},C=async()=>{if(B()){document.body.removeAttribute(g);return}if(await v()){document.querySelector(`[${g}]`)||(await Promise.all([R(),N()]),document.body.setAttribute(g,"true"));return}document.body.removeAttribute(g)},le=async()=>{B()||!await v()||(document.body.setAttribute(g,"true"),await Promise.all([R(),N()]))},de={register(e){e.registerPlugin({id:r,initializer:ne,isReady:!1,name:r}),e.customFields.register({name:`unique-by-${h}`,pluginId:r,type:"string",intlLabel:{id:`${r}.custom-fields.unique-by-domain.label`,defaultMessage:"Unique by domain"},intlDescription:{id:`${r}.custom-fields.unique-by-tenant.description`,defaultMessage:"Ensures the value is unique within the domain."},components:{Input:()=>Promise.resolve().then(()=>require("./TenantCustomField-DLQLr0HX.js"))}}),e.router.addSettingsLink({id:`${r}.settings`,intlLabel:{id:`${r}.settings.label`,defaultMessage:"Multi-Domain Settings"},links:[{id:`${r}.settings.about`,intlLabel:{id:`${r}.settings.about.label`,defaultMessage:"About"},to:`/settings/${r}/about`,Component:()=>Promise.resolve().then(()=>require("./About-CpMJJUxU.js")),permissions:j.admin.access},{id:`${r}.settings.general`,intlLabel:{id:`${r}.settings.general.label`,defaultMessage:"General Settings"},to:`/settings/${r}/${P}`,Component:()=>Promise.resolve().then(()=>require("./Settings-SyBK2mXN.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(r,S(a)),locale:t})):{data:A(r,S({})),locale:t}))},async bootstrap(e){e.getPlugin("content-manager").injectComponent("listView","actions",{name:"display-create-button",Component:te});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(...s){n.apply(history,s),t!==window.location.pathname&&(t=window.location.pathname,C())},history.replaceState=function(...s){a.apply(history,s),t!==window.location.pathname&&(t=window.location.pathname,C())},await le()}};exports.modelId=h;exports.modelRoute=P;exports.packageJson=X;exports.permissions=j;exports.plugin=de;exports.pluginId=r;
|
package/dist/admin/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-DjpG-ImS.js");exports.default=e.plugin;
|
package/dist/admin/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("react-intl"),u=require("./index-DjpG-ImS.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-B7hXre99.js"),s=()=>e.useQuery({queryKey:["multi-domain-settings"],queryFn:()=>t.api.getSettings(),staleTime:120*1e3});exports.useSettings=s;
|
|
@@ -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-B7hXre99.js"),m=require("./index-DjpG-ImS.js"),q=()=>{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}=q();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:[m.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:120*1e3}),Q=e=>s.useQuery({queryKey:n.detail(e),queryFn:()=>u.api.getTenant(e),enabled:!!e,staleTime:120*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 domain:",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;
|
|
@@ -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-CSqflswp.mjs";
|
|
5
|
+
import { m as F } from "./index-ChZO7NH2.mjs";
|
|
6
6
|
const T = () => {
|
|
7
7
|
const e = q();
|
|
8
8
|
return i({
|