"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["views/admin/ip-address/list"],{1891:(e,t,s)=>{s.r(t),s.d(t,{default:()=>P});var n=s(241),i=s(243),r=s.n(i),a=s(242),d=s(877),l=s(90),o=s(1892),c=s(719),p=s(717),u=s(447),m=s(748),x=s(1772);const g=l.Locale.getTranslate("admin.components.forms.ip-address"),j=l.Locale.getSection("admin.components.forms.ip-address"),h=l.Locale.getTranslate("admin.components.forms.security-policy"),f=u.gql`
    fragment generalFields on Query {
        certificates(fromServerRepository: true) {
            id
            name
            repositoryName
        }
        server {
            settings {
                ftpOverSSL
            }
            ipAddresses {
                interfaces
            }
        }
        os {
            isIPv6Supported
            isWindows
        }
        capability {
            panel {
                accessDriver {
                    isHttpsProxyEnabled
                    isDefaultAccessDomain
                }
            }
            ftp {
                isExplicitSSL
            }
        }
    }
`,b=u.gql`
    ${f}
    query UpdateIpAddressValues($id: ID!) {
        ...generalFields
        ipAddress: node(id: $id) {
            ... on IpAddress {
                id
                type
                onRepairMode
                ipAddress
                publicIpAddress
                ftpOverSSL
                isIPv6
                interface
                certificate {
                    id
                    name
                    repositoryName
                }
                defaultDomain {
                    id
                }
                domains {
                    id
                    name(idn: false)
                    owner {
                        name
                    }
                }
            }
        }
    }
`,S=u.gql`
    ${f}
    query CreateIpAddressValues{
        ...generalFields
    }
`,v=u.gql`
    mutation UpdateIpAddress($input: UpdateIpAddressInput!){
        updateIpAddress(input: $input) {
            ipAddress
            task {
                id
            }
        }
    }
