import{aR as w,u as k,r as g,g as D,e as m,c as S,bd as T,ae as E,j as e,O as b,af as Y,Z as G,bg as H,aX as M,gy as O,dl as z,a_ as v,ce as R,a,gm as X,aG as Z,bp as A,aT as L,ct as Q,f as h,ak as U,aY as V}from"./index-d6499a22.js";import{u as I}from"./useUserPermissions-3851a25d.js";import{u as W}from"./useMultiStoreSelect-a2174957.js";import{N as _}from"./NoData-789df290.js";import{d as $}from"./dumbPluralize-86a9b9d6.js";import"./index-da50fbe6.js";import"./file-utils-b5704e1c.js";import"./useCurrentProject-b23444be.js";import"./useProject-0d0fdeb3.js";const q={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 c=w(),{id:l,fsId:n}=k(),{canEdit:f,isDataScientist:i,isLoading:d}=I(),t=f&&!d&&!i,o=g.useCallback(s=>()=>{c(D(m.storageConnector.edit,m.project.value,{connectorName:s,id:l,fsId:n}))},[c,l,n]),p=g.useMemo(()=>new Array(r.length).fill(null).map(()=>[S,T,S,E]),[r]),j=g.useMemo(()=>r.map(({name:s,storageConnectorType:C,description:x})=>[{children:s,bold:!0},{value:C,variant:"default",width:"max-content"},{children:x,gray:!0,bold:!0},{mr:"10px",mainText:t?"Edit":i?"Your role is not allowed to perform this action":"You have no edit right on the feature store",children:e.jsx(b,{p:"5px",height:"28px",sx:{cursor:t?"pointer":"",backgroundColor:"inherit",transition:"all .4s ease",":hover":{svg:{path:{fill:"primary"}}}},disabled:!t,onClick:t?o(s):void 0,"data-test":`edit-${s}`,children:e.jsx(Y,{color:t?"black":"gray",icon:G.edit})})}]),[r,o,i,t]);return e.jsx(b,{sx:q,children:e.jsx(H,{middleColumn:2,groupComponents:p,groupProps:j})})},ie=()=>{M(V.storageConnectors);const r=w(),{id:c,fsId:l}=k(),[n,f]=g.useState(""),{canEdit:i,isDataScientist:d,isLoading:t}=I(),{currentData:o=[],isFetching:p,isLoading:j}=O({pId:+c,fsId:+l}),s=z(u=>u.name.toLowerCase().includes(n.toLocaleLowerCase())||u.description.toLowerCase().includes(n.toLocaleLowerCase()))(o),{selectFSValue:C,selectFSOptions:x,handleFSSelectionChange:N,isLoading:P,isSharedLoading:F}=W(),y=()=>{r(D(m.storageConnector.create,m.project.value,{id:c,fsId:l}))};return P||F?e.jsx(v,{}):!j&&!o?e.jsx(R,{}):e.jsxs(a,{flexDirection:"column",mt:"-20px",children:[e.jsxs(a,{sx:X.stickyHeader,pt:"20px",children:[e.jsxs(a,{alignItems:"center",children:[e.jsx(Z,{labelProps:{flexGrow:1,mr:"20px"},variant:"white",value:n,placeholder:"Find a Storage Connector by name or description...",onChange:u=>f(u.target.value),autoFocus:!0}),o&&e.jsxs(a,{justifyContent:"space-between",alignItems:"center",children:[x.length>1&&e.jsx(A,{mx:"20px",width:"auto",listWidth:"max-content",placeholder:"feature store",value:C,options:x,onChange:N}),e.jsx(E,{mainText:d?"Your role is not allowed to perform this action":"You have no edit right on the feature store",disabled:i&&!d&&!t,children:e.jsx(L,{onClick:y,disabled:!i||d||t,children:"New storage connector"})})]})]}),e.jsx(Q,{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:o.length}),e.jsxs(h,{children:["storage ",$("connector",o.length)," ","displayed"]})]})]}),p&&e.jsx(v,{}),!p&&U(o)&&e.jsx(a,{my:"20px",justifyContent:"center",children:e.jsx(_,{mainText:"No storage connector setup up",children:e.jsx(L,{intent:"secondary",onClick:y,children:"Set up a storage connector"})})}),e.jsx(a,{flexDirection:"column",mt:"20px",bg:"white",children:e.jsx(B,{data:s})})]})};export{ie as default};
