UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) • 10 kB
import{b as U,a6 as te,ho as oe,q as re,aI as le,aH as ce,e as ne,E as Y,t as K,K as W,j as n,gZ as ie,gl as se,gm as G,eb as ge,I as ae,aJ as de,aK as X,c as Z,r as J,o as me,an as ue,aw as ee,cv as fe,cw as pe,M as xe,B as he,aL as je,aM as ze,aN as Se,aO as Oe,bc as ve,aP as be,aQ as Ce,aR as ye,at as _e,n as $,hx as Fe,ba as De}from"./index-ztdGKvBm.js";import{u as we}from"./use-debounced-autosave-CCeLz8XW.js";import{C as Ae,P as Ee,B as Ne,a as Te}from"./review-settings-DnBaXa8b.js";import{D as Le}from"./domain-settings-D4e35lZa.js";import{C as Pe}from"./capability-load-error-CCChPOz4.js";import"./switch-B81oLbqr.js";import"./BookOpen01-DU-B3R7s.js";import"./UserSquare-CafFh5_d.js";import"./use-organization-settings-C2vcrj4S.js";import"./schema-Bb-DbvPZ.js";import"./task-board-i6qU2BVR.js";import"./use-connection-CcG4QE1K.js";import"./use-mcp-client-2MG3LveS.js";import"./auth-C82OPjUx.js";import"./badge-DcUertOZ.js";import"./select-CxXZwsSr.js";import"./index-BdQq_4o_.js";import"./index-CDQbtG2e.js";import"./ChevronDown-XsLJSrfl.js";import"./ChevronUp-BQktpZWC.js";const ke=e=>de({name:X().min(1,e("settings.organizationForm.nameRequired")).max(255,e("settings.organizationForm.nameTooLong")),logo:X().optional()});function Re(e){const t=Z.c(17),{value:s,onChange:f,name:g,disabled:l}=e,c=U(),d=J.useRef(null);let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>d.current?.click(),t[0]=o):o=t[0];const m=o;let i;t[1]!==f||t[2]!==c?(i=S=>{const z=S.target.files?.[0];if(!z)return;if(z.size>2097152){K.error(c("settings.organizationForm.imageTooLarge"));return}const p=new FileReader;p.onerror=()=>K.error(c("settings.organizationForm.failedToReadImage")),p.onloadend=()=>{p.result&&f(p.result),d.current&&(d.current.value="")},p.readAsDataURL(z)},t[1]=f,t[2]=c,t[3]=i):i=t[3];const a=i;let r;t[4]!==c?(r=c("settings.organizationForm.uploadLogoLabel"),t[4]=c,t[5]=r):r=t[5];let u;t[6]!==l||t[7]!==a?(u=n.jsx("input",{ref:d,type:"file",accept:"image/*",onChange:a,className:"hidden",disabled:l}),t[6]=l,t[7]=a,t[8]=u):u=t[8];const h=s||void 0,j=g??"?";let x;t[9]!==h||t[10]!==j?(x=n.jsx(me,{url:h,fallback:j,shape:"square",size:"base"}),t[9]=h,t[10]=j,t[11]=x):x=t[11];let v;return t[12]!==l||t[13]!==r||t[14]!==u||t[15]!==x?(v=n.jsxs("button",{type:"button",onClick:m,disabled:l,className:"rounded-lg overflow-hidden hover:ring-2 hover:ring-border transition-all disabled:opacity-50","aria-label":r,children:[u,x]}),t[12]=l,t[13]=r,t[14]=u,t[15]=x,t[16]=v):v=t[16],v}function Ie(){const e=U(),{org:t}=te(),s=oe(),f=re(),g=le({resolver:ce(ke(e)),values:{name:t.name??"",logo:t.logo??""}}),l=ne({mutationFn:async i=>{const a={name:i.name};i.logo&&(a.logo=i.logo);const r=await s.organization.update({data:a});if(r?.error)throw new Error(r.error.message||e("settings.organizationForm.failedToUpdateOrg"));return r},onSuccess:(i,a)=>{Y("organization_settings_updated",{organization_id:t.id,fields:Object.keys(a)}),f.invalidateQueries({queryKey:W.organizations()}),f.invalidateQueries({queryKey:W.activeOrganization(t.slug)}),K.success(e("settings.organizationForm.updateSuccess"))},onError:(i,a)=>{Y("organization_settings_update_failed",{organization_id:t.id,fields:Object.keys(a),error:i instanceof Error?i.message:String(i)}),K.error(i instanceof Error?i.message:e("settings.organizationForm.failedToUpdateOrg"))}}),{schedule:c,flush:d}=we({save:async()=>{const i=g.control._formState.dirtyFields;if(Object.keys(i).length===0||!await g.trigger())return;const r=g.getValues(),u=g.control._defaultValues;g.reset(r,{keepValues:!0});try{await l.mutateAsync(r)}catch{g.reset(u,{keepValues:!0})}}}),o=g.formState.errors,m=typeof window<"u"?`${window.location.host}/`:"";return n.jsx(ie,{children:n.jsxs(se,{children:[n.jsx(G,{title:e("settings.organizationForm.logoTitle"),description:e("settings.organizationForm.logoDescription"),action:n.jsx(Re,{value:g.watch("logo"),onChange:i=>{g.setValue("logo",i??"",{shouldDirty:!0}),d()},name:g.watch("name")})}),n.jsx(G,{title:e("settings.organizationForm.nameTitle"),action:n.jsx(ge,{control:g.control,name:"name",render:({field:i})=>n.jsx(ae,{id:"org-name",...i,onChange:a=>{i.onChange(a),c()},onBlur:()=>{i.onBlur(),d()},placeholder:e("settings.organizationForm.namePlaceholder"),className:"w-[280px]"})})}),n.jsx(G,{title:e("settings.organizationForm.urlTitle"),description:e("settings.organizationForm.urlDescription"),action:n.jsxs("div",{className:"flex items-center w-[280px] rounded-md border border-input bg-muted/40 overflow-hidden",children:[m&&n.jsx("span",{className:"pl-3 text-sm text-muted-foreground select-none",children:m}),n.jsx("span",{className:"flex-1 min-w-0 px-2 py-1.5 text-sm text-foreground truncate",children:t.slug})]})}),(o.name||o.logo)&&n.jsxs("div",{className:"px-5 pb-3 flex flex-col gap-1",children:[o.name&&n.jsx("p",{className:"text-xs text-destructive",children:o.name.message}),o.logo&&n.jsx("p",{className:"text-xs text-destructive",children:o.logo.message})]})]})})}function Be(){const e=Z.c(83),t=U(),{org:s}=te(),[f,g]=J.useState(!1),[l,c]=J.useState(""),d=ue();let o;e[0]!==s.id||e[1]!==d?(o=async()=>{await d.call("ORGANIZATION_DELETE",{id:s.id})},e[0]=s.id,e[1]=d,e[2]=o):o=e[2];let m;e[3]!==s.id||e[4]!==s.slug||e[5]!==t?(m=()=>{Y("organization_deleted",{organization_id:s.id}),localStorage.getItem(ee.lastOrgSlug())===s.slug&&localStorage.removeItem(ee.lastOrgSlug()),fe()?.org===s.slug&&pe(),xe(),K.success(t("settings.deleteOrganizationSection.organizationDeleted")),window.location.href="/"},e[3]=s.id,e[4]=s.slug,e[5]=t,e[6]=m):m=e[6];let i;e[7]!==t?(i=O=>{K.error(O instanceof Error?O.message:t("settings.deleteOrganizationSection.failedToDeleteOrganization"))},e[7]=t,e[8]=i):i=e[8];let a;e[9]!==o||e[10]!==m||e[11]!==i?(a={mutationFn:o,onSuccess:m,onError:i},e[9]=o,e[10]=m,e[11]=i,e[12]=a):a=e[12];const r=ne(a);let u;e[13]!==t?(u=t("settings.deleteOrganizationSection.dangerZone"),e[13]=t,e[14]=u):u=e[14];let h;e[15]!==t?(h=t("settings.deleteOrganizationSection.deleteOrganizationTitle"),e[15]=t,e[16]=h):h=e[16];let j;e[17]!==t?(j=t("settings.deleteOrganizationSection.deleteOrganizationDescription"),e[17]=t,e[18]=j):j=e[18];let x;e[19]===Symbol.for("react.memo_cache_sentinel")?(x=()=>g(!0),e[19]=x):x=e[19];const v=r.isPending;let S;e[20]!==t?(S=t("settings.deleteOrganizationSection.deleteButton"),e[20]=t,e[21]=S):S=e[21];let z;e[22]!==r.isPending||e[23]!==S?(z=n.jsx(he,{variant:"destructive",size:"sm",onClick:x,disabled:v,children:S}),e[22]=r.isPending,e[23]=S,e[24]=z):z=e[24];let p;e[25]!==z||e[26]!==h||e[27]!==j?(p=n.jsx(se,{className:"border-destructive/40",children:n.jsx(G,{title:h,description:j,action:z})}),e[25]=z,e[26]=h,e[27]=j,e[28]=p):p=e[28];let b;e[29]!==p||e[30]!==u?(b=n.jsx(ie,{title:u,children:p}),e[29]=p,e[30]=u,e[31]=b):b=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=O=>{g(O),O||c("")},e[32]=M):M=e[32];let C;e[33]!==t?(C=t("settings.deleteOrganizationSection.deleteOrganizationQuestion"),e[33]=t,e[34]=C):C=e[34];let y;e[35]!==C?(y=n.jsx(je,{children:C}),e[35]=C,e[36]=y):y=e[36];let _;e[37]!==s.name||e[38]!==t?(_=t("settings.deleteOrganizationSection.deleteWarning",{organizationName:s.name}),e[37]=s.name,e[38]=t,e[39]=_):_=e[39];let F;e[40]!==_?(F=n.jsx("p",{children:_}),e[40]=_,e[41]=F):F=e[41];let D;e[42]!==s.name||e[43]!==t?(D=t("settings.deleteOrganizationSection.typeToConfirm",{organizationName:s.name}),e[42]=s.name,e[43]=t,e[44]=D):D=e[44];let w;e[45]!==D?(w=n.jsx("p",{className:"mt-3 mb-1.5",children:D}),e[45]=D,e[46]=w):w=e[46];let Q;e[47]===Symbol.for("react.memo_cache_sentinel")?(Q=O=>c(O.target.value),e[47]=Q):Q=e[47];let A;e[48]!==l||e[49]!==s.name?(A=n.jsx(ae,{value:l,onChange:Q,placeholder:s.name,autoFocus:!0}),e[48]=l,e[49]=s.name,e[50]=A):A=e[50];let E;e[51]!==F||e[52]!==w||e[53]!==A?(E=n.jsx(ze,{asChild:!0,children:n.jsxs("div",{children:[F,w,A]})}),e[51]=F,e[52]=w,e[53]=A,e[54]=E):E=e[54];let N;e[55]!==y||e[56]!==E?(N=n.jsxs(Se,{children:[y,E]}),e[55]=y,e[56]=E,e[57]=N):N=e[57];let T;e[58]!==t?(T=t("settings.deleteOrganizationSection.cancel"),e[58]=t,e[59]=T):T=e[59];let L;e[60]!==T?(L=n.jsx(Oe,{children:T}),e[60]=T,e[61]=L):L=e[61];let P;e[62]!==r?(P=()=>r.mutate(),e[62]=r,e[63]=P):P=e[63];const H=l!==s.name||r.isPending;let k;e[64]!==r.isPending||e[65]!==t?(k=r.isPending?t("settings.deleteOrganizationSection.deleting"):t("settings.deleteOrganizationSection.deleteOrganizationAction"),e[64]=r.isPending,e[65]=t,e[66]=k):k=e[66];let R;e[67]!==P||e[68]!==H||e[69]!==k?(R=n.jsx(ve,{onClick:P,disabled:H,variant:"destructive",children:k}),e[67]=P,e[68]=H,e[69]=k,e[70]=R):R=e[70];let I;e[71]!==L||e[72]!==R?(I=n.jsxs(be,{children:[L,R]}),e[71]=L,e[72]=R,e[73]=I):I=e[73];let B;e[74]!==N||e[75]!==I?(B=n.jsxs(Ce,{children:[N,I]}),e[74]=N,e[75]=I,e[76]=B):B=e[76];let q;e[77]!==f||e[78]!==B?(q=n.jsx(ye,{open:f,onOpenChange:M,children:B}),e[77]=f,e[78]=B,e[79]=q):q=e[79];let V;return e[80]!==b||e[81]!==q?(V=n.jsxs(n.Fragment,{children:[b,q]}),e[80]=b,e[81]=q,e[82]=V):V=e[82],V}function qe(){const e=Z.c(16),t=U(),{granted:s,loading:f,error:g}=_e("org:manage");if(f){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(De,{}),e[0]=a):a=e[0],a}if(g){let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Pe,{}),e[1]=a):a=e[1],a}let l;e[2]!==t?(l=t("settings.nav.general"),e[2]=t,e[3]=l):l=e[3];let c;e[4]!==l?(c=n.jsx($.Title,{children:l}),e[4]=l,e[5]=c):c=e[5];let d;e[6]!==s?(d=s&&n.jsxs(n.Fragment,{children:[n.jsx(Ie,{}),n.jsx(Ae,{}),n.jsx(Ee,{}),n.jsx(Ne,{})]}),e[6]=s,e[7]=d):d=e[7];let o,m;e[8]!==s?(o=n.jsx(Te,{manageable:s}),m=s&&n.jsxs(n.Fragment,{children:[n.jsx(Le,{}),n.jsx(Be,{})]}),e[8]=s,e[9]=o,e[10]=m):(o=e[9],m=e[10]);let i;return e[11]!==c||e[12]!==d||e[13]!==o||e[14]!==m?(i=n.jsx($,{children:n.jsx($.Content,{children:n.jsx($.Container,{children:n.jsxs(Fe,{children:[c,d,o,m]})})})}),e[11]=c,e[12]=d,e[13]=o,e[14]=m,e[15]=i):i=e[15],i}function rt(){const e=Z.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=n.jsx(qe,{}),e[0]=t):t=e[0],t}export{rt as default};