"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/DatabasesPage/MoveToSubscription"],{1023:(e,s,t)=>{t.r(s),t.d(s,{default:()=>o});var a=t(285),n=t(583),r=t(286);const o=({onClose:e,isOpen:s=!0,closeOnFormSuccess:t=!0,closeUrl:o="..",form:c,...i})=>{const u=(0,n.useNavigate)(),[l,d]=(0,a.useState)(s),m=(0,a.useRef)(null),p=(0,a.useCallback)(((...s)=>{const t=e??(()=>u(o,{preventScrollReset:!0}));d(!1),m.current=setTimeout((()=>{t(...s),m.current=null}),300)}),[o,u,e]);(0,a.useEffect)((()=>()=>{m.current&&clearTimeout(m.current)}),[]),(0,a.useEffect)((()=>{s?m.current&&clearTimeout(m.current):d(s)}),[s]);const b=(0,a.useMemo)((()=>{if(c&&t){if((0,a.isValidElement)(c))return(0,a.cloneElement)(c,{onSuccess:(...e)=>{c.props.onSuccess?.(...e),p()}});if("object"==typeof c)return{...c,onSuccess:(...e)=>{c.onSuccess?.(...e),p()}}}return c}),[t,p,c]);return(0,a.jsx)(r.Drawer,{...i,form:b,onClose:p,isOpen:l})}},2229:(e,s,t)=>{t.r(s),t.d(s,{default:()=>f});var a=t(285),n=t(583),r=t(589),o=t(286),c=t(1023),i=t(89),u=t(906),l=t(539),d=t(2230),m=t(726),p=t.n(m);const b=i.Locale.getTranslate("components.pages.Databases.MoveToSubscription"),f=()=>{const{reloadDatabaseList:e}=(0,n.useOutletContext)(),s=(0,n.useParams)(),[t,i]=(0,a.useState)({domainName:"",ids:[Number(s.databaseId)],forceSkipRedirect:!0}),{data:m}=(0,r.useQuery)(p(),{variables:{databaseId:btoa(`Database:${s.databaseId}`)}});if(!m)return;const f=m.viewer.client?.subscriptions.nodes;(0,d.assertNodeTypename)(m.database,"Database");const h=m.database.name;return(0,a.jsx)(c.default,{size:"sm",title:(0,a.jsx)(b,{content:"title"}),subtitle:(0,a.jsx)(b,{content:"description",params:{name:(0,a.jsx)("b",{children:h})}}),form:(0,a.jsxs)(u.default,{action:"/smb/database/assign-to-subscription",onFieldChange:(e,s)=>{i((t=>(0,o.setIn)(t,e,s)))},values:t,applyButton:!1,onSuccess:({message:s})=>{(0,l.addToast)({intent:"success",message:s}),e?.()},submitButton:{children:(0,a.jsx)(b,{content:"save"}),"data-action-name":"submit"},children:[(0,a.jsx)(o.Paragraph,{children:(0,a.jsx)(b,{content:"hint"})}),(0,a.jsx)(o.FormFieldSelect,{"data-action-name":"assignToSubscriptionSelect",size:"fill",name:"domainName",label:(0,a.jsx)(b,{content:"subscriptionName"}),searchable:!0,required:!0,children:f?.map((({mainDomain:{name:e}})=>(0,a.jsx)("option",{value:e,children:e},e)))})]})})}},2230:(e,s,t)=>{function a(e,s){if(e.__typename!==s)throw new Error(`GraphQL type assertion failed: expected ${s} but received ${e.__typename}`)}t.r(s),t.d(s,{assertNodeTypename:()=>a})}}]);
//# sourceMappingURL=MoveToSubscription.js.map?398ec445dbb4f3672c4c