import{r,p as g,y as j,e as y,bl as B,T as C,bt as M,b4 as z,bf as $,w as S,bh as w,bb as A,b as E,j as e,L as Q,Q as k,b6 as h,b$ as D,c as L,d as b,q as P,be as O,cu as V,bc as W}from"./index-CK33qGU_.js";import{s as G,a as I}from"./secrets.selectors-CBieCzvZ.js";import{S as q}from"./secrets-Bl4_kNye.js";const F=(c,o,t,l)=>{const u=r.useCallback(s=>{var n;return((n=o.find(p=>p.projectId===s))==null?void 0:n.projectName)||""},[o]),i=r.useCallback((s,n)=>s===q.private.toUpperCase()||!o?s.toLowerCase():`${s.toLowerCase()}(${u(n)})`,[u,o]),m=r.useMemo(()=>c.map(()=>[g,g,j,y,y]),[c]),a=r.useMemo(()=>c.map(({name:s,visibility:n,scope:p,addedOn:f,secret:d})=>[{children:s},{children:i(n,+p)},{gray:!0,children:B(new Date(f),"yyyy-MM-dd")},{intent:"ghost",icon:C.eye,tooltip:"Read",disabled:!d,onClick:()=>t({name:s,secret:d})},{intent:"ghost",icon:C.bin,tooltip:"Delete",onClick:()=>l({name:s,secret:d})}]),[c,i,l,t]);return r.useMemo(()=>[m,a],[m,a])},H={td:{whiteSpace:"nowrap",textAlign:"left",pr:0},"td:nth-of-type(1)":{pl:"20px"},"td:nth-of-type(4)":{svg:{fontSize:"14px"}},"td:nth-of-type(5)":{pr:"20px",pl:"8px",svg:{fontSize:"14px"}}},J=r.memo(M),Y=()=>{const c=z(),o=$(),[t,l]=r.useState(),[u,i]=S(),[m,a]=S(),s=w(G),n=w(I).sort((x,_)=>x.name.localeCompare(_.name));A(W.secrets);const{currentData:p=[],isLoading:f}=E(),d=x=>{l(x),a()},v=x=>{l(x),i()},N=async()=>{t&&(await o.secrets.delete(t.name),o.secrets.fetchAll(),i())},[R,T]=F(n,p,d,v);return r.useEffect(()=>{o.secrets.fetchAll()},[o]),s||f?e.jsx(Q,{}):n.length?e.jsxs(e.Fragment,{children:[e.jsxs(k,{width:"1000px",title:"Secrets",contentProps:{pb:0,overflow:"visible"},actions:e.jsx(h,{href:D("/user_guides/projects/secrets/create_secret/"),external:!0,target:"_blank",p:0,intent:"inline",children:"documentation↗"}),children:[e.jsxs(b,{mb:"25x",children:[e.jsxs(b,{width:"100%",children:[e.jsx(g,{primary:!0,children:n.length}),e.jsx(g,{ml:"5px",children:n.length>1?" Secrets":" Secret"})]}),e.jsx(h,{minWidth:"105px",onClick:()=>c(P.account.secrets.create),children:"New Secret"})]}),e.jsx(L,{mt:"20px",mx:"-20px",sx:H,children:e.jsx(J,{legend:["name","visibility","creation"],middleColumn:2,groupComponents:R,groupProps:T})})]}),e.jsx(O,{title:"Read the secret",isOpen:m,onClose:a,secondaryButtonProps:{children:"Done",onClick:a},children:e.jsx(V,{copyButton:!0,content:(t==null?void 0:t.secret)||"",title:t==null?void 0:t.name})}),e.jsx(O,{size:"md",title:`Delete secret ${t==null?void 0:t.name}`,secondaryText:"Once you delete a secret, there is no going back. Please be certain.",isOpen:u,onClose:i,mainButtonProps:{children:"Delete Secret",onClick:N},secondaryButtonProps:{children:"Back",onClick:i}})]}):e.jsx(k,{title:"Secrets",actions:e.jsx(h,{href:D("/user_guides/projects/secrets/create_secret/"),external:!0,target:"_blank",p:0,intent:"inline",children:"documentation↗"}),children:e.jsx(L,{mt:"20px",mx:"-20px",children:e.jsxs(b,{height:"140px",mt:"30px",flexDirection:"column",alignItems:"center",children:[e.jsx(j,{fontSize:"18px",bold:!0,children:"No secrets defined"}),e.jsx(j,{mt:"15px",children:"Secrets let you store sensitive data in order to access to it later from a Jupyter notebook for instance"}),e.jsx(h,{mt:"40px",minWidth:"105px",onClick:()=>c(P.account.secrets.create),children:"New Secret"})]})})})};export{Y as default};
