"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["views/admin/ip-address/list"],{1949:(e,t,s)=>{s.r(t),s.d(t,{default:()=>P});var n=s(242),i=s(244),r=s.n(i),a=s(243),d=s(927),l=s(90),o=s(1950),c=s(728),p=s(679),u=s(455),m=s(762),x=s(1823);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 {
                id
                ipAddress
            }
            task {
                id
            }
        }
    }
`,y=({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]}),A="/cp/ip-address",I=({onSuccess:e})=>{const t=(0,c.useNavigate)(),s=(0,c.useMatch)(`${A}/add`),i=(0,c.useMatch)(`${A}/:id/edit`),r=!(!s&&!i),[u,f]=(0,n.useState)(null),[I,P]=(0,n.useState)(null),C=(e,t)=>{const{ipAddress:s={},server:n={}}=e;f((()=>{const i={ftpOverSSL:"CUSTOM"===n.settings.ftpOverSSL?s.ftpOverSSL:n.settings.ftpOverSSL,ipAddress:s.ipAddress,publicIpAddress:s.publicIpAddress??"",type:s.type??"EXCLUSIVE",certificateId:s.certificate?.id??e.certificates?.[0]?.id,interface:s.interface};return t?i.interface=s.interface??e.server.ipAddresses.interfaces?.[0]:i.defaultDomainId=s.defaultDomain?.id??0,i})),P(e)},T=({message:e})=>{(0,p.addToast)({intent:"danger",message:e}),L()},[k,{loading:D}]=(0,m.useMutation)(v),[w]=(0,x.useLazyQuery)(S,{onCompleted:e=>C(e,!0),onError:T}),[E]=(0,x.useLazyQuery)(b,{onCompleted:e=>C(e,!1),onError:T});(0,n.useEffect)((()=>{f(null),P(null),s?w():i&&E({variables:{id:i.params.id}})}),[w,E,s,i,r]);const L=()=>{t(A)},O=(0,n.useMemo)((()=>{if(!I||!I?.os.isWindows)return null;const e=I?.capability.ftp.isExplicitSSL;if(!e||i&&!I.os.isIPv6Supported&&I.ipAddress.isIPv6)return(0,n.jsx)(y,{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"===I?.server.settings.ftpOverSSL,s=[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)(y,{children:(0,n.jsx)(a.FormFieldRadioButtons,{label:(0,n.jsx)(h,{content:"ftpOverSsl"}),name:"ftpOverSSL",disabled:!t,options:s,description:(0,n.jsx)(h,{content:t?"ftpOverSslCustomHint":"ftpOverSslCustomDisabledHint"})})})}),[I,i]),F=i&&I?.os.isWindows&&I?.capability.panel.accessDriver.isHttpsProxyEnabled&&I?.capability.panel.accessDriver.isDefaultAccessDomain,R=(0,n.useMemo)((()=>{if(I){const e=[...I.certificates||[]],t=I.ipAddress?.certificate;return i&&t&&!e.find((e=>e.id===t.id))&&e.push(t),e}return[]}),[I,i]);return(0,n.jsx)(a.Drawer,{"data-type":"ip-address-drawer",isOpen:r,onClose:L,title:i?(0,n.jsx)(g,{content:"editTitle",params:{address:(0,n.jsx)(a.Text,{bold:!0,children:I?.ipAddress.ipAddress||""}),interface:(0,n.jsx)(a.Text,{bold:!0,children:I?.ipAddress.interface||""})}}):(0,n.jsx)(g,{content:"addTitle"}),form:(0,n.jsx)(d.default,{"data-type":"ip-address-drawer-form",values:u,mutation:k,onSubmit:e=>(i&&(e.id=i.params.id),e),onSuccess:({updateIpAddress:{ipAddress:{id:s,ipAddress:n},task:i}={}})=>{i||(0,p.addToast)({intent:"success",message:l.Locale.getSection("admin.controllers.ip-address.add").lmsg("ipAddressAdded",{address:n})}),t(A),e({task:i,query:{query:b,variables:{id:s}}})},submitButton:{name:"send","data-action":"submit"},state:D?"loading":void 0,applyButton:!1,children:I?(0,n.jsxs)(n.Fragment,{children:[I.ipAddress?.onRepairMode?(0,n.jsx)(a.StatusMessage,{intent:"warning",children:(0,n.jsx)(g,{content:"ipAddressInterfaceNotAvailableWarning",params:{interface:I.ipAddress.interface}})}):null,s||I.ipAddress?.onRepairMode?(0,n.jsx)(a.FormFieldSelect,{name:"interface",label:(0,n.jsx)(g,{content:"interface"}),children:I.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:I.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:R.map((({id:e,name:t})=>(0,n.jsx)("option",{value:e,children:t},e)))}),i?(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")}),I.ipAddress.domains?.map((({id:e,name:t,owner:{name:s}})=>(0,n.jsx)("option",{value:e,children:`${t} (${s})`},e)))]}):null,O,F?(0,n.jsx)("div",{style:{marginTop:"2rem"},children:(0,n.jsx)(a.Status,{intent:"warning",children:(0,n.jsx)(g,{content:"accessDomainOnAnyDomainWinWarning",params:{ip:I.ipAddress.ipAddress}})})}):null]}):(0,n.jsx)(o.default,{})})})};I.propTypes={onSuccess:r().func},I.defaultProps={onSuccess:()=>{}};const P=I},1950:(e,t,s)=>{s.r(t),s.d(t,{default:()=>r});var n=s(243),i=s(242);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)))},1947:(e,t,s)=>{s.r(t),s.d(t,{default:()=>v});var n=s(242),i=s(243),r=s(775),a=s(90),d=s(679),l=(s(1948),s(455)),o=s(762),c=s(734),p=s(911),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),y={...p,...e,...s},[A,{loading:I}]=(0,o.useMutation)(m,{refetchQueries:[{query:u(),variables:y}]}),[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:y}],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:y}],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:q,total:H,canReloadPublic:$,hasPublicIp:N}={}}={}}=D||w,[U,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(H/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:A,state:I?"loading":void 0,tooltip:(0,n.jsx)(h,{content:"buttonRereadConfigurationDescription"}),children:(0,n.jsx)(h,{content:"buttonRereadConfiguration"})}),$?(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:q.find((({id:e})=>U[0]===e)).ipAddress}),count:U.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:!U.length,onClick:async()=>{W(U),await T({variables:{ids:U}}),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]})},N?{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))),[N,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:q,toolbar:te,totalRows:H,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})]})})]})}},1946:(e,t,s)=>{s.r(t),s.d(t,{default:()=>p});var n=s(242),i=s(739),r=s(290),a=s(90),d=s(735),l=s(1947),o=s(728),c=s(1949);const p=(0,i.withPageLayout)((()=>{const e=(0,d.useApolloClient)(),t=(0,n.useCallback)((({task:t,query:s})=>{const n=()=>e.refetchQueries({include:["IpAddressPage",s]});if(t){const e=({id:s,status:i})=>{t?.id===s&&"done"===i&&(n(),a.Observer.remove(e,"plesk:taskComplete"))};a.Observer.append(e,"plesk:taskComplete")}else n()}),[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}}))},1945:(e,t,s)=>{s.r(t),s.d(t,{default:()=>n.default});var n=s(1946)},1948:(e,t,s)=>{s.r(t)}}]);
//# sourceMappingURL=list.js.map?8c73505d504007cdce75