import{r,f as g,c as y,V as S,b7 as V,Z as b,bg as B,aR as M,b0 as $,l as C,b2 as k,aX as z,b as A,j as e,a_ as E,K as w,aT as u,ci as L,O as D,a as j,e as P,a$ as O,cO as I,aY as U}from"./index-d6499a22.js";import{s as G,a as K}from"./secrets.selectors-ddf84833.js";import{S as W}from"./secrets-9b018a52.js";const Z=(c,o,t,l)=>{const h=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()}(${h(n)})`,[h,o]),m=r.useMemo(()=>c.map(()=>[g,g,y,S,S]),[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:V(new Date(f),"yyyy-MM-dd")},{intent:"ghost",icon:b.eye,tooltip:"Read",disabled:!d,onClick:()=>t({name:s,secret:d})},{intent:"ghost",icon:b.bin,tooltip:"Delete",onClick:()=>l({name:s,secret:d})}]),[c,i,l,t]);return r.useMemo(()=>[m,a],[m,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"}}},J=r.memo(B),q=()=>{const c=M(),o=$(),[t,l]=r.useState(),[h,i]=C(),[m,a]=C(),s=k(G),n=k(K).sort((x,T)=>x.name.localeCompare(T.name));z(U.secrets);const{currentData:p=[],isLoading:f}=A(),d=x=>{l(x),a()},R=x=>{l(x),i()},v=async()=>{t&&(await o.secrets.delete(t.name),o.secrets.fetchAll(),i())},[N,_]=Z(n,p,d,R);return r.useEffect(()=>{o.secrets.fetchAll()},[o]),s||f?e.jsx(E,{}):n.length?e.jsxs(e.Fragment,{children:[e.jsxs(w,{width:"1000px",title:"Secrets",contentProps:{pb:0,overflow:"visible"},actions:e.jsx(u,{href:"https://docs.hopsworks.ai/".concat(L.docsVersion,"/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(u,{minWidth:"105px",onClick:()=>c(P.account.secrets.create),children:"New Secret"})]}),e.jsx(D,{mt:"20px",mx:"-20px",sx:F,children:e.jsx(J,{legend:["name","visibility","creation"],middleColumn:2,groupComponents:N,groupProps:_})})]}),e.jsx(O,{title:"Read the secret",isOpen:m,onClose:a,secondaryButtonProps:{children:"Done",onClick:a},children:e.jsx(I,{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:h,onClose:i,mainButtonProps:{children:"Delete Secret",onClick:v},secondaryButtonProps:{children:"Back",onClick:i}})]}):e.jsx(w,{title:"Secrets",actions:e.jsx(u,{href:"https://docs.hopsworks.ai/".concat(L.docsVersion,"/user_guides/projects/secrets/create_secret/"),external:!0,target:"_blank",p:0,intent:"inline",children:"documentation↗"}),children:e.jsx(D,{mt:"20px",mx:"-20px",children:e.jsxs(j,{height:"140px",mt:"30px",flexDirection:"column",alignItems:"center",children:[e.jsx(y,{fontSize:"18px",bold:!0,children:"No secrets defined"}),e.jsx(y,{mt:"15px",children:"Secrets let you store sensitive data in order to access to it later from a Jupyter notebook for instance"}),e.jsx(u,{mt:"40px",minWidth:"105px",onClick:()=>c(P.account.secrets.create),children:"New Secret"})]})})})};export{q as default};
