https://molly88.net/cp/javascript/components/pages/DatabasesPage/AddDatabase.js?090a2b94fb2f8b3ceb45
1"use strict";(globalThis.webpackChunkPlesk||=[]).push([["components/pages/DatabasesPage/AddDatabase"],{1604(e,s,a){a.r(s),a.d(s,{default:()=>n});var t=a(341),l=a(772),r=a(342);const n=({onClose:e,isOpen:s=!0,closeOnFormSuccess:a=!0,closeUrl:n="..",form:o,...c})=>{const d=(0,l.useNavigate)(),[i,u]=(0,t.useState)(s),m=(0,t.useRef)(null),p=(0,t.useCallback)((...s)=>{const a=e??(()=>d(n,{preventScrollReset:!0}));u(!1),m.current=setTimeout(()=>{a(...s),m.current=null},300)},[n,d,e]);(0,t.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]),(0,t.useEffect)(()=>{s?m.current&&clearTimeout(m.current):u(s)},[s]);const x=(0,t.useMemo)(()=>{if(o&&a){if((0,t.isValidElement)(o))return(0,t.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,t.jsx)(r.Drawer,{...c,form:x,onClose:p,isOpen:i})}},2900(e,s,a){a.r(s),a.d(s,{default:()=>l});a(2901);var t=a(341);const l=({prefix:e,children:s})=>(0,t.jsxs)("div",{className:"prefixed-form-element",children:[e&&(0,t.jsx)("span",{className:"prefixed-form-element-prefix",children:e}),s]})},2899(e,s,a){a.r(s),a.d(s,{default:()=>t.default});var t=a(2900)},2898(e,s,a){a.r(s),a.d(s,{default:()=>p});var t=a(1604),l=a(95),r=a(798),n=a(772),o=a(341),c=a(342),d=a(2899),i=a(718);const u=l.Locale.getTranslate("components.pages.Databases.Add"),m=l.Locale.getSection("components.pages.Databases.Add"),p=({data:e})=>{const{reloadDatabaseList:s}=(0,n.useOutletContext)(),a=(0,n.useParams)(),[l,p]=(0,o.useState)(()=>({general:{name:e.name,dbServer:e.defaultDbServerId,domainId:""},user:{name:"",createUser:"1",password:void 0,allDbAccess:"false",aclRadio:e.aclRadio,aclHosts:e.aclHosts,remoteAccessRadio:"denied"}})),x=(0,o.useMemo)(()=>Object.entries(e.servers).map(([e,s])=>({id:Number(e),name:s})),[e.servers]),b=e.permissions.remoteDbConnection,j=e.aclSupportedServers.includes(l.general.dbServer),v=e.remoteAccessRulesSupportedServers.includes(l.general.dbServer),g=b&&j,h=b&&e.isFirewallSupported&&v,f=h&&j,F=h&&!j,S=e.userNamePrefixes[l.general.dbServer]??"";return(0,o.jsx)(t.default,{size:"sm",title:(0,o.jsx)(u,{content:"title"}),form:(0,o.jsxs)(r.default,{action:`/smb/database/create/domainId/${a.domainId}`,values:l,applyButton:!1,submitButton:{children:(0,o.jsx)(u,{content:"create"}),"data-action-name":"submit"},onSubmit:e=>{"1"===e.user.createUser&&(e.user.passwordConfirmation=e.user.password);const s=g?e.user.aclRadio:void 0,a="custom"===s?e.user.aclHosts:void 0,t=F?e.user.remoteAccessRadio:void 0,l="allowed"===t?e.user.remoteAccessAllowed:void 0;return{...e,user:{...e.user,aclRadio:s,aclHosts:a,remoteAccessRadio:t,remoteAccessAllowed:l}}},onSuccess:({name:e})=>{(0,i.addToast)({intent:"success",message:(0,o.jsx)(u,{content:"databaseCreated",params:{name:e}})}),s?.()},onFieldChange:(e,s)=>{p(a=>(0,c.setIn)(a,e,s))},children:[(0,o.jsx)(c.FormField,{required:!0,name:"general[name]",label:(0,o.jsx)(u,{content:"name"}),children:({getValue:s,setValue:a,getName:t,getId:l,isDisabled:r})=>(0,o.jsx)(d.default,{prefix:e.dbPrefix,children:(0,o.jsx)(c.Input,{id:l(),name:t(),value:s(),disabled:r(),onChange:e=>a(e.target.value)})})}),x.length>1?(0,o.jsx)(c.FormFieldSelect,{name:"general[dbServer]",label:(0,o.jsx)(u,{content:"server"}),"data-testid":"dbserver-select",children:x.map(({id:e,name:s})=>(0,o.jsx)("option",{value:e,children:s},e))}):(0,o.jsx)(c.FormField,{"data-testid":"dbserver-text",label:(0,o.jsx)(u,{content:"server"}),children:x[0]?.name}),(0,o.jsxs)(c.FormFieldSelect,{name:"general[domainId]",label:(0,o.jsx)(u,{content:"relatedDomain"}),children:[(0,o.jsx)("option",{value:"",children:m.lmsg("noDomainRelations")}),e.relatedDomains.map(({id:e,name:s})=>(0,o.jsx)("option",{value:e,children:s},e))]}),(0,o.jsxs)(c.Section,{title:(0,o.jsx)(u,{content:"userSection"}),children:[(0,o.jsx)(c.Paragraph,{children:(0,o.jsx)(u,{content:"userSectionDescription"})}),(0,o.jsx)(c.FormFieldCheckbox,{checkedValue:"1",uncheckedValue:"0",name:"user[createUser]",label:(0,o.jsx)(u,{content:"createUser"})}),"1"===l.user.createUser&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(c.FormField,{name:"user[name]",label:(0,o.jsx)(u,{content:"username"}),required:!0,children:({getValue:e,setValue:s,getName:a,getId:t,isDisabled:l})=>(0,o.jsx)(d.default,{prefix:S,children:(0,o.jsx)(c.Input,{id:t(),name:a(),value:e(),disabled:l(),onChange:e=>s(e.target.value)})})}),(0,o.jsx)(c.FormFieldPassword,{name:"user[password]",autoComplete:"new-password",label:(0,o.jsx)(u,{content:"password"}),required:!0}),(0,o.jsx)(c.FormFieldCheckbox,{checkedValue:"true",uncheckedValue:"false",name:"user[allDbAccess]",label:(0,o.jsx)(u,{content:"allDbAccess"})}),g&&(0,o.jsx)(c.FormFieldRadioButtons,{name:"user[aclRadio]",label:(0,o.jsx)(u,{content:"aclRadio"}),options:[{value:"localhost",label:m.lmsg("aclLocalhost")},{value:"any",label:m.lmsg("aclAny")},{value:"custom",label:m.lmsg("aclCustom"),indentFields:"custom"===l.user.aclRadio?[(0,o.jsx)(c.FormFieldText,{label:null,multiline:!0,name:"user[aclHosts]",size:"lg",inputProps:{"aria-label":m.lmsg("aclHostsLabel")},description:(0,o.jsx)(u,{component:"div",style:{whiteSpace:"pre-line"},content:"example",params:{example:(0,o.jsx)(u,{content:"aclExample"})}})},"aclHosts")]:void 0}]}),f&&(0,o.jsx)(c.Paragraph,{children:(0,o.jsx)(u,{content:"remoteAccessHint"})}),F&&(0,o.jsx)(c.FormFieldRadioButtons,{name:"user[remoteAccessRadio]",label:(0,o.jsx)(u,{content:"remoteAccess"}),options:[{value:"denied",label:m.lmsg("remoteAccessDenied")},{value:"allowed",label:m.lmsg("remoteAccessAllowed"),indentFields:"allowed"===l.user.remoteAccessRadio?[(0,o.jsx)(c.FormFieldText,{label:null,multiline:!0,name:"user[remoteAccessAllowed]",size:"lg",description:(0,o.jsx)(u,{component:"div",style:{whiteSpace:"pre-line"},content:"example",params:{example:(0,o.jsx)(u,{content:"remoteAccessExample"})}})},"remoteAccessAllowed")]:void 0}]})]})]})]})})}},2901(e,s,a){a.r(s)}}]); 2//# sourceMappingURL=AddDatabase.js.map?090a2b94fb2f8b3ceb45
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.