import{r,Q as g,b,f as y,aV as E,Z as C,bU as M,bw as T,aD as z,c as S,aL as k,bC as V,a as A,j as e,L as Q,m as D,aG as h,c1 as w,e as L,B as j,s as P,bE as O,aK as $,bD as G}from"./index-dP1W1_bd.js";import{s as I,a as U}from"./secrets.selectors-CBieCzvZ.js";import{S as W}from"./secrets-Bl4_kNye.js";const Z=(c,o,t,l)=>{const m=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===W.private.toUpperCase()||!o?s.toLowerCase():`${s.toLowerCase()}(${m(n)})`,[m,o]),u=r.useMemo(()=>c.map(()=>[g,g,b,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:E(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(()=>[u,a],[u,a])},F={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"}}},H=r.memo(M),X=()=>{const c=T(),o=z(),[t,l]=r.useState(),[m,i]=S(),[u,a]=S(),s=k(I),n=k(U).sort((x,_)=>x.name.localeCompare(_.name));V(G.secrets);const{currentData:p=[],isLoading:f}=A(),d=x=>{l(x),a()},v=x=>{l(x),i()},R=async()=>{t&&(await o.secrets.delete(t.name),o.secrets.fetchAll(),i())},[B,N]=Z(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(D,{width:"1000px",title:"Secrets",contentProps:{pb:0,overflow:"visible"},actions:e.jsx(h,{href:w("/user_guides/projects/secrets/create_secret/"),external:!0,target:"_blank",p:0,intent:"inline",children:"documentation↗"}),children:[e.jsxs(j,{mb:"25x",children:[e.jsxs(j,{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:F,children:e.jsx(H,{legend:["name","visibility","creation"],middleColumn:2,groupComponents:B,groupProps:N})})]}),e.jsx(O,{title:"Read the secret",isOpen:u,onClose:a,secondaryButtonProps:{children:"Done",onClick:a},children:e.jsx($,{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:m,onClose:i,mainButtonProps:{children:"Delete Secret",onClick:R},secondaryButtonProps:{children:"Back",onClick:i}})]}):e.jsx(D,{title:"Secrets",actions:e.jsx(h,{href:w("/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(j,{height:"140px",mt:"30px",flexDirection:"column",alignItems:"center",children:[e.jsx(b,{fontSize:"18px",bold:!0,children:"No secrets defined"}),e.jsx(b,{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{X as default};
