(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/FirewallGeneralPage"],{1425:(e,t,n)=>{"use strict";n.r(t),n.d(t,{SORT_ASC:()=>l,SORT_DESC:()=>c,default:()=>f});var i=n(295),a=n(667),s=n.n(a),r=n(296);const o=n(90).Locale.getSection("components.list"),l="ASC",c="DESC",d="all",u={set(e,t){localStorage.setItem(e,JSON.stringify(t))},get(e){const t=localStorage.getItem(e);return JSON.parse(t)}},m=e=>`list-sort_${e}`,g=e=>`list-page_${e}`,p=({id:e,data:t,columns:n,itemsPerPage:a=25,itemsPerPageOptions:s=[10,25,100,d],sortColumn:c,sortDirection:p=l,searchField:f,locale:h={},emptyView:k,emptyFilteredView:v,toolbar:S,selection:P=[],onSelectionChange:y,searchBarInputProps:b,rowKey:w="key",useStorage:x=!0,...j})=>{const{sortColumn:C,sortDirection:F,setSortState:T}=((e,{sortColumn:t,sortDirection:n})=>{const[{sortColumn:a,sortDirection:s},r]=(0,i.useState)({sortColumn:u.get(m(e))?.sortColumn??t,sortDirection:u.get(m(e))?.sortDirection??n});return{sortColumn:a,sortDirection:s,setSortState:t=>{r(e=>({...e,...t})),u.set(m(e),{...u.get(m(e)),...t})}}})(e,{sortColumn:c??n.find(({sortable:e})=>e)?.key,sortDirection:p}),{page:N,itemsPerPage:D,searchPattern:E,setPageState:M}=((e,{itemsPerPage:t},n=!0)=>{const a=n?{page:u.get(g(e))?.page,itemsPerPage:u.get(g(e))?.itemsPerPage,searchPattern:u.get(g(e))?.searchPattern}:{},[{page:s,itemsPerPage:r,searchPattern:o},l]=(0,i.useState)({page:a.page??1,itemsPerPage:a.itemsPerPage??t,searchPattern:a.searchPattern??""});return{page:s,itemsPerPage:r,searchPattern:o,setPageState:t=>{l(e=>({...e,...t})),n&&u.set(g(e),{...u.get(g(e)),...t})}}})(e,{itemsPerPage:s.includes(a)?a:s[0]},x),O=(0,i.useMemo)(()=>E?v??(0,i.jsx)(r.ListEmptyView,{reason:"filtered","data-testid":"list-empty-view-filtered"}):k??(0,i.jsx)(r.ListEmptyView,{}),[E,k,v]),R=(0,i.useMemo)(()=>n.map(({sortDataField:e,...t})=>t),[n]),L=(0,i.useMemo)(()=>f&&E?t.filter(e=>(Array.isArray(f)?f:[f]).some(t=>e[t]&&String(e[t]).toLowerCase().includes(E.toLowerCase()))):t,[t,E,f]),q=(0,i.useMemo)(()=>{if(!C)return L;const e=n.find(({key:e})=>e===C)?.sortDataField??C,t=n.find(({key:e})=>e===C)?.sort??((t,n)=>t[e]<n[e]?-1:t[e]>n[e]?1:0);return[...L].sort((e,n)=>l===F?t(e,n):t(n,e))},[L,C,F,n]),V=(0,i.useMemo)(()=>{if(D===d)return q;const e=D*(N-1),t=e+D;return q.slice(e,t)},[N,q,D]),A=(0,i.useCallback)(e=>{M({searchPattern:e}),e!==E&&M({page:1})},[E]),B=(0,i.useCallback)(e=>{M({itemsPerPage:e});(e===d?1:Math.ceil(L.length/e))<N&&M({page:1})},[L.length,N]);return(0,i.useEffect)(()=>{if("function"==typeof y&&P.length){const e=L.map(e=>{return t=e,"function"==typeof(n=w)?n(t):t[n];var t,n}).filter(e=>P.includes(e));y(e)}},[L]),(0,i.jsx)(r.List,{pagination:(0,i.jsx)(r.Pagination,{current:N,total:D===d?1:Math.ceil(L.length/D),onSelect:e=>M({page:e}),itemsPerPage:D,itemsPerPageOptions:s,onItemsPerPageChange:B}),toolbar:(S||f)&&(0,i.jsxs)(r.Toolbar,{children:[S,f&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.ToolbarExpander,{}),(0,i.jsx)(r.ToolbarGroup,{title:"",children:(0,i.jsx)(r.SearchBar,{inputProps:{placeholder:o.lmsg("searchPlaceholder"),"data-testid":"list-searchbar",value:E,...b??{}},onTyping:A})})]})]}),totalRows:L.length,sortColumn:C,sortDirection:F,onSortChange:T,columns:R,data:V,filtered:!!E,locale:{totalRows:({totalRows:e})=>o.formatMessage("recordsTotal",{total:e}),...h},emptyView:O,onSelectionChange:y,selection:P,rowKey:w,...j})};p.propTypes={id:s().string.isRequired,data:s().array.isRequired,columns:s().array.isRequired,itemsPerPage:s().number,itemsPerPageOptions:s().array,sortColumn:s().string,sortDirection:s().string,searchField:s().oneOfType([s().string,s().arrayOf(s().string.isRequired)]),locale:s().object,emptyView:s().node,emptyFilteredView:s().node,toolbar:s().node,onSelectionChange:s().func,selection:s().array,rowKey:s().oneOfType([s().string,s().func]),searchBarInputProps:s().object,useStorage:s().bool};const f=p},2502:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>y});var i=n(90),a=n(345),s=n(674),r=n(2503),o=n(2504),l=n(2505),c=n(695),d=n(619),u=n(582),m=n(296),g=n(545),p=n(647),f=n.n(p),h=n(2506),k=n.n(h),v=n(295);const S=i.Locale.getTranslate("components.pages.firewall-general"),P=u.gql`
    mutation ToggleFirewallStatus($enable: Boolean!) {
        toggleFirewall(input: { enable: $enable }) {
            query {
                server {
                    firewall {
                        isEnabled
                    }
                }
            }
        }
    }
`,y=(0,s.withPageLayout)((0,o.withFirewallTabs)(()=>{const{data:{server:{firewall:{isEnabled:e,interfaces:t}}}}=(0,d.useQuery)(f()),[n,{loading:i}]=(0,c.useMutation)(P,{variables:{enable:!e}}),[a,{loading:s}]=(0,c.useMutation)(k(),{variables:{mode:"DEFAULT"},onCompleted:()=>(0,g.addToast)({intent:"success",message:(0,v.jsx)(S,{content:"successDefault"})})}),[o,{loading:u}]=(0,c.useMutation)(k(),{variables:{mode:"PANIC"},onCompleted:()=>(0,g.addToast)({intent:"success",message:(0,v.jsx)(S,{content:"successPanic"})})}),p=async e=>{try{await e()}catch(e){(0,g.addToast)({intent:"danger",message:e.message})}};return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(m.StatusMessage,{intent:"success",children:(0,v.jsx)(S,{content:"info"})}),(0,v.jsxs)(m.Section,{title:"",children:[(0,v.jsx)("p",{children:(0,v.jsx)(m.Switch,{id:"toggleStatus",onChange:()=>p(n),loading:i,checked:e,children:(0,v.jsx)(S,{content:"toggleStatus"})})}),(0,v.jsx)(m.Toolbar,{children:(0,v.jsxs)(m.ToolbarGroup,{title:"",children:[(0,v.jsx)(l.default,{id:"buttonDefault",confirmationText:(0,v.jsx)(S,{content:"confirmationDefault"}),onClick:()=>p(a),isProcessing:s,children:(0,v.jsx)(S,{content:"buttonDefault"})}),(0,v.jsx)(l.default,{id:"buttonPanic",confirmationText:(0,v.jsx)(S,{content:"confirmationPanic"}),onClick:()=>p(o),isProcessing:u,isCritical:!0,children:(0,v.jsx)(S,{content:"buttonPanic"})})]})})]}),(0,v.jsx)(m.Section,{title:(0,v.jsx)(S,{content:"interfaces"}),children:(0,v.jsx)(r.default,{interfaces:t})})]})}),()=>{const{showFrames:e,pageHeader:t,pageSidebar:n}=(0,a.default)();return{showFrames:e,pageHeader:{...t,helpMenu:{...t.helpMenu,helpContext:"firewall_main"}},pageSidebar:n,pageContentHeader:{breadcrumbs:[n.isPowerUserPanel?null:{title:i.Locale.getSection("components.pages.home").lmsg("title"),href:"/admin/home"},{title:i.Locale.getSection("admin.controllers.server.tools").lmsg("title"),href:"/admin/server/tools"},{title:i.Locale.getSection("components.pages.firewall").lmsg("title"),href:"/cp/firewall"},{title:i.Locale.getSection("components.pages.firewall-general").lmsg("title"),href:"/cp/firewall/general"}].filter(Boolean),tabs:[],tabsHasRootPage:!0}}})},2503:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>d});var i=n(667),a=n(296),s=n(90),r=n(1425),o=n(295);const l=s.Locale.getTranslate("admin.components.lists.firewallinterfaces"),c=({interfaces:e})=>{const t=(0,o.useMemo)(()=>["name","type"],[]);return(0,o.jsx)(r.default,{id:"firewall-interfaces-list",columns:[{key:"name",title:(0,o.jsx)(l,{content:"name"}),type:"title",sortable:!0},{key:"type",title:(0,o.jsx)(l,{content:"type"}),sortable:!0},{key:"connection",title:(0,o.jsx)(l,{content:"connection"}),sortable:!0,render:({isConnected:e})=>(0,o.jsx)(a.Tooltip,{title:(0,o.jsx)(l,{content:e?"connectionOn":"connectionOff"}),children:(0,o.jsx)(a.Status,{intent:e?"success":"inactive",children:(0,o.jsx)(l,{content:e?"statusOn":"statusOff"})})})},{key:"firewall",title:(0,o.jsx)(l,{content:"firewall"}),sortable:!0,render:({isEnabled:e})=>(0,o.jsx)(a.Tooltip,{title:(0,o.jsx)(l,{content:e?"firewallOn":"firewallOff"}),children:(0,o.jsx)(a.Status,{intent:e?"success":"inactive",children:(0,o.jsx)(l,{content:e?"statusOn":"statusOff"})})})}],data:e,searchField:t,sortColumn:"name"})};c.propTypes={interfaces:i.PropTypes.arrayOf(i.PropTypes.shape({key:i.PropTypes.string.isRequired,name:i.PropTypes.string.isRequired,type:i.PropTypes.string.isRequired,isEnabled:i.PropTypes.bool.isRequired,isConnected:i.PropTypes.bool.isRequired})).isRequired};const d=c},2504:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>d,withFirewallTabs:()=>c});var i=n(295),a=n(598),s=n(296),r=n(90),o=n(717);const l=()=>{const{pathname:e}=(0,a.useLocation)(),t=(0,i.useMemo)(()=>[{title:r.Locale.getSection("components.pages.firewall-general").lmsg("title"),url:"/cp/firewall/general",id:"tabGeneral"},{title:r.Locale.getSection("components.pages.firewall-icmp").lmsg("title"),url:"/cp/firewall/icmp",id:"tabIcmp"},{title:r.Locale.getSection("components.pages.firewall-rules").lmsg("title"),url:"/cp/firewall/rules",id:"tabRules"}],[]),n=(0,i.useMemo)(()=>t.findIndex(({url:t})=>(0,a.matchPath)(t,e))+1,[t,e]);return(0,i.jsx)(s.Tabs,{active:n,children:t.map(({url:e,...t})=>(0,i.jsx)(s.Tab,{component:o.default,to:e,...t},e))})},c=e=>{const t=t=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l,{...t}),(0,i.jsx)(e,{...t})]});return t.displayName=`withFirewallTabs(${e.displayName||e.name||"Component"})`,t.WrappedComponent=e,t},d=l},2505:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var i=n(296),a=n(90),s=n(295);const r=a.Locale.getTranslate("components.buttons"),o=({children:e,confirmationText:t,onClick:n,isCritical:a=!1,isProcessing:o=!1,target:l,...c})=>{const[d,u]=(0,s.useState)(!1),m=(0,s.jsx)(i.Button,{onClick:()=>u(!0),state:o?"loading":void 0,...c,children:o?(0,s.jsx)(r,{content:"wait"}):e});return(0,s.jsxs)(i.Popover,{target:l?(0,s.cloneElement)(l,{onClick:()=>u(!0)}):m,placement:"top",visible:d,onClose:()=>u(!1),children:[(0,s.jsx)(i.Paragraph,{children:t}),(0,s.jsx)(i.Button,{id:"buttonYes",intent:a?"danger":"primary",onClick:()=>{u(!1),n()},children:(0,s.jsx)(r,{content:"yes"})}),"  ",(0,s.jsx)(i.Button,{id:"buttonCancel",onClick:()=>u(!1),ghost:!0,children:(0,s.jsx)(r,{content:"cancel"})})]})}},2506:e=>{var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SetFirewallMode"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"mode"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"FirewallModeEnum"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"setFirewallMode"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"mode"},value:{kind:"Variable",name:{kind:"Name",value:"mode"}}}]}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"query"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"server"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"firewall"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"icmpRules"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"key"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isEnabled"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"rules"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"key"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"action"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"port"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"protocol"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"profiles"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"remoteAddresses"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isEnabled"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isReadonly"},arguments:[],directives:[]}]}}]}}]}}]}}]}}]}}],loc:{start:0,end:695}};t.loc.source={body:"mutation SetFirewallMode($mode: FirewallModeEnum!) {\r\n    setFirewallMode(input: {mode: $mode }) {\r\n        query {\r\n            server {\r\n                firewall {\r\n                    icmpRules {\r\n                        key\r\n                        isEnabled\r\n                    }\r\n                    rules {\r\n                        key\r\n                        name\r\n                        action\r\n                        port\r\n                        protocol\r\n                        profiles\r\n                        remoteAddresses\r\n                        isEnabled\r\n                        isReadonly\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function n(e,t){if("FragmentSpread"===e.kind)t.add(e.name.value);else if("VariableDefinition"===e.kind){var i=e.type;"NamedType"===i.kind&&t.add(i.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(e){n(e,t)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(e){n(e,t)}),e.definitions&&e.definitions.forEach(function(e){n(e,t)})}var i={};function a(e,t){for(var n=0;n<e.definitions.length;n++){var i=e.definitions[n];if(i.name&&i.name.value==t)return i}}t.definitions.forEach(function(e){if(e.name){var t=new Set;n(e,t),i[e.name.value]=t}}),e.exports=t,e.exports.SetFirewallMode=function(e,t){var n={kind:e.kind,definitions:[a(e,t)]};e.hasOwnProperty("loc")&&(n.loc=e.loc);var s=i[t]||new Set,r=new Set,o=new Set;for(s.forEach(function(e){o.add(e)});o.size>0;){var l=o;o=new Set,l.forEach(function(e){r.has(e)||(r.add(e),(i[e]||new Set).forEach(function(e){o.add(e)}))})}return r.forEach(function(t){var i=a(e,t);i&&n.definitions.push(i)}),n}(t,"SetFirewallMode")}}]);
//# sourceMappingURL=FirewallGeneralPage.js.map?f7240b40d0fca152fdd7