import{bo as w,u as E,r as g,s as I,t as m,c as C,b8 as D,ao as k,j as e,L as S,ap as H,d as Y,bX as z,bx as G,by as M,dz as _,D as v,cq as J,a as c,l as Q,g5 as q,aH as A,bd as O,aJ as L,cD as R,f as h,bp as U,bT as V}from"./index-_eM6l4Nf.js";import{a as W,u as X}from"./index-CZNL5XBB.js";import{u as P}from"./useUserPermissions-Dd9YjnbM.js";import{u as $}from"./useMultiStoreSelect-B3ie-TCg.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"}}}}},K=({data:a})=>{const r=w(),{id:i,fsId:n}=E(),{canEdit:f,isDataScientist:l,isLoading:d}=P(),s=f&&!d&&!l,t=g.useCallback(o=>()=>{r(I(m.project.storageConnector.edit,m.project.value,{connectorName:o,id:i,fsId:n}))},[r,i,n]),p=g.useMemo(()=>new Array(a.length).fill(null).map(()=>[C,D,C,k]),[a]),j=g.useMemo(()=>a.map(({name:o,storageConnectorType:b,description:u})=>[{children:o,bold:!0},{value:b,variant:"default",width:"max-content"},{children:u,gray:!0,bold:!0},{mr:"10px",mainText:s?"Edit":l?"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:s?"pointer":"",backgroundColor:"inherit",transition:"all .4s ease",":hover":{svg:{path:{fill:"primary"}}}},disabled:!s,onClick:s?t(o):void 0,"data-test":`edit-${o}`,children:e.jsx(H,{color:s?"black":"gray",icon:Y.edit})})}]),[a,t,l,s]);return e.jsx(S,{sx:B,children:e.jsx(z,{middleColumn:2,groupComponents:p,groupProps:j})})},oe=()=>{G(M.storageConnectors);const a=w(),{id:r,fsId:i}=E();W({pId:+r,fsId:+i});const[n,f]=g.useState(""),{canEdit:l,isDataScientist:d,isLoading:s}=P(),{data:t,isFetching:p,isLoading:j}=X({pId:+r,fsId:+i}),o=_(x=>x.name.toLowerCase().includes(n.toLocaleLowerCase())||x.description.toLowerCase().includes(n.toLocaleLowerCase()))((t==null?void 0:t.items)??[]),{selectFSValue:b,selectFSOptions:u,handleFSSelectionChange:F,isLoading:T,isSharedLoading:N}=$(),y=()=>{a(I(m.project.storageConnector.create,m.project.value,{id:r,fsId:i}))};return T||N?e.jsx(v,{}):!j&&!t?e.jsx(J,{}):e.jsxs(c,{flexDirection:"column",mt:"-20px",children:[e.jsxs(c,{sx:q.stickyHeader,pt:"20px",children:[e.jsxs(c,{alignItems:"center",gap:"10px",children:[e.jsx(A,{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(O,{variant:"white",width:"auto",label:"feature store",labelPosition:"inline",value:b,options:u,onChange:F}),e.jsx(k,{mainText:d?"Your role is not allowed to perform this action":"You have no edit right on the feature store",disabled:l&&!d&&!s,children:e.jsx(L,{onClick:y,disabled:!l||d||s,children:"New data source"})})]})]}),e.jsx(R,{mt:"10px",mb:"20px",ml:"0px",width:"100%",sx:{backgroundColor:"grayShade2",height:"3px"}}),e.jsxs(c,{mb:"15px",children:[e.jsx(h,{primary:!0,px:"5px",children:o.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:["data ",U("source",(t==null?void 0:t.count)??0)," ","displayed"]})]})]}),p&&e.jsx(v,{}),!p&&Q(t)&&e.jsx(c,{my:"20px",justifyContent:"center",children:e.jsx(V,{mainText:"No storage connector setup up",children:e.jsx(L,{intent:"secondary",onClick:y,children:"Set up a data source"})})}),e.jsx(c,{flexDirection:"column",mt:"20px",mb:"40px",bg:"white",children:e.jsx(K,{data:o})})]})};export{oe as default};
