"use strict";(globalThis.webpackChunkPlesk=globalThis.webpackChunkPlesk||[]).push([["views/admin/ip-address/list"],{2619(e,t,s){s.r(t),s.d(t,{default:()=>C});var n=s(396),i=s(786),r=s.n(i),a=s(397),d=s(1318),l=s(95),o=s(2620),c=s(717),p=s(663),u=s(860),m=s(809),x=s(700);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=x.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=x.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
                    }
                }
            }
        }
    }
`,v=x.gql`
    ${f}
    query CreateIpAddressValues{
        ...generalFields
    }
`,S=x.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),[x,f]=(0,n.useState)(null),[I,C]=(0,n.useState)(null),P=(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}),C(e)},k=({message:e})=>{(0,p.addToast)({intent:"danger",message:e}),F()},[T,{loading:w}]=(0,m.useMutation)(S),[D]=(0,u.useLazyQuery)(v,{onCompleted:e=>P(e,!0),onError:k}),[L]=(0,u.useLazyQuery)(b,{onCompleted:e=>P(e,!1),onError:k});(0,n.useEffect)(()=>{f(null),C(null),s?D():i&&L({variables:{id:i.params.id}})},[D,L,s,i,r]);const F=()=>{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]),E=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:F,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:x,mutation:T,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:w?"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,E?(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};const C=I},2620(e,t,s){s.r(t),s.d(t,{default:()=>r});var n=s(397),i=s(396);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))},2617(e,t,s){s.r(t),s.d(t,{default:()=>S});var n=s(396),i=s(397),r=s(831),a=s(95),d=s(663),l=(s(2618),s(809)),o=s(738),c=s(700),p=s(770),u=s.n(p);const m=c.gql`
    mutation RereadIpAddresses {
        rereadIpAddresses {
            result
        }
    }
`,x=c.gql`
    mutation ReloadPublicIpAddresses {
        reloadPublicIpAddresses {
            task {
                id
            }
        }
    }
`,g=c.gql`
    mutation DeleteIpAddress($ids: [ID!]!) {
        deleteIpAddress(input: { ids: $ids} ) {
            ids
        }
    }
`,j=c.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"),v={page:1,itemsPerPage:25},S=()=>{const[e,t]=(0,n.useState)({search:null,type:null}),[s,c]=(0,n.useState)({sortColumn:null,sortDirection:null}),[p,S]=(0,n.useState)(v),y=e=>e.sortColumn?{orderBy:{[e.sortColumn]:e.sortDirection}}:{},A={...p,...e,...y(s)},[I,{loading:C}]=(0,l.useMutation)(m,{refetchQueries:[{query:u(),variables:A}]}),[P,{loading:k}]=(0,l.useMutation)(x,{onCompleted({reloadPublicIpAddresses:{task:e}}){const t=({id:s,status:n})=>{e?.id===s&&"done"===n&&(_(),a.Observer.remove(t,"plesk:taskComplete"))};a.Observer.append(t,"plesk:taskComplete")}}),[T]=(0,l.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}),_()}}),[w]=(0,l.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:L,loading:F,refetch:O}=(0,o.useQuery)(u(),{variables:v,notifyOnNetworkStatusChange:!0,onCompleted(e){const t=Math.ceil(e.server.ipAddresses.pageInfo.total/p.itemsPerPage);p.page>t&&S(e=>({...e,page:t})),c(e.server.ipAddresses.sortInfo)}}),{mode:{isDemo:E,isPowerUserPanel:R,canManageResellers:M}={},serverInfo:{isVirtuozzo:B}={},server:{firewall:q,ipAddresses:{nodes:H,pageInfo:{total:$},canReloadPublic:N,hasPublicIp:U}={}}={}}=D||L,[Q,V]=(0,n.useState)([]),[W,z]=(0,n.useState)([]),[G,X]=(0,n.useState)(!1),K=!(E||B),J=!R&&M,Y=e.search||e.type,Z="all"===p.itemsPerPage?1:Math.ceil($/p.itemsPerPage),_=async t=>{await O({...p,...e,...y(s),...t})},ee=(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,{"aria-label":f.lmsg("address"),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,{"aria-label":f.lmsg("type"),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:()=>{S(e=>({...e,page:1})),_({...e,page:1})},children:(0,n.jsx)(h,{content:"buttonSearch"})}),(0,n.jsx)(i.Button,{onClick:()=>{S(e=>({...e,page:1}));const e={search:null,type:null};t(e),_({...e,page:1})},children:(0,n.jsx)(h,{content:"buttonResetSearch"})})]})}),te=K?(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,se=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(i.Toolbar,{children:[(0,n.jsxs)(i.ToolbarGroup,{title:"",children:[te,(0,n.jsx)(i.Button,{"data-type":"ip-reread-configuration",icon:"refresh",onClick:I,state:C?"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:k?"loading":void 0,tooltip:(0,n.jsx)(h,{content:"buttonReloadPublicDescription"}),children:(0,n.jsx)(h,{content:"buttonReloadPublic"})}):null,q?.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()=>{z(Q),await T({variables:{ids:Q}}),z([])},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,{"data-cy":"filter-button",icon:"chevron-"+(G?"up":"down"),state:G?"active":void 0,onClick:()=>X(e=>!e),tooltip:f.lmsg("buttonFilter"),tooltipAsLabel:!0})})]}),G&&ee]}),ne=(0,n.useMemo)(()=>[{key:"ipAddress",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)(i.Link,{onClick:()=>w({variables:{id:s}}),children:(0,n.jsx)(h,{content:"repair"})}):null]})}):null]})},U?{key:"publicIpAddress",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"})},J?{width:"60px",key:"resellersCount",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,R?null:{width:"60px",key:"subscriptionsCount",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,J,R,w]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Paragraph,{children:(0,n.jsx)(h,{content:J?"hintWithResellers":"hint"})}),(0,n.jsx)(i.List,{loadingRows:W,"data-type":"ip-address-list",loading:F,rowKey:"id",sortColumn:s.sortColumn,sortDirection:s.sortDirection,onSortChange:e=>{c(e),_(y(e))},columns:ne,selection:Q,onSelectionChange:e=>V(e),data:H,toolbar:se,totalRows:$,pagination:(0,n.jsx)(i.Pagination,{current:p.page,total:Z,onSelect:e=>{S(t=>({...t,page:e})),_({page:e})},itemsPerPage:p.itemsPerPage,onItemsPerPageChange:e=>{const t={page:1,itemsPerPage:"all"===e?1e4:e};S(t),_(t)},itemsPerPageOptions:[10,25,100,"all"]}),emptyView:(0,n.jsxs)(n.Fragment,{children:[Y&&se,(0,n.jsx)(i.ListEmptyView,{actions:!Y&&te})]})})]})}},2616(e,t,s){s.r(t),s.d(t,{default:()=>p});var n=s(396),i=s(800),r=s(462),a=s(95),d=s(740),l=s(2617),o=s(717),c=s(2619);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}})},2615(e,t,s){s.r(t),s.d(t,{default:()=>n.default});var n=s(2616)},2618(e,t,s){s.r(t)}}]);
//# sourceMappingURL=list.js.map?9f5775f78bc1bead3202