import{r,f as g,c as b,i as y,bP as A,d as C,bQ as E,bo as B,bI as I,y as S,bJ as D,bx as z,by as M,b as W,j as e,D as $,W as k,L as w,a as j,aJ as h,t as L,c5 as P,bA as N,cN as J,bX as G}from"./index-_eM6l4Nf.js";import{s as Q,a as V}from"./secrets.selectors-CBieCzvZ.js";import{S as q}from"./secrets-Bl4_kNye.js";const F=(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===q.private.toUpperCase()||!o?s.toLowerCase():`${s.toLowerCase()}(${m(n)})`,[m,o]),u=r.useMemo(()=>i.map(()=>[g,g,b,y,y]),[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:A(new Date(f),E.DATE_TIME.DATE)},{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})}]),[i,c,l,t]);return r.useMemo(()=>[u,a],[u,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"}}},U=r.memo(G),Z=()=>{const i=B(),o=I(),[t,l]=r.useState(),[m,c]=S(),[u,a]=S(),s=D(Q),n=D(V).sort((x,_)=>x.name.localeCompare(_.name));z(M.secrets);const{currentData:p=[],isLoading:f}=W(),d=x=>{l(x),a()},O=x=>{l(x),c()},T=async()=>{t&&(await o.secrets.delete(t.name),o.secrets.fetchAll(),c())},[v,R]=F(n,p,d,O);return r.useEffect(()=>{o.secrets.fetchAll()},[o]),s||f?e.jsx($,{}):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(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:()=>i(L.account.secrets.create),children:"New Secret"})]}),e.jsx(w,{mt:"20px",mx:"-20px",sx:H,children:e.jsx(U,{legend:["name","visibility","creation"],middleColumn:2,groupComponents:v,groupProps:R})})]}),e.jsx(N,{title:"Read the secret",isOpen:u,onClose:a,secondaryButtonProps:{children:"Done",onClick:a},children:e.jsx(J,{copyButton:!0,content:(t==null?void 0:t.secret)||"",title:t==null?void 0:t.name})}),e.jsx(N,{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(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:()=>i(L.account.secrets.create),children:"New Secret"})]})})})};export{Z as default};
