import{bw as w,u as k,r as m,q as E,s as g,b as y,bj as M,ar as P,j as e,e as S,as as Y,Z,bU as D,bC as G,a_ as H,L as v,ck as Q,B as a,fW as z,aM as A,bm as B,aG as L,cA as R,Q as h,g as U,bD as V}from"./index-dP1W1_bd.js";import{u as q}from"./index-DG59sqU_.js";import{u as F}from"./useUserPermissions-Olw8jjZn.js";import{u as K}from"./useMultiStoreSelect-BgwXFUPU.js";import{N as O}from"./NoData-DLZ_8GEo.js";import{d as W}from"./dumbPluralize-CcxDsNiu.js";import"./FileUploaderButton-frSujVRY.js";import"./useDownload-C3yCvYJa.js";import"./useProject-CXVt1xnE.js";import"./length-BzpOfCdE.js";import"./uniq-98MdbBvs.js";import"./uniqBy-6mvKp2Ip.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"}}}}},$=({data:r})=>{const l=w(),{id:c,fsId:i}=k(),{canEdit:f,isDataScientist:n,isLoading:d}=F(),o=f&&!d&&!n,t=m.useCallback(s=>()=>{l(E(g.storageConnector.edit,g.project.value,{connectorName:s,id:c,fsId:i}))},[l,c,i]),p=m.useMemo(()=>new Array(r.length).fill(null).map(()=>[y,M,y,P]),[r]),j=m.useMemo(()=>r.map(({name:s,storageConnectorType:b,description:u})=>[{children:s,bold:!0},{value:b,variant:"default",width:"max-content"},{children:u,gray:!0,bold:!0},{mr:"10px",mainText:o?"Edit":n?"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:o?"pointer":"",backgroundColor:"inherit",transition:"all .4s ease",":hover":{svg:{path:{fill:"primary"}}}},disabled:!o,onClick:o?t(s):void 0,"data-test":`edit-${s}`,children:e.jsx(Y,{color:o?"black":"gray",icon:Z.edit})})}]),[r,t,n,o]);return e.jsx(S,{sx:_,children:e.jsx(D,{middleColumn:2,groupComponents:p,groupProps:j})})},de=()=>{G(V.storageConnectors);const r=w(),{id:l,fsId:c}=k(),[i,f]=m.useState(""),{canEdit:n,isDataScientist:d,isLoading:o}=F(),{data:t,isFetching:p,isLoading:j}=q({pId:+l,fsId:+c}),s=H(x=>x.name.toLowerCase().includes(i.toLocaleLowerCase())||x.description.toLowerCase().includes(i.toLocaleLowerCase()))((t==null?void 0:t.items)??[]),{selectFSValue:b,selectFSOptions:u,handleFSSelectionChange:I,isLoading:N,isSharedLoading:T}=K(),C=()=>{r(E(g.storageConnector.create,g.project.value,{id:l,fsId:c}))};return N||T?e.jsx(v,{}):!j&&!t?e.jsx(Q,{}):e.jsxs(a,{flexDirection:"column",mt:"-20px",children:[e.jsxs(a,{sx:z.stickyHeader,pt:"20px",children:[e.jsxs(a,{alignItems:"center",gap:"10px",children:[e.jsx(A,{labelProps:{flexGrow:1},variant:"white",value:i,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(B,{variant:"white",width:"auto",label:"feature store",labelPosition:"inline",value:b,options:u,onChange:I}),e.jsx(P,{mainText:d?"Your role is not allowed to perform this action":"You have no edit right on the feature store",disabled:n&&!d&&!o,children:e.jsx(L,{onClick:C,disabled:!n||d||o,children:"New storage connector"})})]})]}),e.jsx(R,{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:(t==null?void 0:t.count)??0}),e.jsxs(h,{children:["storage"," ",W("connector",(t==null?void 0:t.count)??0)," ","displayed"]})]})]}),p&&e.jsx(v,{}),!p&&U(t)&&e.jsx(a,{my:"20px",justifyContent:"center",children:e.jsx(O,{mainText:"No storage connector setup up",children:e.jsx(L,{intent:"secondary",onClick:C,children:"Set up a storage connector"})})}),e.jsx(a,{flexDirection:"column",mt:"20px",mb:"40px",bg:"white",children:e.jsx($,{data:s})})]})};export{de as default};
