"use strict";(globalThis.webpackChunkPlesk=globalThis.webpackChunkPlesk||[]).push([["views/smb/smarthost/edit"],{1961(e,t,s){s.r(t),s.d(t,{default:()=>c});var n=s(90),i=s(373),a=s(757),o=s.n(a),r=s(372);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},1663(e,t,s){s.r(t),s.d(t,{default:()=>c});var n=s(757),i=s.n(n),a=s(373),o=s(90),r=s(802),d=s(372);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},1958(e,t,s){s.r(t),s.d(t,{default:()=>d});var n=s(1663),i=s(771),a=s(1959),o=s(372);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)},1959(e,t,s){s.r(t),s.d(t,{default:()=>f});var n=s(372),i=s(688),a=s(757),o=s.n(a),r=s(780),d=s(671),l=s(373),c=s(90),u=s(634),p=s(1397),m=s(802),g=s(1960),h=s(1961);const b=d.gql`
    mutation UpdateDomainSmarthost($input: UpdateDomainSmarthostInput!) {
        updateDomainSmarthost(input: $input) {
            success
            message
        }
    }
`,x=c.Locale.getTranslate("smb.components.forms.smarthost"),j=({initialValues:e,encryptionOptions:t,domainName:s,isWindows:a,returnUrl:o})=>{const d=(0,i.useNavigate)(),[j,f]=(0,n.useState)(e),[R,q]=(0,n.useState)({}),[y,{loading:w}]=(0,r.useMutation)(b);(0,n.useEffect)(()=>{f(e)},[e]);return(0,n.jsxs)(p.default,{id:"smarthost-form",mutation:y,values:j,errors:R,onFieldChange:(e,t)=>f((0,l.setIn)(j,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:m.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)(j,"configuration[isAuthenticationRequired]"),onDryRun:async()=>{try{q({});const e=await y({variables:{input:{...j,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)(j,"settings[enabled]")})]})};j.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 f=j},1960(e,t,s){s.r(t),s.d(t,{default:()=>c});var n=s(90),i=s(373),a=s(757),o=s.n(a),r=s(372);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"})})}})}),(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},1957(e,t,s){s.r(t),s.d(t,{default:()=>n.default});var n=s(1958)}}]);
//# sourceMappingURL=edit.js.map?f70e19a559780753d3c1