"use strict";(globalThis.webpackChunkPlesk=globalThis.webpackChunkPlesk||[]).push([["views/smb/smarthost/edit"],{1575(e,t,s){s.r(t),s.d(t,{default:()=>c});var n=s(669),i=s.n(n),a=s(297),o=s(90),r=s(714),d=s(296);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},1866(e,t,s){s.r(t),s.d(t,{default:()=>n.default});var n=s(1867)},1867(e,t,s){s.r(t),s.d(t,{default:()=>d});var n=s(1575),i=s(683),a=s(1868),o=s(296);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)},1868(e,t,s){s.r(t),s.d(t,{default:()=>j});var n=s(296),i=s(600),a=s(669),o=s.n(a),r=s(692),d=s(583),l=s(297),c=s(90),u=s(546),p=s(1308),m=s(714),g=s(1869),h=s(1870);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)(p.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: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)(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},1869(e,t,s){s.r(t),s.d(t,{default:()=>c});var n=s(90),i=s(297),a=s(669),o=s.n(a),r=s(296);const d=n.Locale.getTranslate("smb.components.forms.smarthost.settings"),l=({disabled:e})=>(0,r.jsx)(i.Section,{title:(0,r.jsx)(d,{content:"title"}),children:(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},1870(e,t,s){s.r(t),s.d(t,{default:()=>c});var n=s(90),i=s(297),a=s(669),o=s.n(a),r=s(296);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}}]);
//# sourceMappingURL=edit.js.map?0642cbd989665f126698