import{bo as w,u as I,r as g,o as E,q as m,c as y,b8 as Y,ao as P,j as e,L as S,ap as _,C as D,bW as G,bw as H,bx as M,dw as Q,D as v,cp as $,$ as c,h as z,f_ as U,b2 as q,bd as A,b1 as L,cC as J,f as h,bp as O,bS as R}from"./index-46ma1THH.js";import{a as V,u as W}from"./index-CEcdCfcT.js";import{u as k}from"./useUserPermissions-DiAMkzC6.js";import{u as B}from"./useMultiStoreSelect-B0XeLjHW.js";const K={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"}}}}},X=({data:a})=>{const r=w(),{id:i,fsId:n}=I(),{canEdit:f,isDataScientist:l,isLoading:d}=k(),s=f&&!d&&!l,t=g.useCallback(o=>()=>{r(E(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(()=>[y,Y,y,P]),[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(_,{color:s?"black":"gray",icon:D.edit})})}]),[a,t,l,s]);return e.jsx(S,{sx:K,children:e.jsx(G,{middleColumn:2,groupComponents:p,groupProps:j})})},oe=()=>{H(M.storageConnectors);const a=w(),{id:r,fsId:i}=I();V({pId:+r,fsId:+i});const[n,f]=g.useState(""),{canEdit:l,isDataScientist:d,isLoading:s}=k(),{data:t,isFetching:p,isLoading:j}=W({pId:+r,fsId:+i}),o=Q(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}=B(),C=()=>{a(E(m.project.storageConnector.create,m.project.value,{id:r,fsId:i}))};return T||N?e.jsx(v,{}):!j&&!t?e.jsx($,{}):e.jsxs(c,{flexDirection:"column",mt:"-20px",children:[e.jsxs(c,{sx:U.stickyHeader,pt:"20px",children:[e.jsxs(c,{alignItems:"center",gap:"10px",children:[e.jsx(q,{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(A,{variant:"white",width:"auto",label:"feature store",labelPosition:"inline",value:b,options:u,onChange:F}),e.jsx(P,{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:C,disabled:!l||d||s,children:"New data source"})})]})]}),e.jsx(J,{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 ",O("source",(t==null?void 0:t.count)??0)," ","displayed"]})]})]}),p&&e.jsx(v,{}),!p&&z(t)&&e.jsx(c,{my:"20px",justifyContent:"center",children:e.jsx(R,{mainText:"No storage connector setup up",children:e.jsx(L,{intent:"secondary",onClick:C,children:"Set up a data source"})})}),e.jsx(c,{flexDirection:"column",mt:"20px",mb:"40px",bg:"white",children:e.jsx(X,{data:o})})]})};export{oe as default};
