decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines (1 loc) • 4.95 kB
JavaScript
import{c as le,b as oe,j as n,aL as z,aM as G,aN as V,aO as X,bc as Z,aP as ee,aQ as te,aR as ne,a6 as se,q as ie,an as ce,r as re,t as Y,gs as ae,i7 as de,i8 as fe}from"./index-DoEtSiIe.js";function ge(P){const e=le.c(86),{deleteState:s,cancelDelete:r,confirmDelete:D,confirmForceDelete:a}=P,t=oe(),b=s.mode==="deleting";let f;e[0]!==r?(f=W=>{W||r()},e[0]=r,e[1]=f):f=e[1];let d;e[2]!==t?(d=t("common.deleteConnectionDialogs.title"),e[2]=t,e[3]=d):d=e[3];let C;e[4]!==d?(C=n.jsx(z,{children:d}),e[4]=d,e[5]=C):C=e[5];let u;e[6]!==t?(u=t("common.deleteConnectionDialogs.description"),e[6]=t,e[7]=u):u=e[7];const k=s.mode==="deleting"&&s.connection.title;let x;e[8]!==k?(x=n.jsx("span",{className:"font-medium text-foreground",children:k}),e[8]=k,e[9]=x):x=e[9];let o;e[10]!==u||e[11]!==x?(o=n.jsxs(G,{children:[u," ",x,"."]}),e[10]=u,e[11]=x,e[12]=o):o=e[12];let l;e[13]!==C||e[14]!==o?(l=n.jsxs(V,{children:[C,o]}),e[13]=C,e[14]=o,e[15]=l):l=e[15];let i;e[16]!==t?(i=t("common.deleteConnectionDialogs.cancel"),e[16]=t,e[17]=i):i=e[17];let m;e[18]!==i?(m=n.jsx(X,{children:i}),e[18]=i,e[19]=m):m=e[19];let c;e[20]!==t?(c=t("common.deleteConnectionDialogs.delete"),e[20]=t,e[21]=c):c=e[21];let g;e[22]!==D||e[23]!==c?(g=n.jsx(Z,{onClick:D,variant:"destructive",children:c}),e[22]=D,e[23]=c,e[24]=g):g=e[24];let h;e[25]!==m||e[26]!==g?(h=n.jsxs(ee,{children:[m,g]}),e[25]=m,e[26]=g,e[27]=h):h=e[27];let j;e[28]!==h||e[29]!==l?(j=n.jsxs(te,{children:[l,h]}),e[28]=h,e[29]=l,e[30]=j):j=e[30];let p;e[31]!==b||e[32]!==j||e[33]!==f?(p=n.jsx(ne,{open:b,onOpenChange:f,children:j}),e[31]=b,e[32]=j,e[33]=f,e[34]=p):p=e[34];const $=s.mode==="force-deleting";let N;e[35]!==r?(N=W=>{W||r()},e[35]=r,e[36]=N):N=e[36];let E;e[37]!==t?(E=t("common.deleteConnectionDialogs.forceDeleteTitle"),e[37]=t,e[38]=E):E=e[38];let O;e[39]!==E?(O=n.jsx(z,{children:E}),e[39]=E,e[40]=O):O=e[40];let T;e[41]!==t?(T=t("common.deleteConnectionDialogs.forceDeleteDescription"),e[41]=t,e[42]=T):T=e[42];const B=s.mode==="force-deleting"&&s.connection.title;let y;e[43]!==B?(y=n.jsx("span",{className:"font-medium text-foreground",children:B}),e[43]=B,e[44]=y):y=e[44];let S;e[45]!==t?(S=t("common.deleteConnectionDialogs.isUsedByAgents"),e[45]=t,e[46]=S):S=e[46];const J=s.mode==="force-deleting"&&s.agentNames;let _;e[47]!==J?(_=n.jsx("span",{className:"font-medium text-foreground",children:J}),e[47]=J,e[48]=_):_=e[48];let A;e[49]!==T||e[50]!==y||e[51]!==S||e[52]!==_?(A=n.jsxs("p",{children:[T," ",y," ",S," ",_,"."]}),e[49]=T,e[50]=y,e[51]=S,e[52]=_,e[53]=A):A=e[53];let v;e[54]!==t?(v=t("common.deleteConnectionDialogs.forceDeleteWarning"),e[54]=t,e[55]=v):v=e[55];let L;e[56]!==v?(L=n.jsx("p",{className:"mt-2",children:v}),e[56]=v,e[57]=L):L=e[57];let R;e[58]!==A||e[59]!==L?(R=n.jsx(G,{asChild:!0,children:n.jsxs("div",{children:[A,L]})}),e[58]=A,e[59]=L,e[60]=R):R=e[60];let F;e[61]!==O||e[62]!==R?(F=n.jsxs(V,{children:[O,R]}),e[61]=O,e[62]=R,e[63]=F):F=e[63];let I;e[64]!==t?(I=t("common.deleteConnectionDialogs.cancel"),e[64]=t,e[65]=I):I=e[65];let q;e[66]!==I?(q=n.jsx(X,{children:I}),e[66]=I,e[67]=q):q=e[67];let U;e[68]!==t?(U=t("common.deleteConnectionDialogs.deleteAnyway"),e[68]=t,e[69]=U):U=e[69];let w;e[70]!==a||e[71]!==U?(w=n.jsx(Z,{onClick:a,variant:"destructive",children:U}),e[70]=a,e[71]=U,e[72]=w):w=e[72];let H;e[73]!==q||e[74]!==w?(H=n.jsxs(ee,{children:[q,w]}),e[73]=q,e[74]=w,e[75]=H):H=e[75];let K;e[76]!==F||e[77]!==H?(K=n.jsxs(te,{children:[F,H]}),e[76]=F,e[77]=H,e[78]=K):K=e[78];let Q;e[79]!==$||e[80]!==N||e[81]!==K?(Q=n.jsx(ne,{open:$,onOpenChange:N,children:K}),e[79]=$,e[80]=N,e[81]=K,e[82]=Q):Q=e[82];let M;return e[83]!==p||e[84]!==Q?(M=n.jsxs(n.Fragment,{children:[p,Q]}),e[83]=p,e[84]=Q,e[85]=M):M=e[85],M}function De({onSuccess:P}={}){const{org:e}=se(),s=ie(),r=ce(),D=oe(),[a,t]=re.useState({mode:"idle"}),b=()=>{ae(s,e.id)},f=o=>{de(o),s.invalidateQueries({predicate:l=>l.queryKey[1]===fe&&l.queryKey[3]===o})},d=o=>{b(),f(o),Y.success(D("orgs.connections.connectionDeleted")),t({mode:"idle"}),P?.()};return{deleteState:a,requestDelete:o=>{t({mode:"deleting",connection:o})},cancelDelete:()=>{t({mode:"idle"})},confirmDelete:async()=>{if(a.mode!=="deleting")return;const o=a.connection;t({mode:"idle"});try{await r.call("COLLECTION_CONNECTIONS_DELETE",{id:o.id}),d(o.id)}catch(l){const i=l instanceof Error?l.message:String(l),m=i.replace(/^Error:\s*/,"");try{const c=JSON.parse(m);if(c.code==="CONNECTION_IN_USE"&&c.agentNames){t({mode:"force-deleting",connection:o,agentNames:c.agentNames.map(g=>`"${g}"`).join(", ")});return}}catch{}Y.error(D("orgs.connections.failedToDeleteConnection",{error:i}))}},confirmForceDelete:async()=>{if(a.mode!=="force-deleting")return;const o=a.connection.id;t({mode:"idle"});try{await r.call("COLLECTION_CONNECTIONS_DELETE",{id:o,force:!0}),d(o)}catch(l){const i=l instanceof Error?l.message:String(l);Y.error(D("orgs.connections.failedToDeleteConnection",{error:i}))}}}}export{ge as D,De as u};