import{r,f as g,c as j,i as C,bO as E,C as y,bP as z,bo as A,bH as B,y as S,bI as D,bw as I,bx as M,a as $,j as e,D as W,b as k,L as w,$ as b,b1 as h,q as L,c4 as P,bz as O,cM as F,bW as G}from"./index-46ma1THH.js";import{s as H,a as Q}from"./secrets.selectors-CBieCzvZ.js";import{S as V}from"./secrets-Bl4_kNye.js";const q=(i,o,t,l)=>{const m=r.useCallback(s=>{var n;return((n=o.find(p=>p.projectId===s))==null?void 0:n.projectName)||""},[o]),c=r.useCallback((s,n)=>s===V.private.toUpperCase()||!o?s.toLowerCase():`${s.toLowerCase()}(${m(n)})`,[m,o]),u=r.useMemo(()=>i.map(()=>[g,g,j,C,C]),[i]),a=r.useMemo(()=>i.map(({name:s,visibility:n,scope:p,addedOn:f,secret:d})=>[{children:s},{children:c(n,+p)},{gray:!0,children:E(new Date(f),z.DATE_TIME.DATE)},{intent:"ghost",icon:y.eye,tooltip:"Read",disabled:!d,onClick:()=>t({name:s,secret:d})},{intent:"ghost",icon:y.bin,tooltip:"Delete",onClick:()=>l({name:s,secret:d})}]),[i,c,l,t]);return r.useMemo(()=>[u,a],[u,a])},J={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"}}},U=r.memo(G),Z=()=>{const i=A(),o=B(),[t,l]=r.useState(),[m,c]=S(),[u,a]=S(),s=D(H),n=D(Q).sort((x,N)=>x.name.localeCompare(N.name));I(M.secrets);const{currentData:p=[],isLoading:f}=$(),d=x=>{l(x),a()},R=x=>{l(x),c()},T=async()=>{t&&(await o.secrets.delete(t.name),o.secrets.fetchAll(),c())},[_,v]=q(n,p,d,R);return r.useEffect(()=>{o.secrets.fetchAll()},[o]),s||f?e.jsx(W,{}):n.length?e.jsxs(e.Fragment,{children:[e.jsxs(k,{width:"1000px",title:"Secrets",contentProps:{pb:0,overflow:"visible"},actions:e.jsx(h,{href:P("/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:()=>i(L.account.secrets.create),children:"New Secret"})]}),e.jsx(w,{mt:"20px",mx:"-20px",sx:J,children:e.jsx(U,{legend:["name","visibility","creation"],middleColumn:2,groupComponents:_,groupProps:v})})]}),e.jsx(O,{title:"Read the secret",isOpen:u,onClose:a,secondaryButtonProps:{children:"Done",onClick:a},children:e.jsx(F,{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:c,mainButtonProps:{children:"Delete Secret",onClick:T},secondaryButtonProps:{children:"Back",onClick:c}})]}):e.jsx(k,{title:"Secrets",actions:e.jsx(h,{href:P("/user_guides/projects/secrets/create_secret/"),external:!0,target:"_blank",p:0,intent:"inline",children:"documentation↗"}),children:e.jsx(w,{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:()=>i(L.account.secrets.create),children:"New Secret"})]})})})};export{Z as default};
