import{bx as I,u as P,r as j,t as k,x as b,c as S,b9 as N,an as F,bn as v,j as e,F as L,ao as H,v as R,bV as G,bG as M,bH as Y,dS as q,L as w,cE as z,q as p,h7 as D,aH as Q,aJ as E,bS as $,d as f,by as A,h as J,c5 as K}from"./index-DHiyXWqE.js";import{a as O,u as U}from"./index-DRFB149W.js";import{u as T}from"./useUserPermissions-BpHid_5k.js";const V={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"}}}}},Z=({data:r})=>{const a=I(),{id:n,fsId:i}=P(),{canEdit:C,isDataScientist:c,isFeatureStoreRestricted:o,isLoading:u}=T(),x=C&&!u&&!c&&!o,t=j.useCallback(s=>()=>{a(k(b.project.storageConnector.edit,b.project.value,{connectorName:s,id:n,fsId:i}))},[a,n,i]),m=j.useMemo(()=>new Array(r.length).fill(null).map(()=>[S,N,S,F]),[r]),g=j.useMemo(()=>r.map(({name:s,storageConnectorType:d,description:l})=>{const h=x&&d!==v.opensearch,y=d===v.opensearch?"OpenSearch connectors cannot be edited":void 0;return[{children:s,bold:!0},{value:d,variant:"default",width:"max-content"},{children:l,gray:!0,bold:!0},{mr:"10px",mainText:h?"Edit":c||o?"Your role is not allowed to perform this action":"You have no edit right on the feature store",...y?{mainText:y}:{},children:e.jsx(L,{p:"5px",height:"28px",sx:{cursor:h?"pointer":"",backgroundColor:"inherit",transition:"all .4s ease",":hover":{svg:{path:{fill:"primary"}}}},disabled:!h,onClick:h?t(s):void 0,"data-test":`edit-${s}`,children:e.jsx(H,{color:h?"black":"gray",icon:R.edit})})}]}),[r,t,c,o,x]);return e.jsx(L,{sx:V,children:e.jsx(G,{middleColumn:2,groupComponents:m,groupProps:g})})},_=()=>{M(Y.storageConnectors);const r=I(),{id:a,fsId:n}=P();O({pId:+a,fsId:+n});const[i,C]=j.useState(""),{canEdit:c,isDataScientist:o,isFeatureStoreRestricted:u,isLoading:x}=T(),{data:t,isFetching:m,isLoading:g}=U({pId:+a,fsId:+n}),s=q(l=>l.name.toLowerCase().includes(i.toLocaleLowerCase())||l.description.toLowerCase().includes(i.toLocaleLowerCase()))((t==null?void 0:t.items)??[]),d=()=>{r(k(b.project.storageConnector.create,b.project.value,{id:a,fsId:n}))};return g?e.jsx(w,{}):!g&&!t?e.jsx(z,{}):e.jsxs(p,{flexDirection:"column",mt:"-20px",children:[e.jsxs(p,{sx:D.stickyHeader,pt:"20px",children:[e.jsxs(p,{alignItems:"center",gap:"10px",children:[e.jsx(Q,{labelProps:{flexGrow:1},variant:"white",value:i,placeholder:"Find a Storage Connector by name or description...",onChange:l=>C(l.target.value),autoFocus:!0}),t&&e.jsx(F,{mainText:o||u?"Your role is not allowed to perform this action":"You have no edit right on the feature store",disabled:c&&!o&&!u&&!x,children:e.jsx(E,{onClick:d,disabled:!c||o||u||x,children:"New data source"})})]}),e.jsx($,{mt:"10px",mb:"20px",ml:"0px",width:"100%",sx:{backgroundColor:"grayShade2",height:"3px"}}),e.jsxs(p,{mb:"15px",children:[e.jsx(f,{primary:!0,px:"5px",children:s.length}),e.jsx(f,{children:"out of"}),e.jsx(f,{primary:!0,px:"5px",children:(t==null?void 0:t.count)??0}),e.jsxs(f,{children:["data ",A("source",(t==null?void 0:t.count)??0)," ","displayed"]})]})]}),m&&e.jsx(w,{}),!m&&J(t)&&e.jsx(p,{my:"20px",justifyContent:"center",children:e.jsx(K,{mainText:"No storage connector setup up",children:e.jsx(E,{intent:"secondary",onClick:d,children:"Set up a data source"})})}),e.jsx(p,{flexDirection:"column",mt:"20px",mb:"40px",bg:"white",children:e.jsx(Z,{data:s})})]})};export{_ as default};
