"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/DatabasesPage/AddDatabase"],{1021:(e,s,a)=>{a.r(s),a.d(s,{default:()=>l});var r=a(270),n=a(592),t=a(271);const l=({onClose:e,isOpen:s=!0,closeOnFormSuccess:a=!0,closeUrl:l="..",form:o,...c})=>{const u=(0,n.useNavigate)(),[d,i]=(0,r.useState)(s),m=(0,r.useRef)(null),p=(0,r.useCallback)(((...s)=>{const a=e??(()=>u(l,{preventScrollReset:!0}));i(!1),m.current=setTimeout((()=>{a(...s),m.current=null}),300)}),[l,u,e]);(0,r.useEffect)((()=>()=>{m.current&&clearTimeout(m.current)}),[]),(0,r.useEffect)((()=>{s?m.current&&clearTimeout(m.current):i(s)}),[s]);const x=(0,r.useMemo)((()=>{if(o&&a){if((0,r.isValidElement)(o))return(0,r.cloneElement)(o,{onSuccess:(...e)=>{o.props.onSuccess?.(...e),p()}});if("object"==typeof o)return{...o,onSuccess:(...e)=>{o.onSuccess?.(...e),p()}}}return o}),[a,p,o]);return(0,r.jsx)(t.Drawer,{...c,form:x,onClose:p,isOpen:d})}},2412:(e,s,a)=>{a.r(s),a.d(s,{default:()=>m});var r=a(1021),n=a(89),t=a(902),l=a(592),o=a(270),c=a(271),u=a(548);const d=n.Locale.getTranslate("components.pages.Databases.Add"),i=n.Locale.getSection("components.pages.Databases.Add"),m=({data:e})=>{const s=(0,l.useRevalidator)(),a=(0,l.useParams)(),[n,m]=(0,o.useState)((()=>({general:{name:e.name,dbServer:e.defaultDbServerId,domainId:""},user:{createUser:"1",password:void 0,allDbAccess:"0",aclRadio:"any"},forceSkipRedirect:!0}))),p=(0,o.useMemo)((()=>Object.entries(e.servers).map((([e,s])=>({id:Number(e),name:s})))),[e.servers]),x=(0,o.useMemo)((()=>e.aclSupportedServers.includes(n.general.dbServer)),[e.aclSupportedServers,n.general.dbServer]);return(0,o.jsx)(r.default,{size:"sm",title:(0,o.jsx)(d,{content:"title"}),form:(0,o.jsxs)(t.default,{action:`/smb/database/create/domainId/${a.domainId}`,values:n,applyButton:!1,submitButton:{children:(0,o.jsx)(d,{content:"create"})},onSubmit:e=>("1"===e.user.createUser&&(e.user.passwordConfirmation=e.user.password),e),onSuccess:({name:e})=>{(0,u.addToast)({intent:"success",message:(0,o.jsx)(d,{content:"databaseCreated",params:{name:e}})}),s.revalidate()},onFieldChange:(e,s)=>{m((a=>(0,c.setIn)(a,e,s)))},children:[(0,o.jsx)(c.FormFieldText,{required:!0,name:"general[name]",label:(0,o.jsx)(d,{content:"name"})}),(0,o.jsx)(c.FormFieldSelect,{name:"general[dbServer]",label:(0,o.jsx)(d,{content:"server"}),children:p.map((({id:e,name:s})=>(0,o.jsx)("option",{value:e,children:s},e)))}),(0,o.jsxs)(c.FormFieldSelect,{name:"general[domainId]",label:(0,o.jsx)(d,{content:"relatedDomain"}),children:[(0,o.jsx)("option",{value:"",children:i.lmsg("noDomainRelations")}),e.relatedDomains.map((({id:e,name:s})=>(0,o.jsx)("option",{value:e,children:s},e)))]}),(0,o.jsx)(c.FormFieldCheckbox,{checkedValue:"1",uncheckedValue:"0",name:"user[createUser]",label:(0,o.jsx)(d,{content:"createUser"})}),"1"===n.user.createUser&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.Paragraph,{children:(0,o.jsx)(d,{content:"userSectionDescription"})}),(0,o.jsx)(c.FormFieldText,{name:"user[name]",required:"1"===n.user.createUser,label:(0,o.jsx)(d,{content:"username"})}),(0,o.jsx)(c.FormFieldPassword,{name:"user[password]",autoComplete:"new-password",label:(0,o.jsx)(d,{content:"password"}),required:"1"===n.user.createUser}),(0,o.jsx)(c.FormFieldCheckbox,{checkedValue:"1",uncheckedValue:"0",name:"user[allDbAccess]",label:(0,o.jsx)(d,{content:"allDbAccess"})}),x&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.FormFieldRadioButtons,{name:"user[aclRadio]",label:(0,o.jsx)(d,{content:"aclRadio"}),options:[{value:"localhost",label:i.lmsg("aclLocalhost")},{value:"any",label:i.lmsg("aclAny")},{value:"custom",label:i.lmsg("aclCustom")}]}),"custom"===n.user.aclRadio&&(0,o.jsx)(c.FormFieldText,{multiline:!0,name:"user[aclHosts]",description:(0,o.jsx)(d,{content:"example",params:{example:(0,o.jsx)(d,{content:"aclExample"})}})})]})]})]})})}}}]);
//# sourceMappingURL=AddDatabase.js.map?bea70db7ab0694a7d1cd