import{b4 as w,u as P,r as m,o as F,q as g,y,aN as Y,am as k,j as e,c as S,an as z,T as H,bt as M,bb as V,cF as D,L as v,bW as G,d as a,fl as Q,aR as R,aQ as q,b6 as L,ca as A,p as h,g as J,bc as K}from"./index-CK33qGU_.js";import{u as O}from"./index-DnFHOcek.js";import{u as E}from"./useUserPermissions-CGy0I-II.js";import{u as U}from"./useMultiStoreSelect-Ckt9gw8q.js";import{N as W}from"./NoData-CuLyR2Bg.js";import{d as _}from"./dumbPluralize-CcxDsNiu.js";import"./FileUploaderButton-Bppadu35.js";import"./useDownload-hrjXceJg.js";import"./useProject-BzBQtp4J.js";import"./length-fOfC3W0h.js";const $={table:{td:{":nth-of-type(1)":{pl:"20px"},":nth-of-type(2)":{px:0},":nth-of-type(4)":{float:"right",height:"60px",display:"flex",alignItems:"center"},":nth-of-type(5)":{pr:"20px",pl:0,svg:{fontSize:"14px"}}}}},B=({data:r})=>{const l=w(),{id:c,fsId:n}=P(),{canEdit:f,isDataScientist:i,isLoading:d}=E(),o=f&&!d&&!i,t=m.useCallback(s=>()=>{l(F(g.storageConnector.edit,g.project.value,{connectorName:s,id:c,fsId:n}))},[l,c,n]),p=m.useMemo(()=>new Array(r.length).fill(null).map(()=>[y,Y,y,k]),[r]),j=m.useMemo(()=>r.map(({name:s,storageConnectorType:b,description:u})=>[{children:s,bold:!0},{value:b,variant:"default",width:"max-content"},{children:u,gray:!0,bold:!0},{mr:"10px",mainText:o?"Edit":i?"Your role is not allowed to perform this action":"You have no edit right on the feature store",children:e.jsx(S,{p:"5px",height:"28px",sx:{cursor:o?"pointer":"",backgroundColor:"inherit",transition:"all .4s ease",":hover":{svg:{path:{fill:"primary"}}}},disabled:!o,onClick:o?t(s):void 0,"data-test":`edit-${s}`,children:e.jsx(z,{color:o?"black":"gray",icon:H.edit})})}]),[r,t,i,o]);return e.jsx(S,{sx:$,children:e.jsx(M,{middleColumn:2,groupComponents:p,groupProps:j})})},le=()=>{V(K.storageConnectors);const r=w(),{id:l,fsId:c}=P(),[n,f]=m.useState(""),{canEdit:i,isDataScientist:d,isLoading:o}=E(),{data:t,isFetching:p,isLoading:j}=O({pId:+l,fsId:+c}),s=D(x=>x.name.toLowerCase().includes(n.toLocaleLowerCase())||x.description.toLowerCase().includes(n.toLocaleLowerCase()))((t==null?void 0:t.items)??[]),{selectFSValue:b,selectFSOptions:u,handleFSSelectionChange:N,isLoading:T,isSharedLoading:I}=U(),C=()=>{r(F(g.storageConnector.create,g.project.value,{id:l,fsId:c}))};return T||I?e.jsx(v,{}):!j&&!t?e.jsx(G,{}):e.jsxs(a,{flexDirection:"column",mt:"-20px",children:[e.jsxs(a,{sx:Q.stickyHeader,pt:"20px",children:[e.jsxs(a,{alignItems:"center",gap:"10px",children:[e.jsx(R,{labelProps:{flexGrow:1},variant:"white",value:n,placeholder:"Find a Storage Connector by name or description...",onChange:x=>f(x.target.value),autoFocus:!0}),t&&e.jsxs(e.Fragment,{children:[u.length>1&&e.jsx(q,{variant:"white",width:"auto",label:"feature store",labelPosition:"inline",value:b,options:u,onChange:N}),e.jsx(k,{mainText:d?"Your role is not allowed to perform this action":"You have no edit right on the feature store",disabled:i&&!d&&!o,children:e.jsx(L,{onClick:C,disabled:!i||d||o,children:"New storage connector"})})]})]}),e.jsx(A,{mt:"10px",mb:"20px",ml:"0px",width:"100%",sx:{backgroundColor:"grayShade2",height:"3px"}}),e.jsxs(a,{mb:"15px",children:[e.jsx(h,{primary:!0,px:"5px",children:s.length}),e.jsx(h,{children:"out of"}),e.jsx(h,{primary:!0,px:"5px",children:(t==null?void 0:t.count)??0}),e.jsxs(h,{children:["storage"," ",_("connector",(t==null?void 0:t.count)??0)," ","displayed"]})]})]}),p&&e.jsx(v,{}),!p&&J(t)&&e.jsx(a,{my:"20px",justifyContent:"center",children:e.jsx(W,{mainText:"No storage connector setup up",children:e.jsx(L,{intent:"secondary",onClick:C,children:"Set up a storage connector"})})}),e.jsx(a,{flexDirection:"column",mt:"20px",mb:"40px",bg:"white",children:e.jsx(B,{data:s})})]})};export{le as default};
