"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/ConnectionInfo"],{1367:(e,s,t)=>{t.r(s),t.d(s,{default:()=>d});var n=t(247),a=t.n(n),o=t(246),i=t(245);const r=({error:e})=>400===e.networkError?.statusCode?null:(0,i.jsx)(o.StatusMessage,{intent:"danger",children:e.message});r.propTypes={error:a().shape({message:a().string.isRequired,networkError:a().shape({statusCode:a().number})}).isRequired};const d=r},993:(e,s,t)=>{t.r(s),t.d(s,{default:()=>l});var n=t(245),a=t(739),o=t(247),i=t.n(o),r=t(246);const d=({onClose:e,isOpen:s,closeOnFormSuccess:t,closeUrl:o,...i})=>{const d=(0,a.useNavigate)(),[l,c]=(0,n.useState)(s),u=(0,n.useRef)(null),m=(0,n.useCallback)(((...s)=>{const t=e??(()=>d(o,{preventScrollReset:!0}));c(!1),u.current=setTimeout((()=>{t(...s),u.current=null}),300)}),[o,d,e]);(0,n.useEffect)((()=>()=>clearTimeout(u.current)),[]),(0,n.useEffect)((()=>{s?u.current&&clearTimeout(u.current):c(s)}),[s]);const p=(0,n.useMemo)((()=>{const{form:e}=i;if(e&&t){if((0,n.isValidElement)(e))return(0,n.cloneElement)(e,{onSuccess:()=>{e.props.onSuccess?.(),m()}});if("object"==typeof e)return{...e,onSuccess:()=>{e.onSuccess?.(),m()}}}return e}),[t,m,i]);return(0,n.jsx)(r.Drawer,{...i,form:p,onClose:m,isOpen:l})};d.propTypes={onClose:i().func,isOpen:i().bool,form:i().oneOfType([i().object,i().node]),closeOnFormSuccess:i().bool,closeUrl:i().string},d.defaultProps={onClose:void 0,form:void 0,isOpen:!0,closeOnFormSuccess:!0,closeUrl:".."};const l=d},2085:(e,s,t)=>{t.r(s),t.d(s,{ConnectionInfo:()=>j,default:()=>x});var n=t(245),a=t(739),o=t(458),i=t(745),r=t(246),d=t(1367),l=t(959),c=t(993),u=t(90),m=t(2086),p=t(2089);const b=u.Locale.getTranslate("components.forms.domain.connection-info"),h=o.gql`
    fragment DatabaseFields on Database {
        id
        name
        server {
            type
            fork
            host
            port
        }
        defaultUser {
            id
            login
        }
        users {
            id
            login
        }
        isWebadminInstalled
    }
`,g=o.gql`
    ${h}
    query GetDomain($id: ID!) {
        domain: node(id: $id) {
            ... on Domain {
                id
                name(idn: false)
                sysUser {
                    login
                    isShellForbidden
                }
                ipAddresses {
                    publicIpAddress
                    ipAddress
                }
                databases {
                    ...DatabaseFields
                }
                applicationDatabases {
                    ...DatabaseFields
                }
                relatedDatabase {
                    ...DatabaseFields
                }
                baseDomain {
                    id
                    databases {
                        ...DatabaseFields
                    }
                }
                subscription {
                    isDatabasesAvailable
                    permissions {
                        manageWebsitesAndDomains
                        manageDatabases
                        manageFtpAccounts
                    }
                }
            }
        }
    }
`,j=()=>{const{id:e}=(0,a.useParams)(),[s,t]=(0,n.useState)(!0),[o,h]=(0,n.useState)([]),[j,x]=(0,n.useState)(null),[f,A]=(0,n.useState)(!1),F=()=>t(!1),{loading:D,data:y,error:C}=(0,i.useQuery)(g,{variables:{id:btoa(`Domain:${e}`)}});(0,n.useEffect)((()=>{A(!0),u.api.get(`/smb/web/connection-info/id/${e}`).then((e=>{let s=[];e.statusMessages&&(s=e.statusMessages.filter((({status:e})=>"error"===e)).map((({content:e})=>e))),h(s),e.embeddedForms&&x({id:e.id,embeddedForms:e.embeddedForms}),A(!1)})).catch((e=>{h([e.message]),A(!1)}))}),[e]);return(0,n.jsx)(c.default,{isOpen:s,title:(0,n.jsx)(b,{content:"title"}),subtitle:y?y.domain.name:null,size:"sm","data-type":"connection-info",children:(()=>{if(D||f)return(0,n.jsx)(r.ContentLoader,{});if(C)return(0,n.jsx)(d.default,{error:C});if(!y)return(0,n.jsx)(r.ContentLoader,{});const e=y.domain.baseDomain?y.domain.baseDomain:y.domain,s=Number(atob(e.id).split(":")[1]),{databases:t}=e;let a=y.domain.relatedDatabase;!a&&0<y.domain.applicationDatabases.length?a=y.domain.applicationDatabases[0]:!a&&0<t.length&&(a=t[0]);const{permissions:i,isDatabasesAvailable:c}=y.domain.subscription,u=i.manageDatabases&&c;return(0,n.jsxs)(n.Fragment,{children:[o.map((e=>(0,n.jsx)(r.StatusMessage,{intent:"danger",children:(0,n.jsx)("span",{dangerouslySetInnerHTML:{__html:e}})},btoa(e)))),y.domain.sysUser?(0,n.jsx)(p.default,{domain:y.domain,showFtpAccounts:i.manageFtpAccounts,showManageAccess:i.manageWebsitesAndDomains,isShellForbidden:y.domain.sysUser.isShellForbidden,onAction:F}):null,u?(0,n.jsx)(m.default,{baseDomainId:s,database:a,databases:t,onAction:F}):null,j&&0<j.embeddedForms.length?(0,n.jsx)(l.default,{vertical:!0,id:j.id,embeddedForms:j.embeddedForms,submitButton:!1,applyButton:!1,cancelButton:!1,render:({renderForm:e})=>e({actionButtons:null})}):null]})})()})},x=j},2087:(e,s,t)=>{t.r(s),t.d(s,{default:()=>c});var n=t(246),a=t(90),o=t(247),i=t.n(o),r=t(245);const d=a.Locale.getTranslate("components.forms.domain.connection-info"),l=({content:e})=>(0,r.jsx)(n.Button,{ghost:!0,icon:"copy",tooltip:(0,r.jsx)(d,{content:"copyToClipboard"}),onClick:()=>(0,n.copyToClipboard)(e),"data-action":"copy-to-clipboard"});l.propTypes={content:i().string.isRequired};const c=l},2086:(e,s,t)=>{t.r(s),t.d(s,{default:()=>p});var n=t(245),a=t(247),o=t.n(a),i=t(246),r=t(90),d=t(787),l=t(2087),c=t(2088);const u=r.Locale.getTranslate("components.forms.domain.connection-info"),m=({baseDomainId:e,database:s,databases:t,onAction:a})=>{const[o,r]=(0,n.useState)(!1);return(0,n.jsxs)("div",{"data-section":"database",children:[(0,n.jsx)(i.Section,{title:(0,n.jsx)(u,{content:"database"}),children:0===t.length?(0,n.jsx)(i.Hint,{children:(0,n.jsx)(u,{content:"databaseNotCreatedHint"})}):1<t.length?(0,n.jsx)(i.Hint,{children:(0,n.jsx)(u,{content:"databaseHint",params:{number:t.length}})}):null}),(0,n.jsxs)(i.Section,{children:[s?(()=>{const e=s.server.port?`${s.server.host}:${s.server.port}`:s.server.host,t=s.server.fork||s.server.type;let a=s.defaultUser;!a&&0<s.users.length&&(a=s.users[0]);const d=a?Number(atob(a.id).split(":")[1]):null;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(i.FormField,{label:(0,n.jsx)(u,{content:"databaseHost"}),"data-type":"host",children:[(0,n.jsx)(u,{content:"databaseHostValue",params:{value:e,fork:(0,n.jsx)(u,{content:`databaseType.${t.toLowerCase()}`})}}),(0,n.jsx)(l.default,{content:e})]}),(0,n.jsxs)(i.FormField,{label:(0,n.jsx)(u,{content:"databaseName"}),"data-type":"name",children:[s.name,(0,n.jsx)(l.default,{content:s.name})]}),a?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(i.FormField,{label:(0,n.jsx)(u,{content:"username"}),"data-type":"login",children:[a.login,(0,n.jsx)(l.default,{content:a.login})]}),(0,n.jsxs)(i.FormField,{label:(0,n.jsx)(u,{content:"password"}),"data-type":"password",children:["•".repeat(16),(0,n.jsx)(c.default,{title:(0,n.jsx)(u,{content:"changeDatabaseUserPasswordTitle"}),notice:(0,n.jsx)(u,{content:"changeDatabaseUserPasswordNotice"}),handlerUrl:`/smb/database/change-user-password/id/${d}`,target:(0,n.jsx)(i.Button,{ghost:!0,icon:"pencil",tooltip:(0,n.jsx)(u,{content:"changePasswordTooltip"}),onClick:()=>r(!0),"data-type":"edit-password-button"}),visible:o,onClose:()=>r(!1)})]})]}):null]})})():null,(0,n.jsx)(i.SectionItem,{children:(0,n.jsx)(i.Columns,{gap:"md",children:(()=>{const t=[];if(!s)return t.push((0,n.jsx)(i.Column,{children:(0,n.jsx)(i.Action,{href:`/smb/database/create/domainId/${e}`,icon:"database-plus",onClick:a,"data-action":"create-database",children:(0,n.jsx)(u,{content:"addDatabase"})})},"addDatabase")),t;if(s.isWebadminInstalled){const e=Number(atob(s.id).split(":")[1]);"MYSQL"===s.server.type&&t.push((0,n.jsx)(i.Column,{children:(0,n.jsx)(i.Action,{href:`/smb/database/webadmin/id/${e}`,target:"dbedit",icon:"phpmyadmin",onClick:a,"data-action":"open-php-my-admin",children:(0,n.jsx)(u,{content:"phpMyAdmin"})})},"MYSQL"))}return t.push((0,n.jsx)(i.Column,{children:(0,n.jsx)(i.Action,{component:d.default,to:`/smb/database/list/domainId/${e}`,icon:"database",onClick:a,"data-action":"manage-databases",children:(0,n.jsx)(u,{content:"manageDatabases"})})},"manageDatabases")),t})()})})]})]})};m.propTypes={baseDomainId:o().number.isRequired,database:o().object,databases:o().array,onAction:o().func},m.defaultProps={database:null,databases:[],onAction:()=>{}};const p=m},2088:(e,s,t)=>{t.r(s),t.d(s,{default:()=>u});var n=t(245),a=t(246),o=t(792),i=t(90),r=t(247),d=t.n(r);const l=i.Locale.getTranslate("components.forms.domain.connection-info"),c=({title:e,notice:s,handlerUrl:t,target:r,visible:d,onClose:c})=>{const[u,m]=(0,n.useState)(void 0),[p,b]=(0,n.useState)([]),[h,g]=(0,n.useState)({}),j=()=>{c(),b([]),g({})};return(0,n.jsx)(a.Popover,{title:e,target:r,placement:"top-right",visible:d,onClose:j,"data-type":"edit-password",children:(0,n.jsxs)(a.Form,{vertical:!0,applyButton:!1,submitButton:{id:"btn-send",children:(0,n.jsx)(l,{content:"submit"===u?"buttonSaving":"buttonSave"})},cancelButton:{id:"btn-cancel",children:(0,n.jsx)(l,{content:"buttonCancel"}),onClick:j},state:u,errors:h,onSubmit:async e=>{m("submit");const s=await i.api.post(t,(0,o.toFormData)(e));m(null);let n=[],a={};"success"===s.status?j():(s.statusMessages&&(n=s.statusMessages.filter((({status:e})=>"error"===e)).map((({content:e})=>e))),s.message&&(a={password:{message:s.message}})),b(n),g(a)},"data-type":"form",children:[p.map((e=>(0,n.jsx)(a.StatusMessage,{intent:"danger",children:(0,n.jsx)("span",{dangerouslySetInnerHTML:{__html:e}})},btoa(e)))),s?(0,n.jsx)(a.StatusMessage,{intent:"info",children:s}):null,(0,n.jsx)(a.FormFieldPassword,{name:"password",label:(0,n.jsx)(l,{content:"newPassword"}),required:!0,"data-type":"password"})]})})};c.propTypes={title:d().node.isRequired,notice:d().node,handlerUrl:d().string.isRequired,target:d().element.isRequired,onClose:d().func.isRequired,visible:d().bool},c.defaultProps={notice:null,visible:!1};const u=c},2089:(e,s,t)=>{t.r(s),t.d(s,{default:()=>j});var n=t(245),a=t(749),o=t(246),i=t(90),r=t(247),d=t.n(r),l=t(864),c=t(2068),u=t(2088),m=t(879),p=t(867),b=t(2087);const h=i.Locale.getTranslate("components.forms.domain.connection-info"),g=({domain:e,showFtpAccounts:s,showManageAccess:t,isShellForbidden:i,onAction:r})=>{const[d,g]=(0,n.useState)(!1),j=e.baseDomain?e.baseDomain:e,x=(0,p.getId)(j.id),f=(0,l.useGetDomainOverviewRoutePath)(),A=t?(0,n.jsx)(o.Link,{href:(0,m.getContextUrl)(x,"/smb/web/edit"),onClick:r,children:(0,n.jsx)(h,{content:"systemUserCredentialsHintDetails"})}):(0,n.jsx)(o.Popover,{target:(0,n.jsx)(o.Link,{children:(0,n.jsx)(h,{content:"systemUserCredentialsHintDetails"})}),placement:"bottom-left","data-type":"details",children:(0,n.jsx)(o.Paragraph,{children:(0,n.jsx)(h,{content:i?"systemUserRemoveAccessDisabled":"systemUserRemoveAccessEnabled"})})}),F=[];return s&&F.push((0,n.jsx)(o.Column,{children:(0,n.jsx)(o.Action,{href:(0,m.getContextUrl)(x,"/smb/ftp/users-list"),icon:"folder-key",onClick:r,"data-action":"show-ftp-accounts",children:(0,n.jsx)(h,{content:"additionalFtpAccounts"})})},"ftpAccounts")),t&&F.push((0,n.jsx)(o.Column,{children:(0,n.jsx)(o.Action,{to:f((0,p.getId)(e.id),"domain",`hosting-settings#${c.MenuSectionNames.WEBSPACE}`),component:a.Link,icon:"gear",onClick:r,"data-action":"manage-access",children:(0,n.jsx)(h,{content:"manageAccess"})})},"manageAccess")),(0,n.jsxs)("div",{"data-section":"user-credentials",children:[(0,n.jsx)(o.Section,{title:(0,n.jsx)(h,{content:"systemUserCredentials"}),children:(0,n.jsx)(o.Hint,{children:(0,n.jsx)(h,{content:"systemUserCredentialsHint",params:{details:A}})})}),(0,n.jsxs)(o.Section,{children:[e.ipAddresses.map((({publicIpAddress:e,ipAddress:s})=>{const t=e||s;return(0,n.jsxs)(o.FormField,{label:(0,n.jsx)(h,{content:"ipAddress"}),"data-type":"ip-address",children:[t,(0,n.jsx)(b.default,{content:t})]},t)})),(0,n.jsxs)(o.FormField,{label:(0,n.jsx)(h,{content:"username"}),"data-type":"login",children:[e.sysUser.login,(0,n.jsx)(b.default,{content:e.sysUser.login})]}),(0,n.jsxs)(o.FormField,{label:(0,n.jsx)(h,{content:"password"}),"data-type":"password",children:["•".repeat(16),t?(0,n.jsx)(u.default,{title:(0,n.jsx)(h,{content:"changeSystemUserPasswordTitle"}),handlerUrl:`/smb/web/change-password/id/${x}`,target:(0,n.jsx)(o.Button,{ghost:!0,icon:"pencil",tooltip:(0,n.jsx)(h,{content:"changePasswordTooltip"}),onClick:()=>g(!0),"data-type":"edit-password-button"}),visible:d,onClose:()=>g(!1)}):null]}),0<F.length?(0,n.jsx)(o.SectionItem,{children:(0,n.jsx)(o.Columns,{gap:"md",children:F})}):null]})]})};g.propTypes={domain:d().object.isRequired,showFtpAccounts:d().bool.isRequired,showManageAccess:d().bool.isRequired,isShellForbidden:d().bool.isRequired,onAction:d().func},g.defaultProps={onAction:()=>{}};const j=g},2084:(e,s,t)=>{t.r(s),t.d(s,{ConnectionInfo:()=>n.ConnectionInfo,default:()=>n.default});var n=t(2085)},2068:(e,s,t)=>{t.r(s),t.d(s,{ForwardingTypes:()=>o,HostingTypes:()=>n,MenuSectionNames:()=>r,PreferredDomain:()=>i,UiHostingTypes:()=>a});const n={VIRTUAL:"VIRTUAL",STANDARD_FORWARDING:"STANDARD_FORWARDING",FRAME_FORWARDING:"FRAME_FORWARDING",NONE:"NONE"},a={VIRTUAL:"hosting",FORWARDING:"forwarding",NONE:"none"},o={MOVED_PERMANENTLY:"MOVED_PERMANENTLY",MOVED_TEMPORARILY:"MOVED_TEMPORARILY",FRAME_FORWARDING:"FRAME_FORWARDING"},i={WWW:"www",NON_WWW:"non-www",NONE:"none"},r={DOMAIN:"domain",WEBSPACE:"webspace"}}}]);
//# sourceMappingURL=ConnectionInfo.js.map?bbd9aff8ebfb9ffd80f5