`,A=({children:e})=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("hr",{}),(0,n.jsx)(a.Text,{bold:!0,style:{fontSize:"1.2rem"},children:(0,n.jsx)(h,{content:"secureFtpSection"})}),e]}),y="/cp/ip-address",I=({onSuccess:e})=>{const t=(0,c.useNavigate)(),s=(0,c.useMatch)(`${y}/add`),i=(0,c.useMatch)(`${y}/:id/edit`),r=!(!s&&!i),[u,f]=(0,n.useState)(null),[I,{loading:P}]=(0,m.useMutation)(v),[C,{data:T,loading:k}]=(0,x.useLazyQuery)(s?S:b,{onCompleted:e=>{const{ipAddress:t={},server:n={}}=e;f((()=>{const i={ftpOverSSL:"CUSTOM"===n.settings.ftpOverSSL?t.ftpOverSSL:n.settings.ftpOverSSL,ipAddress:t.ipAddress,publicIpAddress:t.publicIpAddress??"",type:t.type??"EXCLUSIVE",certificateId:t.certificate?.id??e.certificates[0]?.id,interface:t.interface};return s?i.interface=t.interface??e.server.ipAddresses.interfaces?.[0]:i.defaultDomainId=t.defaultDomain?.id??0,i}))}});(0,n.useEffect)((()=>{if(r){const e=s?{}:{id:i.params.id};C({variables:e})}}),[C,s,i,r]);const D=(0,n.useMemo)((()=>{if(!T||!T?.os.isWindows)return null;const e=T?.capability.ftp.isExplicitSSL;if(!e||!s&&!T.os.isIPv6Supported&&T.ipAddress.isIPv6)return(0,n.jsx)(A,{children:(0,n.jsx)(a.FormField,{label:(0,n.jsx)(h,{content:"ftpOverSsl"}),children:(0,n.jsx)(g,{content:e?"ftpOverSslIpv6NotSupportedByServer":"ftpOverSslNotSupportedByServer"})})});const t="CUSTOM"===T?.server.settings.ftpOverSSL,i=[t?null:{value:"REQUIRED",label:(0,n.jsx)(h,{content:"ftpOverSslOptionRequired"})},{value:"ENABLED",label:(0,n.jsx)(h,{content:"ftpOverSslOptionEnabled"})},{value:"DISABLED",label:(0,n.jsx)(h,{content:"ftpOverSslOptionDisabled"})}].filter((e=>e));return(0,n.jsx)(A,{children:(0,n.jsx)(a.FormFieldRadioButtons,{label:(0,n.jsx)(h,{content:"ftpOverSsl"}),name:"ftpOverSSL",disabled:!t,options:i,description:(0,n.jsx)(h,{content:t?"ftpOverSslCustomHint":"ftpOverSslCustomDisabledHint"})})})}),[T,s]),w=!s&&T?.os.isWindows&&T?.capability.panel.accessDriver.isHttpsProxyEnabled&&T?.capability.panel.accessDriver.isDefaultAccessDomain,E=(0,n.useMemo)((()=>{if(T){const e=T.certificates,t=T.ipAddress?.certificate;return s||!t||e.find((e=>e.id===t.id))||e.push(t),e}return[]}),[T,s]);return(0,n.jsx)(a.Drawer,{"data-type":"ip-address-drawer",isOpen:r,onClose:()=>{t(y)},title:s?(0,n.jsx)(g,{content:"addTitle"}):(0,n.jsx)(g,{content:"editTitle",params:{address:(0,n.jsx)(a.Text,{bold:!0,children:T?.ipAddress.ipAddress||""}),interface:(0,n.jsx)(a.Text,{bold:!0,children:T?.ipAddress.interface||""})}}),form:(0,n.jsx)(d.default,{"data-type":"ip-address-drawer-form",values:u,mutation:I,onSubmit:e=>(s||(e.id=i.params.id),e),onSuccess:({updateIpAddress:{ipAddress:s,task:n}={}})=>{n||(0,p.addToast)({intent:"success",message:l.Locale.getSection("admin.controllers.ip-address.add").lmsg("ipAddressAdded",{address:s})}),t(y),e({task:n})},submitButton:{name:"send","data-action":"submit"},state:P?"loading":void 0,applyButton:!1,children:!T||k?(0,n.jsx)(o.default,{}):(0,n.jsxs)(n.Fragment,{children:[T.ipAddress?.onRepairMode?(0,n.jsx)(a.StatusMessage,{intent:"warning",children:(0,n.jsx)(g,{content:"ipAddressInterfaceNotAvailableWarning",params:{interface:T.ipAddress.interface}})}):null,s||T.ipAddress?.onRepairMode?(0,n.jsx)(a.FormFieldSelect,{name:"interface",label:(0,n.jsx)(g,{content:"interface"}),children:T.server.ipAddresses.interfaces.map((e=>(0,n.jsx)("option",{value:e,children:e},e)))}):null,s?(0,n.jsx)(a.FormFieldText,{name:"ipAddress",size:"lg",description:(0,n.jsx)(g,{content:T.isIPv6Supported?"addressHintIPv6":"addressHintIPv4"}),label:(0,n.jsx)(g,{content:"addressAndSubnetPrefixLength"}),inputProps:{maxLength:255}}):null,(0,n.jsx)(a.FormFieldText,{name:"publicIpAddress",label:(0,n.jsx)(g,{content:"publicIp"}),inputProps:{maxLength:255}}),(0,n.jsx)(a.FormFieldRadioButtons,{name:"type",label:(0,n.jsx)(g,{content:"distributionType"}),options:[{value:"SHARED",label:(0,n.jsx)(g,{content:"distributionTypeShared"})},{value:"EXCLUSIVE",label:(0,n.jsx)(g,{content:"distributionTypeExclusive"})}]}),(0,n.jsx)(a.FormFieldSelect,{name:"certificateId",label:(0,n.jsx)(g,{content:"certificate"}),children:E.map((({id:e,name:t})=>(0,n.jsx)("option",{value:e,children:t},e)))}),s?null:(0,n.jsxs)(a.FormFieldSelect,{name:"defaultDomainId","data-testid":"defaultSite",label:(0,n.jsx)(g,{content:"defaultSite"}),children:[(0,n.jsx)("option",{value:0,children:j.lmsg("none")}),T.ipAddress.domains?.map((({id:e,name:t,owner:{name:s}})=>(0,n.jsx)("option",{value:e,children:`${t} (${s})`},e)))]}),D,w?(0,n.jsx)("div",{style:{marginTop:"2rem"},children:(0,n.jsx)(a.Status,{intent:"warning",children:(0,n.jsx)(g,{content:"accessDomainOnAnyDomainWinWarning",params:{ip:T.ipAddress.ipAddress}})})}):null]})})})};I.propTypes={onSuccess:r().func},I.defaultProps={onSuccess:()=>{}};const P=I},1892:(e,t,s)=>{s.r(t),s.d(t,{default:()=>r});var n=s(242),i=s(241);const r=()=>Array.from({length:6}).map(((e,t)=>(0,i.jsx)(n.FormField,{label:(0,i.jsx)(n.SkeletonText,{lines:1}),children:(0,i.jsx)(n.Skeleton,{maxWidth:300})},t)))},1889:(e,t,s)=>{s.r(t),s.d(t,{default:()=>v});var n=s(241),i=s(242),r=s(761),a=s(90),d=s(717),l=(s(1890),s(447)),o=s(748),c=s(725),p=s(861),u=s.n(p);const m=l.gql`
    mutation RereadIpAddresses {
        rereadIpAddresses {
            result
        }
    }
