"use strict";(globalThis.webpackChunkPlesk=globalThis.webpackChunkPlesk||[]).push([["views/smb/smarthost/edit"],{1973(e,t,s){s.r(t),s.d(t,{default:()=>c});var n=s(95),i=s(379),a=s(763),o=s.n(a),r=s(378);const d=n.Locale.getTranslate("admin.components.forms.server-mail-smarthost.configuration"),l=({encryptionOptions:e,isWindows:t,isAuthenticationRequired:s,onDryRun:n,disabled:a})=>{const o=t?"Windows":"Unix",[l,c]=(0,r.useState)(!1),u=async()=>{c(!0),await n(),c(!1)};return(0,r.jsxs)(i.Section,{title:(0,r.jsx)(d,{content:"title"}),children:[(0,r.jsx)(i.FormField,{name:"configuration[host]",label:(0,r.jsx)(d,{content:"hostnameOrIP"}),required:!0,description:t?"":(0,r.jsx)(d,{content:"hostnameOrIP.unixHint"}),children:({getValue:e,setValue:t,getName:s})=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Input,{name:s(),id:"configuration-host",size:45,value:e(),onChange:e=>t(e.target.value),disabled:a}),"  ",(0,r.jsx)(i.Button,{size:"md",state:l?"loading":null,id:"checkConnection",onClick:u,disabled:a,children:(0,r.jsx)(d,{content:"checkConnection"})})]})}),(0,r.jsx)(i.FormFieldText,{name:"configuration[port]",label:(0,r.jsx)(d,{content:"port"}),inputProps:{size:5},required:!0,disabled:a}),(0,r.jsx)(i.FormFieldCheckbox,{name:"configuration[isAuthenticationRequired]",label:(0,r.jsx)(d,{content:"authRequired"}),disabled:a}),(0,r.jsxs)(i.Section,{collapsible:!0,children:[(0,r.jsx)(i.FormFieldText,{name:"configuration[username]",label:(0,r.jsx)(d,{content:"username"}),size:"md",disabled:!s||a}),(0,r.jsx)(i.FormFieldPassword,{name:"configuration[password]",label:(0,r.jsx)(d,{content:"password"}),size:"md",hideGenerateButton:!0,hidePasswordMeter:!0,disabled:!s||a})]}),e.length>0&&(0,r.jsx)(i.FormFieldRadioButtons,{name:"configuration[encryption]",label:(0,r.jsx)(d,{content:"encryption"}),options:e.map(e=>({value:e,label:(0,r.jsx)(d,{content:`encryption.${o}.${e}`})})),disabled:a})]})};l.propTypes={encryptionOptions:o().array.isRequired,isWindows:o().bool.isRequired,isAuthenticationRequired:o().bool.isRequired,onDryRun:o().func.isRequired,disabled:o().bool.isRequired};const c=l},1672(e,t,s){s.r(t),s.d(t,{default:()=>c});var n=s(763),i=s.n(n),a=s(379),o=s(95),r=s(808),d=s(378);const l=({items:e})=>e&&e.length>1?(0,d.jsx)(a.Tabs,{active:e.findIndex(({containerCls:e})=>"active"===e)+1,children:e.map(({title:e,href:t},s)=>(0,d.jsx)(a.Tab,{title:e,component:r.default,to:(0,o.prepareUrl)(t)},s))}):null;l.propTypes={items:i().arrayOf(i().shape({title:i().string.isRequired,href:i().string.isRequired,containerCls:i().string}))};const c=l},1970(e,t,s){s.r(t),s.d(t,{default:()=>d});var n=s(1672),i=s(777),a=s(1971),o=s(378);const r=({tabs:e=[],...t})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.default,{items:e}),(0,o.jsx)(a.default,{...t})]});r.propTypes={tabs:n.default.propTypes.items};const d=(0,i.withPageLayout)(r)},1971(e,t,s){s.r(t),s.d(t,{default:()=>j});var n=s(378),i=s(694),a=s(763),o=s.n(a),r=s(786),d=s(677),l=s(379),c=s(95),u=s(640),m=s(1403),p=s(808),g=s(1972),h=s(1973);const b=d.gql`
    mutation UpdateDomainSmarthost($input: UpdateDomainSmarthostInput!) {
        updateDomainSmarthost(input: $input) {
            success
            message
        }
    }
`,x=c.Locale.getTranslate("smb.components.forms.smarthost"),f=({initialValues:e,encryptionOptions:t,domainName:s,isWindows:a,returnUrl:o})=>{const d=(0,i.useNavigate)(),[f,j]=(0,n.useState)(e),[R,q]=(0,n.useState)({}),[y,{loading:w}]=(0,r.useMutation)(b);(0,n.useEffect)(()=>{j(e)},[e]);return(0,n.jsxs)(m.default,{id:"smarthost-form",mutation:y,values:f,errors:R,onFieldChange:(e,t)=>j((0,l.setIn)(f,e,t)),onSuccess:(e,t)=>{(0,u.addToast)({intent:"success",message:(0,n.jsx)(x,{content:"success",params:{domain:s}})}),t?d(window.location.pathname,{replace:!0}):d((0,c.prepareUrl)(o))},applyButton:{id:"btn-apply"},cancelButton:{id:"btn-cancel",component:p.default,to:(0,c.prepareUrl)(o)},submitButton:{id:"btn-send"},children:[(0,n.jsx)(g.default,{disabled:w}),(0,n.jsx)(h.default,{encryptionOptions:t,isWindows:a,isAuthenticationRequired:(0,l.getIn)(f,"configuration[isAuthenticationRequired]"),onDryRun:async()=>{try{q({});const e=await y({variables:{input:{...f,checkConnection:!0}}}),{data:{updateDomainSmarthost:{success:t,message:s}}}=e;(0,u.addToast)({intent:t?"success":"danger",message:t?(0,n.jsx)(x,{content:"configuration.checkConnection.success"}):s})}catch(e){const t=e?.graphQLErrors||[];if("validate"===t[0]?.extensions?.category)q(t[0].extensions.messages);else{const s=t[0]?.extensions?.debugMessage||t[0]?.message||e.message;(0,u.addToast)({intent:"danger",message:s})}}},disabled:w||!(0,l.getIn)(f,"settings[enabled]")})]})};f.propTypes={initialValues:o().shape({settings:o().shape({enabled:o().bool.isRequired}).isRequired,configuration:o().shape({host:o().string.isRequired,port:o().number.isRequired,isAuthenticationRequired:o().bool.isRequired,username:o().string.isRequired,password:o().string.isRequired,encryption:o().string}).isRequired}).isRequired,encryptionOptions:o().array.isRequired,domainName:o().string.isRequired,isWindows:o().bool.isRequired,returnUrl:o().string.isRequired};const j=f},1972(e,t,s){s.r(t),s.d(t,{default:()=>c});var n=s(95),i=s(379),a=s(763),o=s.n(a),r=s(378);const d=n.Locale.getTranslate("smb.components.forms.smarthost.settings"),l=({disabled:e})=>(0,r.jsxs)(i.Section,{title:(0,r.jsx)(d,{content:"title"}),children:[(0,r.jsx)(i.StatusMessage,{intent:"warning",children:(0,r.jsx)(d,{content:"note",params:{title:(0,r.jsx)("b",{children:(0,r.jsx)(d,{content:"noteTitle"})}),link:(0,r.jsx)("a",{href:"https://docs.plesk.com/en-US/obsidian/customer-guide/mail-settings/configuring-a-smarthost-or-relayhost-for-a-domain.73390",target:"_blank",rel:"noopener noreferrer",children:(0,r.jsx)(d,{content:"noteLinkTitle"})})}})}),(0,r.jsx)(i.FormFieldCheckbox,{label:(0,r.jsx)(d,{content:"useSmarthost"}),name:"settings[enabled]",disabled:e})]});l.propTypes={disabled:o().bool.isRequired};const c=l},1969(e,t,s){s.r(t),s.d(t,{default:()=>n.default});var n=s(1970)}}]);
//# sourceMappingURL=edit.js.map?3306a9b22619d62ff602