import{u as y,ba as I,w as T,r,x as E,p as P,kj as w,bD as v,kk as F,kF as N,bG as B,bH as M,j as o,L as O,cE as $,bJ as z}from"./index-DNBEEyYo.js";import{d as G,e as H,f as J}from"./index-XpLJ3bKZ.js";import{D as Q}from"./DataSourceCreate-DJ6191Al.js";import"./useScreenWithScroll-zcr7TMGO.js";import"./form-nDhxPMre.js";import"./flip-CO85ug7l.js";import"./index-bIvQJs1X.js";import"./sum-elEvBIoZ.js";import"./countBy-CjWkC9gm.js";import"./FeaturesForm-CzZWLvJz.js";import"./TagsForm-BXATGMc8.js";import"./useUpdateTdOrFvInfoService-CZYcDMMa.js";import"./index-Burx7Ja_.js";import"./randomArrayString---X8tfjV.js";import"./sort-BOLIcXtz.js";import"./index-DEeBzOsi.js";import"./Project-D_38ySn9.js";import"./alertManagerConfig.selectors-6Q6ry9ha.js";import"./defineProperty-9LKwahlh.js";import"./HumanizedCronExpression-Cc3xtXqn.js";import"./index-DivQJV92.js";import"./symmetricDifference-lQ_DaX5E.js";import"./git-BLdzamrJ.js";import"./useCopyToClipboard-BnywFRQi.js";import"./AlertForm-BOLtC7QE.js";const Ct=()=>{const{connectorName:a,id:i,fsId:e}=y(),d=I(),[f,n]=T(),[m,{error:h,isLoading:l}]=G(),[g,{isLoading:u}]=H(),{currentData:t,isUninitialized:j,isFetching:C}=J({pId:+i,fsId:+e,id:a}),D=r.useCallback(()=>{d(E.project.storageConnector.list,{fsId:e})},[e,d]),k=r.useCallback(async(p,c)=>{const{storageConnectorType:b}=p,S=P(v("type",F(b)),w(b))(p);await m({pId:+i,fsId:+e,id:a,data:S}).unwrap().then(R=>{c==null||c(p)})},[m,i,e,a]),x=r.useCallback(()=>g({pId:+i,fsId:+e,id:a}).unwrap().then(D),[g,i,e,a,D]),s=t==null?void 0:t.storageConnectorType,L=r.useMemo(()=>N(s)(t),[t,s]);return B(`${M.editStorageConnector} - ${t==null?void 0:t.name}`),C&&!t||j?o.jsx(O,{}):!t&&!C?o.jsx($,{}):o.jsxs(o.Fragment,{children:[o.jsx(Q,{error:h,isSaving:l||u,isDisabled:l,onSubmit:k,initialProtocol:s,initialData:L,onDelete:n,isEdit:!0}),o.jsx(z,{title:`Delete ${t==null?void 0:t.name}`,secondaryText:"Once you delete a storage connector, there is no going back. Please be certain.",isOpen:f,onClose:n,mainButtonProps:{children:"Delete",onClick:x,isLoading:u,"data-test":"delete-ds"},secondaryButtonProps:{children:"Back",onClick:n}})]})};export{Ct as default};