`,x=l.gql`
    mutation ReloadPublicIpAddresses {
        reloadPublicIpAddresses {
            task {
                id
            }
        }
    }
`,g=l.gql`
    mutation DeleteIpAddress($ids: [ID!]!) {
        deleteIpAddress(input: { ids: $ids} ) {
            ids
        }
    }
`,j=l.gql`
    mutation RepairIpAddress($id: ID!) {
        repairIpAddress(input: { id: $id }) {
            ipAddress {
                ipAddress
            }
        }
    }
`,h=a.Locale.getTranslate("admin.components.lists.ipaddresses"),f=a.Locale.getSection("admin.components.lists.ipaddresses"),b=a.Locale.getTranslate("components.buttons"),S={page:1,itemsPerPage:25},v=()=>{const[e,t]=(0,n.useState)({search:null,type:null}),[s,l]=(0,n.useState)({sortColumn:null,sortDirection:null}),[p,v]=(0,n.useState)(S),A={...p,...e,...s},[y,{loading:I}]=(0,o.useMutation)(m,{refetchQueries:[{query:u(),variables:A}]}),[P,{loading:C}]=(0,o.useMutation)(x,{onCompleted({reloadPublicIpAddresses:{task:e}}){const t=({id:s,status:n})=>{e?.id===s&&"done"===n&&(J(),a.Observer.remove(t,"plesk:taskComplete"))};a.Observer.append(t,"plesk:taskComplete")}}),[T]=(0,o.useMutation)(g,{refetchQueries:[{query:u(),variables:A}],onCompleted(){(0,d.addToast)({intent:"success",message:f.lmsg("removeSuccess")})},onError({message:e}){(0,d.addToast)({intent:"danger",message:e}),J()}}),[k]=(0,o.useMutation)(j,{refetchQueries:[{query:u(),variables:A}],onCompleted({repairIpAddress:{ipAddress:{ipAddress:e}={}}={}}){(0,d.addToast)({intent:"success",message:f.lmsg("repairSuccess",{address:e})})},onError({message:e}){(0,d.addToast)({intent:"danger",message:e})}}),{data:D,previousData:w,loading:E,refetch:L}=(0,c.useQuery)(u(),{variables:S,notifyOnNetworkStatusChange:!0,onCompleted(e){const t=Math.ceil(e.server.ipAddresses.total/p.itemsPerPage);p.page>t&&v((e=>({...e,page:t})))}}),{mode:{isDemo:O,isPowerUserPanel:F,canManageResellers:R}={},serverInfo:{isVirtuozzo:B}={},server:{firewall:M,ipAddresses:{list:H,total:$,canReloadPublic:N,hasPublicIp:U}={}}={}}=D||w,[q,Q]=(0,n.useState)([]),[V,W]=(0,n.useState)([]),[z,_]=(0,n.useState)(!1),G=!(O||B),X=!F&&R,K=e.search||e.type,Y="all"===p.itemsPerPage?1:Math.ceil($/p.itemsPerPage),J=async t=>{await L({...p,...e,...s,...t})},Z=(0,n.jsx)(i.Panel,{children:(0,n.jsxs)(i.ToolbarGroup,{title:"",className:"ip-address-page-filter",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(i.Hint,{children:(0,n.jsx)(h,{content:"address"})}),(0,n.jsx)(i.Input,{value:e.search,onChange:({target:e})=>t((t=>({...t,search:e.value})))})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)(i.Hint,{children:(0,n.jsx)(h,{content:"type"})}),(0,n.jsxs)(i.Select,{size:"sm",value:e.type??"",onChange:e=>t((t=>({...t,type:e||void 0}))),children:[(0,n.jsx)("option",{value:"",children:f.lmsg("typeAny")}),(0,n.jsx)("option",{value:"SHARED",children:f.lmsg("typeShared")}),(0,n.jsx)("option",{value:"EXCLUSIVE",children:f.lmsg("typeExclusive")})]})]}),(0,n.jsx)(i.Button,{onClick:()=>{v((e=>({...e,page:1}))),J({...e,page:1})},children:(0,n.jsx)(h,{content:"buttonSearch"})}),(0,n.jsx)(i.Button,{onClick:()=>{v((e=>({...e,page:1})));const e={search:null,type:null};t(e),J({...e,page:1})},children:(0,n.jsx)(h,{content:"buttonResetSearch"})})]})}),ee=G?(0,n.jsx)(i.Button,{component:r.default,to:"/cp/ip-address/add","data-type":"ip-add-address",icon:"plus",intent:"primary",tooltip:(0,n.jsx)(h,{content:"buttonAddNewIpAddressDescription"}),children:(0,n.jsx)(h,{content:"buttonAddNewIpAddress"})}):null,te=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(i.Toolbar,{children:[(0,n.jsxs)(i.ToolbarGroup,{title:"",children:[ee,(0,n.jsx)(i.Button,{"data-type":"ip-reread-configuration",icon:"refresh",onClick:y,state:I?"loading":void 0,tooltip:(0,n.jsx)(h,{content:"buttonRereadConfigurationDescription"}),children:(0,n.jsx)(h,{content:"buttonRereadConfiguration"})}),N?(0,n.jsx)(i.Button,{"data-type":"ip-button-reload-public",onClick:P,state:C?"loading":void 0,tooltip:(0,n.jsx)(h,{content:"buttonReloadPublicDescription"}),children:(0,n.jsx)(h,{content:"buttonReloadPublic"})}):null,M?.isEnabled?(0,n.jsx)(i.Button,{to:"/cp/firewall/",component:r.default,"data-type":"ip-button-firewall",tooltip:(0,n.jsx)(h,{content:"buttonFirewallDescription"}),children:(0,n.jsx)(h,{content:"buttonFirewall"})}):null]}),(0,n.jsx)(i.ToolbarGroup,{title:"",children:(0,n.jsx)(i.ListOperation,{critical:!0,confirmationText:()=>f.formatMessage("removeConfirmation",{name:(0,n.jsx)("b",{children:H.find((({id:e})=>q[0]===e)).ipAddress}),count:q.length}),actionButtonText:(0,n.jsx)(b,{content:"yesRemove"}),cancelButtonText:(0,n.jsx)(b,{content:"cancel"}),children:(0,n.jsx)(i.Button,{"data-type":"ip-remove",disabled:!q.length,onClick:async()=>{W(q),await T({variables:{ids:q}}),W([])},icon:"recycle",children:(0,n.jsx)(h,{content:"buttonRemove"})})})}),(0,n.jsx)(i.ToolbarExpander,{}),(0,n.jsx)(i.ToolbarGroup,{title:"",groupable:!1,children:(0,n.jsx)(i.Button,{icon:"chevron-"+(z?"up":"down"),state:z?"active":void 0,onClick:()=>_((e=>!e))})})]}),z&&Z]}),se=(0,n.useMemo)((()=>[{key:"IP_ADDRESS",title:(0,n.jsx)(h,{content:"address"}),type:"title",sortable:!0,render:({isMain:e,ipAddress:t,id:s,mask:a,isBroken:d,isBlacklisted:l,isMissing:o})=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Text,{bold:e,children:(0,n.jsx)(r.default,{"data-type":"ip-address-edit",to:`/cp/ip-address/${s}/edit`,children:t})}),(0,n.jsxs)(i.Hint,{children:[" ","/"," ",a]}),d?(0,n.jsx)("div",{style:{marginTop:"5px"},children:(0,n.jsxs)(i.Status,{intent:"warning",children:[(0,n.jsx)(h,{content:l?"ipAddressBlacklisted":"ipAddressBroken"})," ",o&&!l?(0,n.jsx)("a",{onClick:()=>k({variables:{id:s}}),children:(0,n.jsx)(h,{content:"repair"})}):null]})}):null]})},U?{key:"PUBLIC_IP_ADDRESS",title:(0,n.jsx)(h,{content:"publicAddress"}),sortable:!0,render:({isMain:e,publicIpAddress:t})=>(0,n.jsx)(i.Text,{bold:e,children:t})}:null,{width:"160px",key:"INTERFACE",title:(0,n.jsx)(h,{content:"interface"}),sortable:!0,render:({interface:e})=>e},{width:"150px",key:"TYPE",title:(0,n.jsx)(h,{content:"type"}),sortable:!0,render:({type:e})=>(0,n.jsx)(h,{content:"SHARED"===e?"typeSharedHint":"typeExclusiveHint"})},X?{width:"60px",key:"RESELLERS_COUNT",title:(0,n.jsx)(h,{content:"resellerCount"}),sortable:!0,render:({id:e,resellersCount:t})=>(0,n.jsx)(r.default,{to:`${e}/clients`,children:t})}:null,F?null:{width:"60px",key:"SUBSCRIPTIONS_COUNT",title:(0,n.jsx)(h,{content:"subscriptionCount"}),sortable:!0,render:({id:e,subscriptionsCount:t})=>(0,n.jsx)(r.default,{to:`${e}/domains`,children:t})}].filter((e=>e))),[U,X,F,k]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Paragraph,{children:(0,n.jsx)(h,{content:X?"hintWithResellers":"hint"})}),(0,n.jsx)(i.List,{loadingRows:V,"data-type":"ip-address-list",loading:E,rowKey:"id",sortColumn:s.sortColumn,sortDirection:s.sortDirection,onSortChange:e=>{l(e),J(e)},columns:se,onSelectionChange:e=>Q(e),data:H,toolbar:te,totalRows:$,pagination:(0,n.jsx)(i.Pagination,{current:p.page,total:Y,onSelect:e=>{v((t=>({...t,page:e}))),J({page:e})},itemsPerPage:p.itemsPerPage,onItemsPerPageChange:e=>{const t={page:1,itemsPerPage:"all"===e?1e4:e};v(t),J(t)},itemsPerPageOptions:[10,25,100,"all"]}),emptyView:(0,n.jsxs)(n.Fragment,{children:[K&&te,(0,n.jsx)(i.ListEmptyView,{actions:!K&&ee})]})})]})}},1888:(e,t,s)=>{s.r(t),s.d(t,{default:()=>p});var n=s(241),i=s(731),r=s(288),a=s(90),d=s(726),l=s(1889),o=s(719),c=s(1891);const p=(0,i.withPageLayout)((()=>{const e=(0,d.useApolloClient)(),t=(0,n.useCallback)((({task:t})=>{const s=()=>e.refetchQueries({include:["IpAddressPage"]});if(t){const e=({id:n,status:i})=>{t?.id===n&&"done"===i&&(s(),a.Observer.remove(e,"plesk:taskComplete"))};a.Observer.append(e,"plesk:taskComplete")}else s()}),[e]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l.default,{}),(0,n.jsx)(c.default,{onSuccess:t}),(0,n.jsx)(o.Outlet,{})]})}),(e=>{const{showFrames:t,pageHeader:s,pageSidebar:n}=(0,r.default)(),i=a.Locale.getSection("admin.controllers.ip-address.list").lmsg("title");return{...e,showFrames:t,pageHeader:{...s,helpMenu:{...s.helpMenu,helpContext:"ip-address.list"}},pageSidebar:n,pageContentHeader:{pageTitle:i,breadcrumbs:[n.isPowerUserPanel?null:{title:a.Locale.getSection("admin.controllers.home.admin").lmsg("title"),href:"/admin/home/"},{title:a.Locale.getSection("admin.controllers.server.tools").lmsg("title"),href:"/admin/server/tools/"},{title:i,href:"/cp/ip-address/"}].filter(Boolean)},pageTitle:i}}))},1887:(e,t,s)=>{s.r(t),s.d(t,{default:()=>n.default});var n=s(1888)},1890:(e,t,s)=>{s.r(t)}}]);
//# sourceMappingURL=list.js.map?2892f642d6db38acd43d