import{aS as w,u as D,r as g,c as I,b as m,x as y,be as T,af as P,j as e,o as b,ag as Y,z,bh as H,aY as M,gF as Q,dp as A,a$ as v,cf as G,Q as a,gr as U,aH as V,bq as $,aU as L,cu as q,g as u,al as O,aZ as R}from"./index-ea7817a2.js";import{u as k}from"./useUserPermissions-d2903885.js";import{u as W}from"./useMultiStoreSelect-64ee55e0.js";import{N as X}from"./NoData-8733f606.js";import{d as Z}from"./dumbPluralize-86a9b9d6.js";import"./index-8f672200.js";import"./file-utils-a5f053e8.js";import"./useCurrentProject-0132f110.js";import"./useProject-77619fff.js";const B={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"}}}}},J=({data:r})=>{const c=w(),{id:l,fsId:n}=D(),{canEdit:f,isDataScientist:i,isLoading:d}=k(),t=f&&!d&&!i,o=g.useCallback(s=>()=>{c(I(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(()=>[y,T,y,P]),[r]),C=g.useMemo(()=>r.map(({name:s,storageConnectorType:j,description:x})=>[{children:s,bold:!0},{value:j,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:z.edit})})}]),[r,o,i,t]);return e.jsx(b,{sx:B,children:e.jsx(H,{middleColumn:2,groupComponents:p,groupProps:C})})},ie=()=>{M(R.storageConnectors);const r=w(),{id:c,fsId:l}=D(),[n,f]=g.useState(""),{canEdit:i,isDataScientist:d,isLoading:t}=k(),{currentData:o=[],isFetching:p,isLoading:C}=Q({pId:+c,fsId:+l}),s=A(h=>h.name.toLowerCase().includes(n.toLocaleLowerCase())||h.description.toLowerCase().includes(n.toLocaleLowerCase()))(o),{selectFSValue:j,selectFSOptions:x,handleFSSelectionChange:E,isLoading:F,isSharedLoading:N}=W(),S=()=>{r(I(m.storageConnector.create,m.project.value,{id:c,fsId:l}))};return F||N?e.jsx(v,{}):!C&&!o?e.jsx(G,{}):e.jsxs(a,{flexDirection:"column",mt:"-20px",children:[e.jsxs(a,{sx:U.stickyHeader,pt:"20px",children:[e.jsxs(a,{alignItems:"center",children:[e.jsx(V,{labelProps:{flexGrow:1,mr:"20px"},variant:"white",value:n,placeholder:"Find a Storage Connector by name or description...",onChange:h=>f(h.target.value),autoFocus:!0}),o&&e.jsxs(a,{justifyContent:"space-between",alignItems:"center",children:[x.length>1&&e.jsx($,{mx:"20px",width:"auto",listWidth:"max-content",placeholder:"feature store",value:j,options:x,onChange:E}),e.jsx(P,{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:S,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(u,{primary:!0,px:"5px",children:s.length}),e.jsx(u,{children:"out of"}),e.jsx(u,{primary:!0,px:"5px",children:o.length}),e.jsxs(u,{children:["storage ",Z("connector",o.length)," ","displayed"]})]})]}),p&&e.jsx(v,{}),!p&&O(o)&&e.jsx(a,{my:"20px",justifyContent:"center",children:e.jsx(X,{mainText:"No storage connector setup up",children:e.jsx(L,{intent:"secondary",onClick:S,children:"Set up a storage connector"})})}),e.jsx(a,{flexDirection:"column",mt:"20px",bg:"white",children:e.jsx(J,{data:s})})]})};export{ie as default};
