"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/ConnectionInfo"],{1317:(e,s,t)=>{t.r(s),t.d(s,{default:()=>d});var n=t(253),a=t.n(n),o=t(252),i=t(251);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},2050:(e,s,t)=>{t.r(s),t.d(s,{default:()=>c});var n=t(252),a=t(89),o=t(253),i=t.n(o),r=t(251);const d=a.Locale.getTranslate("components.buttons"),l=({id:e,content:s})=>(0,r.jsx)(n.Button,{ghost:!0,icon:"copy",tooltip:(0,r.jsx)(d,{content:"copyToClipboard"}),onClick:()=>(0,n.copyToClipboard)(s),"data-action":"copy-to-clipboard"+(e?`-${e}`:"")});l.propTypes={id:i().string,content:i().string.isRequired},l.defaultProps={id:void 0};const c=l},942:(e,s,t)=>{t.r(s),t.d(s,{default:()=>l});var n=t(251),a=t(581),o=t(253),i=t.n(o),r=t(252);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},2048:(e,s,t)=>{t.r(s),t.d(s,{ConnectionInfo:()=>j,default:()=>x});var n=t(251),a=t(581),o=t(495),i=t(588),r=t(252),d=t(1317),l=t(821),c=t(942),u=t(89),m=t(2049),p=t(2052);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),S=()=>t(!1),{loading:y,data:D,error:F}=(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:D?D.domain.name:null,size:"sm","data-type":"connection-info",children:(()=>{if(y||f)return(0,n.jsx)(r.ContentLoader,{});if(F)return(0,n.jsx)(d.default,{error:F});if(!D)return(0,n.jsx)(r.ContentLoader,{});const e=D.domain.baseDomain?D.domain.baseDomain:D.domain,s=Number(atob(e.id).split(":")[1]),{databases:t}=e;let a=D.domain.relatedDatabase;!a&&0<D.domain.applicationDatabases.length?a=D.domain.applicationDatabases[0]:!a&&0<t.length&&(a=t[0]);const{permissions:i,isDatabasesAvailable:c}=D.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)))),D.domain.sysUser?(0,n.jsx)(p.default,{domain:D.domain,showFtpAccounts:i.manageFtpAccounts,showManageAccess:i.manageWebsitesAndDomains,isShellForbidden:D.domain.sysUser.isShellForbidden,onAction:S}):null,u?(0,n.jsx)(m.default,{baseDomainId:s,database:a,databases:t,onAction:S}):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},2049:(e,s,t)=>{t.r(s),t.d(s,{default:()=>p});var n=t(251),a=t(253),o=t.n(a),i=t(252),r=t(89),d=t(631),l=t(2050),c=t(2051);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},2051:(e,s,t)=>{t.r(s),t.d(s,{default:()=>u});var n=t(251),a=t(252),o=t(636),i=t(89),r=t(253),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},2052:(e,s,t)=>{t.r(s),t.d(s,{default:()=>j});var n=t(251),a=t(592),o=t(252),i=t(89),r=t(253),d=t.n(r),l=t(709),c=t(2028),u=t(2051),m=t(724),p=t(712),b=t(2050);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"})})}),S=[];return s&&S.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&&S.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<S.length?(0,n.jsx)(o.SectionItem,{children:(0,n.jsx)(o.Columns,{gap:"md",children:S})}):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},2047:(e,s,t)=>{t.r(s),t.d(s,{ConnectionInfo:()=>n.ConnectionInfo,default:()=>n.default});var n=t(2048)},2028:(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",DOMAIN_NAME:"domainName",HOSTING_TYPE:"hostingType",SSL:"ssl",SAME_SSL:"sameSsl",WEB_STATS:"statistics",WEB_SCRIPTING:"scripting",WEBSPACE:"webspace",SYS_USER:"systemUser",SHELL:"shell",IP:"ipAddresses",QUOTA:"quota"}}}]);
//# sourceMappingURL=ConnectionInfo.js.map?badbdacef829fcaa42af