import{r,d as g,c as b,n as C,v as S,c1 as E,c2 as z,bx as A,bW as B,w as y,bX as k,bG as M,bH as F,b as I,j as e,L as J,f as w,F as D,q as j,aJ as h,x as P,ci as L,bJ as v,bU as V,bV as W}from"./index-DHiyXWqE.js";import{s as $,a as q}from"./secrets.selectors-CBieCzvZ.js";import{S as G}from"./secrets-Bl4_kNye.js";const H=(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===G.private.toUpperCase()||!o?s.toLowerCase():`${s.toLowerCase()}(${m(n)})`,[m,o]),u=r.useMemo(()=>c.map(()=>[g,g,b,C,C]),[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),z.DATE_TIME.DATE)},{intent:"ghost",icon:S.eye,tooltip:"Read",disabled:!d,onClick:()=>t({name:s,secret:d})},{intent:"ghost",icon:S.bin,tooltip:"Delete",onClick:()=>l({name:s,secret:d})}]),[c,i,l,t]);return r.useMemo(()=>[u,a],[u,a])},U={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"}}},K=r.memo(W),Z=()=>{const c=A(),o=B(),[t,l]=r.useState(),[m,i]=y(),[u,a]=y(),s=k($),n=k(q).sort((x,_)=>x.name.localeCompare(_.name));M(F.secrets);const{currentData:p=[],isLoading:f}=I(),d=x=>{l(x),a()},N=x=>{l(x),i()},O=async()=>{t&&(await o.secrets.delete(t.name),o.secrets.fetchAll(),i())},[T,R]=H(n,p,d,N);return r.useEffect(()=>{o.secrets.fetchAll()},[o]),s||f?e.jsx(J,{}):n.length?e.jsxs(e.Fragment,{children:[e.jsxs(w,{width:"1000px",title:"Secrets",contentProps:{pb:0,overflow:"visible"},actions:e.jsx(h,{href:L("/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(D,{mt:"20px",mx:"-20px",sx:U,children:e.jsx(K,{legend:["name","visibility","creation"],middleColumn:2,groupComponents:T,groupProps:R})})]}),e.jsx(v,{title:"Read the secret",isOpen:u,onClose:a,secondaryButtonProps:{children:"Done",onClick:a},children:e.jsx(V,{copyButton:!0,content:(t==null?void 0:t.secret)||"",title:t==null?void 0:t.name})}),e.jsx(v,{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:O},secondaryButtonProps:{children:"Back",onClick:i}})]}):e.jsx(w,{title:"Secrets",actions:e.jsx(h,{href:L("/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(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{Z as default};
