"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/FirewallIcmpPage"],{1642:(e,t,a)=>{a.r(t),a.d(t,{SORT_ASC:()=>p,SORT_DESC:()=>m,default:()=>g});var s=a(236),o=a(238),l=a.n(o),r=a(237),i=a(87);const n=i.Locale.getTranslate("components.list"),c=i.Locale.getSection("components.list"),p="ASC",m="DESC",u="all",d=({data:e,columns:t,itemsPerPage:a,itemsPerPageOptions:o,sortColumn:l,sortDirection:i,searchField:m,locale:d,emptyView:g,emptyFilteredView:f,toolbar:y,selection:h,onSelectionChange:w,searchBarInputProps:b,rowKey:P,...S})=>{const[C,x]=(0,s.useState)(1),[T,j]=(0,s.useState)(l??t.find((({sortable:e})=>e))?.key),[k,F]=(0,s.useState)(i),[L,v]=(0,s.useState)(o.includes(a)?a:o[0]),[R,M]=(0,s.useState)(""),V=(0,s.useMemo)((()=>R?f??(0,s.jsx)(r.ListEmptyView,{reason:"filtered",title:(0,s.jsx)(n,{content:"emptyViewFilteredTitle"}),description:(0,s.jsx)(n,{content:"emptyViewFilteredDescription"})}):g??(0,s.jsx)(r.ListEmptyView,{title:(0,s.jsx)(n,{content:"emptyViewTitle"})})),[R,g,f]),D=(0,s.useMemo)((()=>m?e.filter((e=>(Array.isArray(m)?m:[m]).some((t=>e[t]&&String(e[t]).toLowerCase().includes(R.toLowerCase()))))):e),[e,R,m]),E=(0,s.useMemo)((()=>{if(!T)return D;const e=t.find((({key:e})=>e===T))?.sortDataField??T,a=t.find((({key:e})=>e===T))?.sort??((t,a)=>t[e]<a[e]?-1:t[e]>a[e]?1:0);return[...D].sort(((e,t)=>p===k?a(e,t):a(t,e)))}),[D,T,k,t]),O=(0,s.useMemo)((()=>{if(L===u)return E;const e=L*(C-1),t=e+L;return E.slice(e,t)}),[C,E,L]),I=(0,s.useCallback)((e=>{M(e),e!==R&&x(1)}),[R]),q=(0,s.useCallback)((e=>{v(e);(e===u?1:Math.ceil(D.length/e))<C&&x(1)}),[D.length,C]);return(0,s.useEffect)((()=>{if("function"==typeof w&&h.length){const e=D.map((e=>{return t=e,"function"==typeof(a=P)?a(t):t[a];var t,a})).filter((e=>h.includes(e)));w(e)}}),[D]),(0,s.jsx)(r.List,{pagination:(0,s.jsx)(r.Pagination,{current:C,total:L===u?1:Math.ceil(D.length/L),onSelect:e=>x(e),itemsPerPage:L,itemsPerPageOptions:o,onItemsPerPageChange:q}),toolbar:(y||m)&&(0,s.jsxs)(r.Toolbar,{children:[y,m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.ToolbarExpander,{}),(0,s.jsx)(r.ToolbarGroup,{title:"",children:(0,s.jsx)(r.SearchBar,{inputProps:{placeholder:c.lmsg("searchPlaceholder"),"data-testid":"list-searchbar",...b??{}},onTyping:I})})]})]}),totalRows:D.length,sortColumn:T,sortDirection:k,onSortChange:({sortColumn:e,sortDirection:t})=>{j(e),F(t)},columns:t,data:O,filtered:!!R,locale:{totalRows:({totalRows:e})=>c.formatMessage("recordsTotal",{total:e}),...d},emptyView:V,onSelectionChange:w,selection:h,rowKey:P,...S})};d.propTypes={data:l().array.isRequired,columns:l().array.isRequired,itemsPerPage:l().number,itemsPerPageOptions:l().array,sortColumn:l().string,sortDirection:l().string,searchField:l().oneOfType([l().string,l().arrayOf(l().string.isRequired)]),locale:l().object,emptyView:l().node,emptyFilteredView:l().node,toolbar:l().node,onSelectionChange:l().func,selection:l().array,rowKey:l().oneOfType([l().string,l().func]),searchBarInputProps:l().object},d.defaultProps={itemsPerPage:25,itemsPerPageOptions:[10,25,100,u],sortColumn:void 0,sortDirection:p,searchField:void 0,locale:{},emptyView:void 0,emptyFilteredView:void 0,toolbar:void 0,onSelectionChange:void 0,selection:[],searchBarInputProps:void 0,rowKey:"key"};const g=d},1823:(e,t,a)=>{a.r(t),a.d(t,{default:()=>f});var s=a(238),o=a(237),l=a(87),r=a(1642),i=a(443),n=a(709),c=a(236),p=a(684);const m=l.Locale.getTranslate("admin.components.lists.firewallicmprules"),u=l.Locale.getSection("admin.components.lists.firewallicmprules"),d=i.gql`
    mutation ToggleFirewallIcmpRuleStatus($key: String!, $enable: Boolean!) {
        toggleFirewallIcmpRule(input: { key: $key, enable: $enable }) {
            query {
                server {
                    firewall {
                        icmpRules {
                            key
                            isEnabled
                        }
                    }
                }
            }
        }
    }
`,g=({rules:e})=>{const[t,a]=(0,c.useState)([]),[s,{loading:l}]=(0,n.useMutation)(d),i=(0,c.useMemo)((()=>e.map((({key:e,...t})=>({key:e,name:u.lmsg(e.toLowerCase()),...t})))),[e]);return(0,c.jsx)(r.default,{columns:[{key:"status",title:(0,c.jsx)(m,{content:"status"}),sortable:!0,sortDataField:"isEnabled",width:"1%",render:({key:e,isEnabled:r})=>(0,c.jsx)(o.Switch,{id:`toggle-${e}`,tooltip:(0,c.jsx)(m,{content:r?"on":"off"}),checked:r,loading:l&&t.includes(e),onChange:()=>(async(e,t)=>{try{a((t=>[...t,e])),await s({variables:{key:e,enable:t}})}catch(e){(0,p.addToast)({intent:"danger",message:e.message})}finally{a((t=>t.filter((t=>t!==e))))}})(e,!r)})},{key:"name",title:(0,c.jsx)(m,{content:"name"}),type:"title",sortable:!0}],data:i,searchField:"name",sortColumn:"name"})};g.propTypes={rules:s.PropTypes.arrayOf(s.PropTypes.shape({key:s.PropTypes.string.isRequired,isEnabled:s.PropTypes.bool.isRequired})).isRequired};const f=g},1822:(e,t,a)=>{a.r(t),a.d(t,{default:()=>u});var s=a(87),o=a(282),l=a(692),r=a(1823),i=a(1819),n=a(686),c=a(810),p=a.n(c),m=a(236);const u=(0,l.withPageLayout)((0,i.withFirewallTabs)((()=>{const{data:{server:{firewall:{icmpRules:e}}}}=(0,n.useQuery)(p());return(0,m.jsx)(r.default,{rules:e})})),(()=>{const{showFrames:e,pageHeader:t,pageSidebar:a}=(0,o.default)();return{showFrames:e,pageHeader:{...t,helpMenu:{...t.helpMenu,helpContext:"firewall_icmp"}},pageSidebar:a,pageContentHeader:{breadcrumbs:[a.isPowerUserPanel?null:{title:s.Locale.getSection("components.pages.home").lmsg("title"),href:"/admin/home"},{title:s.Locale.getSection("admin.controllers.server.tools").lmsg("title"),href:"/admin/server/tools"},{title:s.Locale.getSection("components.pages.firewall").lmsg("title"),href:"/cp/firewall"},{title:s.Locale.getSection("components.pages.firewall-icmp").lmsg("title"),href:"/cp/firewall/icmp"}].filter(Boolean),tabs:[],tabsHasRootPage:!0}}}))},1819:(e,t,a)=>{a.r(t),a.d(t,{default:()=>m,withFirewallTabs:()=>p});var s=a(236),o=a(679),l=a(680),r=a(237),i=a(87),n=a(722);const c=()=>{const{pathname:e}=(0,o.useLocation)(),t=(0,s.useMemo)((()=>[{title:i.Locale.getSection("components.pages.firewall-general").lmsg("title"),url:"/cp/firewall/general",id:"tabGeneral"},{title:i.Locale.getSection("components.pages.firewall-icmp").lmsg("title"),url:"/cp/firewall/icmp",id:"tabIcmp"},{title:i.Locale.getSection("components.pages.firewall-rules").lmsg("title"),url:"/cp/firewall/rules",id:"tabRules"}]),[]),a=(0,s.useMemo)((()=>t.findIndex((({url:t})=>(0,l.matchPath)(t,e)))+1),[t,e]);return(0,s.jsx)(r.Tabs,{active:a,children:t.map((({url:e,...t})=>(0,s.jsx)(r.Tab,{component:n.default,to:e,...t},e)))})},p=e=>{const t=t=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c,{...t}),(0,s.jsx)(e,{...t})]});return t.displayName=`withFirewallTabs(${e.displayName||e.name||"Component"})`,t.WrappedComponent=e,t},m=c}}]);
//# sourceMappingURL=FirewallIcmpPage.js.map?023e96d854c3327b756d