import{bp as w,u as P,r as g,q as k,s as m,c as y,bb as Y,at as E,j as e,d as S,au as G,C as H,bX as M,bx as _,de as q,L as v,cr as z,B as i,g4 as B,b5 as D,be as O,b4 as L,cG as U,b as h,bq as A,h as J,by as Q}from"./index-C1DmWO_C.js";import{u as R}from"./index-DDgDmsNg.js";import{u as F}from"./useUserPermissions-BiARnwL4.js";import{u as V}from"./useMultiStoreSelect-BV826hNF.js";import{N as X}from"./NoData-Y_e6mfNf.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"}}}}},K=({data:n})=>{const l=w(),{id:c,fsId:r}=P(),{canEdit:f,isDataScientist:a,isLoading:d}=F(),s=f&&!d&&!a,t=g.useCallback(o=>()=>{l(k(m.storageConnector.edit,m.project.value,{connectorName:o,id:c,fsId:r}))},[l,c,r]),p=g.useMemo(()=>new Array(n.length).fill(null).map(()=>[y,Y,y,E]),[n]),b=g.useMemo(()=>n.map(({name:o,storageConnectorType:j,description:u})=>[{children:o,bold:!0},{value:j,variant:"default",width:"max-content"},{children:u,gray:!0,bold:!0},{mr:"10px",mainText:s?"Edit":a?"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(G,{color:s?"black":"gray",icon:H.edit})})}]),[n,t,a,s]);return e.jsx(S,{sx:$,children:e.jsx(M,{middleColumn:2,groupComponents:p,groupProps:b})})},oe=()=>{_(Q.storageConnectors);const n=w(),{id:l,fsId:c}=P(),[r,f]=g.useState(""),{canEdit:a,isDataScientist:d,isLoading:s}=F(),{data:t,isFetching:p,isLoading:b}=R({pId:+l,fsId:+c}),o=q(x=>x.name.toLowerCase().includes(r.toLocaleLowerCase())||x.description.toLowerCase().includes(r.toLocaleLowerCase()))((t==null?void 0:t.items)??[]),{selectFSValue:j,selectFSOptions:u,handleFSSelectionChange:I,isLoading:N,isSharedLoading:T}=V(),C=()=>{n(k(m.storageConnector.create,m.project.value,{id:l,fsId:c}))};return N||T?e.jsx(v,{}):!b&&!t?e.jsx(z,{}):e.jsxs(i,{flexDirection:"column",mt:"-20px",children:[e.jsxs(i,{sx:B.stickyHeader,pt:"20px",children:[e.jsxs(i,{alignItems:"center",gap:"10px",children:[e.jsx(D,{labelProps:{flexGrow:1},variant:"white",value:r,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:j,options:u,onChange:I}),e.jsx(E,{mainText:d?"Your role is not allowed to perform this action":"You have no edit right on the feature store",disabled:a&&!d&&!s,children:e.jsx(L,{onClick:C,disabled:!a||d||s,children:"New storage connector"})})]})]}),e.jsx(U,{mt:"10px",mb:"20px",ml:"0px",width:"100%",sx:{backgroundColor:"grayShade2",height:"3px"}}),e.jsxs(i,{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:["storage"," ",A("connector",(t==null?void 0:t.count)??0)," ","displayed"]})]})]}),p&&e.jsx(v,{}),!p&&J(t)&&e.jsx(i,{my:"20px",justifyContent:"center",children:e.jsx(X,{mainText:"No storage connector setup up",children:e.jsx(L,{intent:"secondary",onClick:C,children:"Set up a storage connector"})})}),e.jsx(i,{flexDirection:"column",mt:"20px",mb:"40px",bg:"white",children:e.jsx(K,{data:o})})]})};export{oe as default};
