import{r,g,x as S,A as y,b8 as A,z as b,bh as B,aS as E,b1 as M,P as C,b3 as k,aY as T,a as V,j as e,a$ as $,E as w,aU as u,cj as P,o as D,Q as j,b as L,b0 as O,cR as I,aZ as Q}from"./index-ea7817a2.js";import{s as G,a as U}from"./secrets.selectors-ddf84833.js";import{S as W}from"./secrets-9b018a52.js";const F=(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,S,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:A(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])},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"}}},X=r.memo(B),H=()=>{const c=E(),o=M(),[t,l]=r.useState(),[h,i]=C(),[m,a]=C(),s=k(G),n=k(U).sort((x,_)=>x.name.localeCompare(_.name));T(Q.secrets);const{currentData:p=[],isLoading:f}=V(),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]=F(n,p,d,R);return r.useEffect(()=>{o.secrets.fetchAll()},[o]),s||f?e.jsx($,{}):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(P.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(L.account.secrets.create),children:"New Secret"})]}),e.jsx(D,{mt:"20px",mx:"-20px",sx:J,children:e.jsx(X,{legend:["name","visibility","creation"],middleColumn:2,groupComponents:N,groupProps:z})})]}),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(P.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(S,{fontSize:"18px",bold:!0,children:"No secrets defined"}),e.jsx(S,{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(L.account.secrets.create),children:"New Secret"})]})})})};export{H as default};
