decocms
Version:
Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools
2 lines (1 loc) • 9.04 kB
JavaScript
import{c as j,b as N,j as s,n as C,hx as F,R as k,r as y,e3 as L,B as D,aA as O,ai as T,D as A,v as B,w as R,x as I,aW as q,I as _,y as V,t as z,gl as H}from"./index-DoEtSiIe.js";import{i as W}from"./AlertCircle-GoAGGV0G.js";import{s as G}from"./Plus-BoPsX_T8.js";import{t as J}from"./Users01-BasqfwpC.js";import{E as K}from"./empty-state-UX_DOq42.js";import{L as w}from"./label-G4Rj_cXa.js";import{S as M,b as Q,a as U,d as X,c as P}from"./select-OlcoUSVg.js";import{T as Y}from"./textarea-CP9TQ5HN.js";import{u as Z,a as ee}from"./use-secrets-DumIaW5z.js";import{R as te}from"./require-capability-FcSdruCZ.js";import"./index-BdQq_4o_.js";import"./index-BFFHlwFA.js";import"./ChevronDown-Dm2xO7jf.js";import"./ChevronUp-BKdcyIOm.js";import"./access-gate-4Yp7vAaA.js";import"./capability-load-error-C6JoLBp9.js";function se(t){const e=j.c(6),{error:r}=t,i=N();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(W,{size:16}),e[0]=c):c=e[0];let n;e[1]!==r.message||e[2]!==i?(n=i("settings.secrets.failedToLoadError",{error:r.message}),e[1]=r.message,e[2]=i,e[3]=n):n=e[3];let l;return e[4]!==n?(l=s.jsxs("div",{className:"p-4 rounded-md bg-destructive/10 text-destructive flex items-center gap-2",children:[c,s.jsx("span",{className:"text-sm font-medium",children:n})]}),e[4]=n,e[5]=l):l=e[5],l}function re(t){const e=j.c(8),{scope:r}=t,i=N(),c=r==="user"?O:J;let n;e[0]!==r||e[1]!==i?(n=i(r==="user"?"settings.secrets.scopePrivate":"settings.secrets.scopeOrganization"),e[0]=r,e[1]=i,e[2]=n):n=e[2];const l=n;let a;e[3]!==c?(a=s.jsx(c,{size:12}),e[3]=c,e[4]=a):a=e[4];let m;return e[5]!==l||e[6]!==a?(m=s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-muted text-muted-foreground text-xs",children:[a,l]}),e[5]=l,e[6]=a,e[7]=m):m=e[7],m}function $(t){const e=j.c(20),{secret:r}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx("div",{className:"size-9 rounded-md bg-muted flex items-center justify-center shrink-0",children:s.jsx(T,{size:16,className:"text-muted-foreground"})}),e[0]=i):i=e[0];let c;e[1]!==r.name?(c=s.jsx("span",{className:"font-medium text-sm truncate",children:r.name}),e[1]=r.name,e[2]=c):c=e[2];let n;e[3]!==r.scope?(n=s.jsx(re,{scope:r.scope}),e[3]=r.scope,e[4]=n):n=e[4];let l;e[5]!==c||e[6]!==n?(l=s.jsxs("div",{className:"flex items-center gap-2",children:[c,n]}),e[5]=c,e[6]=n,e[7]=l):l=e[7];let a;e[8]!==r.description?(a=r.description?s.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:r.description}):null,e[8]=r.description,e[9]=a):a=e[9];let m;e[10]!==l||e[11]!==a?(m=s.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[i,s.jsxs("div",{className:"min-w-0",children:[l,a]})]}),e[10]=l,e[11]=a,e[12]=m):m=e[12];let d;e[13]!==r.createdAt?(d=new Date(r.createdAt).toLocaleDateString(),e[13]=r.createdAt,e[14]=d):d=e[14];let u;e[15]!==d?(u=s.jsx("div",{className:"text-xs text-muted-foreground shrink-0",children:d}),e[15]=d,e[16]=u):u=e[16];let x;return e[17]!==m||e[18]!==u?(x=s.jsxs("div",{className:"flex items-start justify-between gap-4 py-3 border-b border-border/60 last:border-b-0",children:[m,u]}),e[17]=m,e[18]=u,e[19]=x):x=e[19],x}function ne(t){const e=j.c(9),{action:r}=t,i=N();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(T,{}),e[0]=c):c=e[0];let n;e[1]!==i?(n=i("settings.secrets.emptyTitle"),e[1]=i,e[2]=n):n=e[2];let l;e[3]!==i?(l=i("settings.secrets.emptyDescription"),e[3]=i,e[4]=l):l=e[4];let a;return e[5]!==r||e[6]!==n||e[7]!==l?(a=s.jsx(H,{children:s.jsx(K,{size:"inline",icon:c,title:n,description:l,children:r})}),e[5]=r,e[6]=n,e[7]=l,e[8]=a):a=e[8],a}function E({open:t,onOpenChange:e}){const r=N(),[i,c]=y.useState("organization"),[n,l]=y.useState(""),[a,m]=y.useState(""),[d,u]=y.useState(""),x=ee();function g(){c("organization"),l(""),m(""),u("")}function p(){g(),e(!1)}async function S(o){if(o.preventDefault(),!(!n.trim()||!a))try{await x.mutateAsync({scope:i,name:n.trim(),value:a,description:d.trim()||void 0}),z.success(r("settings.secrets.secretCreated",{name:n.trim()})),p()}catch(f){z.error(f instanceof Error?f.message:r("settings.secrets.failedToCreateSecret"))}}return s.jsx(A,{open:t,onOpenChange:o=>{o?e(o):p()},children:s.jsxs(B,{className:"sm:max-w-lg",children:[s.jsxs(R,{children:[s.jsx(I,{children:r("settings.secrets.newSecretTitle")}),s.jsx(q,{children:r("settings.secrets.newSecretDescription")})]}),s.jsxs("form",{onSubmit:S,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(w,{htmlFor:"secret-scope",children:r("settings.secrets.scopeLabel")}),s.jsxs(M,{value:i,onValueChange:o=>c(o),children:[s.jsx(Q,{id:"secret-scope",children:s.jsx(U,{})}),s.jsxs(X,{children:[s.jsx(P,{value:"organization",children:r("settings.secrets.scopeOrganizationDescription")}),s.jsx(P,{value:"user",children:r("settings.secrets.scopePrivateDescription")})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(w,{htmlFor:"secret-name",children:r("settings.secrets.nameLabel")}),s.jsx(_,{id:"secret-name",value:n,onChange:o=>l(o.target.value),placeholder:r("settings.secrets.namePlaceholder"),autoComplete:"off",required:!0}),s.jsx("p",{className:"text-xs text-muted-foreground",children:r("settings.secrets.nameHelp")})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(w,{htmlFor:"secret-value",children:r("settings.secrets.valueLabel")}),s.jsx(_,{id:"secret-value",type:"password",value:a,onChange:o=>m(o.target.value),autoComplete:"new-password",required:!0})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(w,{htmlFor:"secret-description",children:r("settings.secrets.descriptionLabel")}),s.jsx(Y,{id:"secret-description",value:d,onChange:o=>u(o.target.value),rows:2,placeholder:r("settings.secrets.descriptionPlaceholder")})]}),s.jsxs(V,{children:[s.jsx(D,{type:"button",variant:"outline",onClick:p,disabled:x.isPending,children:r("settings.secrets.cancelButton")}),s.jsx(D,{type:"submit",disabled:x.isPending||!n.trim()||!a,children:x.isPending?r("settings.secrets.creatingButton"):r("settings.secrets.createButton")})]})]})]})})}function ie(){const t=j.c(34),e=N(),r=Z(),[i,c]=y.useState(!1);let n,l;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>c(!0),l=s.jsx(G,{size:14}),t[0]=n,t[1]=l):(n=t[0],l=t[1]);let a;t[2]!==e?(a=e("settings.secrets.newSecret"),t[2]=e,t[3]=a):a=t[3];let m;t[4]!==a?(m=s.jsx(C.Actions,{children:s.jsxs(D,{size:"sm",onClick:n,children:[l,a]})}),t[4]=a,t[5]=m):m=t[5];const d=m;if(r.length===0){let o;t[6]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(ne,{action:!1}),t[6]=o):o=t[6];let f;t[7]!==i?(f=s.jsx(E,{open:i,onOpenChange:c}),t[7]=i,t[8]=f):f=t[8];let h;return t[9]!==d||t[10]!==f?(h=s.jsxs(s.Fragment,{children:[d,o,f]}),t[9]=d,t[10]=f,t[11]=h):h=t[11],h}let u,x,g;if(t[12]!==d||t[13]!==r||t[14]!==e){const o=r.filter(oe),f=r.filter(ae),h=r.length===1?"settings.secrets.secretsCountSingular":"settings.secrets.secretsCountPlural";let b;t[18]!==r.length||t[19]!==e||t[20]!==h?(b=e(h,{count:r.length}),t[18]=r.length,t[19]=e,t[20]=h,t[21]=b):b=t[21];let v;t[22]!==b?(v=s.jsx("p",{className:"text-sm text-muted-foreground",children:b}),t[22]=b,t[23]=v):v=t[23],t[24]!==d||t[25]!==v?(u=s.jsxs("div",{className:"flex items-center justify-between",children:[v,d]}),t[24]=d,t[25]=v,t[26]=u):u=t[26],x=o.length>0?s.jsxs("section",{className:"surface p-5",children:[s.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:e("settings.secrets.sectionOrganization")}),s.jsx("div",{children:o.map(le)})]}):null,g=f.length>0?s.jsxs("section",{className:"surface p-5",children:[s.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:e("settings.secrets.sectionPrivate")}),s.jsx("div",{children:f.map(ce)})]}):null,t[12]=d,t[13]=r,t[14]=e,t[15]=u,t[16]=x,t[17]=g}else u=t[15],x=t[16],g=t[17];let p;t[27]!==i?(p=s.jsx(E,{open:i,onOpenChange:c}),t[27]=i,t[28]=p):p=t[28];let S;return t[29]!==u||t[30]!==x||t[31]!==g||t[32]!==p?(S=s.jsxs(s.Fragment,{children:[u,x,g,p]}),t[29]=u,t[30]=x,t[31]=g,t[32]=p,t[33]=S):S=t[33],S}function ce(t){return s.jsx($,{secret:t},t.id)}function le(t){return s.jsx($,{secret:t},t.id)}function ae(t){return t.scope==="user"}function oe(t){return t.scope==="organization"}function me(){const t=j.c(7),e=N();let r;t[0]!==e?(r=e("settings.nav.secrets"),t[0]=e,t[1]=r):r=t[1];let i;t[2]!==r?(i=s.jsx(C.Title,{children:r}),t[2]=r,t[3]=i):i=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(k,{fallback:de,children:s.jsx(y.Suspense,{fallback:s.jsx(L,{className:"h-32 w-full"}),children:s.jsx(ie,{})})}),t[4]=c):c=t[4];let n;return t[5]!==i?(n=s.jsx(C,{children:s.jsx(C.Content,{children:s.jsx(C.Container,{children:s.jsxs(F,{children:[i,c]})})})}),t[5]=i,t[6]=n):n=t[6],n}function de(t){const{error:e}=t;return s.jsx(se,{error:e??new Error("Failed to load secrets")})}function ze(){const t=j.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(te,{capability:"secrets:manage",area:"secrets",children:s.jsx(me,{})}),t[0]=e):e=t[0],e}export{ze as default};