D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
cp
/
public
/
javascript
/
components
/
pages
/
Filename :
FirewallGeneralPage.js
back
Copy
(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/FirewallGeneralPage"],{1411:(e,t,n)=>{"use strict";n.r(t),n.d(t,{SORT_ASC:()=>d,SORT_DESC:()=>u,default:()=>k});var i=n(285),a=n(596),s=n.n(a),r=n(286),o=n(89);const l=o.Locale.getTranslate("components.list"),c=o.Locale.getSection("components.list"),d="ASC",u="DESC",m="all",g={set(e,t){localStorage.setItem(e,JSON.stringify(t))},get(e){const t=localStorage.getItem(e);return JSON.parse(t)}},p=e=>`list-sort_${e}`,f=e=>`list-page_${e}`,h=({id:e,data:t,columns:n,itemsPerPage:a=25,itemsPerPageOptions:s=[10,25,100,m],sortColumn:o,sortDirection:u=d,searchField:h,locale:k={},emptyView:v,emptyFilteredView:S,toolbar:y,selection:P=[],onSelectionChange:w,searchBarInputProps:b,rowKey:x="key",useStorage:j=!0,...F})=>{const{sortColumn:C,sortDirection:T,setSortState:N}=((e,{sortColumn:t,sortDirection:n})=>{const[{sortColumn:a,sortDirection:s},r]=(0,i.useState)({sortColumn:g.get(p(e))?.sortColumn??t,sortDirection:g.get(p(e))?.sortDirection??n});return{sortColumn:a,sortDirection:s,setSortState:t=>{r((e=>({...e,...t}))),g.set(p(e),{...g.get(p(e)),...t})}}})(e,{sortColumn:o??n.find((({sortable:e})=>e))?.key,sortDirection:u}),{page:D,itemsPerPage:E,searchPattern:M,setPageState:O}=((e,{itemsPerPage:t},n=!0)=>{const a=n?{page:g.get(f(e))?.page,itemsPerPage:g.get(f(e))?.itemsPerPage,searchPattern:g.get(f(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&&g.set(f(e),{...g.get(f(e)),...t})}}})(e,{itemsPerPage:s.includes(a)?a:s[0]},j),L=(0,i.useMemo)((()=>M?S??(0,i.jsx)(r.ListEmptyView,{reason:"filtered",title:(0,i.jsx)(l,{content:"emptyViewFilteredTitle"}),description:(0,i.jsx)(l,{content:"emptyViewFilteredDescription"}),"data-testid":"list-empty-view-filtered"}):v??(0,i.jsx)(r.ListEmptyView,{title:(0,i.jsx)(l,{content:"emptyViewTitle"})})),[M,v,S]),R=(0,i.useMemo)((()=>n.map((({sortDataField:e,...t})=>t))),[n]),q=(0,i.useMemo)((()=>h&&M?t.filter((e=>(Array.isArray(h)?h:[h]).some((t=>e[t]&&String(e[t]).toLowerCase().includes(M.toLowerCase()))))):t),[t,M,h]),V=(0,i.useMemo)((()=>{if(!C)return q;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[...q].sort(((e,n)=>d===T?t(e,n):t(n,e)))}),[q,C,T,n]),A=(0,i.useMemo)((()=>{if(E===m)return V;const e=E*(D-1),t=e+E;return V.slice(e,t)}),[D,V,E]),B=(0,i.useCallback)((e=>{O({searchPattern:e}),e!==M&&O({page:1})}),[M]),I=(0,i.useCallback)((e=>{O({itemsPerPage:e});(e===m?1:Math.ceil(q.length/e))<D&&O({page:1})}),[q.length,D]);return(0,i.useEffect)((()=>{if("function"==typeof w&&P.length){const e=q.map((e=>{return t=e,"function"==typeof(n=x)?n(t):t[n];var t,n})).filter((e=>P.includes(e)));w(e)}}),[q]),(0,i.jsx)(r.List,{pagination:(0,i.jsx)(r.Pagination,{current:D,total:E===m?1:Math.ceil(q.length/E),onSelect:e=>O({page:e}),itemsPerPage:E,itemsPerPageOptions:s,onItemsPerPageChange:I}),toolbar:(y||h)&&(0,i.jsxs)(r.Toolbar,{children:[y,h&&(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:c.lmsg("searchPlaceholder"),"data-testid":"list-searchbar",value:M,...b??{}},onTyping:B})})]})]}),totalRows:q.length,sortColumn:C,sortDirection:T,onSortChange:N,columns:R,data:A,filtered:!!M,locale:{totalRows:({totalRows:e})=>c.formatMessage("recordsTotal",{total:e}),...k},emptyView:L,onSelectionChange:w,selection:P,rowKey:x,...F})};h.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 k=h},2477:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o});var i=n(286),a=n(89),s=n(285);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"})})]})}},2475:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>d});var i=n(596),a=n(286),s=n(89),r=n(1411),o=n(285);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},2474:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>P});var i=n(89),a=n(335),s=n(603),r=n(2475),o=n(2476),l=n(2477),c=n(1120),d=n(586),u=n(628),m=n(286),g=n(536),p=n(1263),f=n.n(p),h=n(2478),k=n.n(h),v=n(285);const S=i.Locale.getTranslate("components.pages.firewall-general"),y=c.gql` mutation ToggleFirewallStatus($enable: Boolean!) { toggleFirewall(input: { enable: $enable }) { query { server { firewall { isEnabled } } } } } `,P=(0,s.withPageLayout)((0,o.withFirewallTabs)((()=>{const{data:{server:{firewall:{isEnabled:e,interfaces:t}}}}=(0,d.useQuery)(f()),[n,{loading:i}]=(0,u.useMutation)(y,{variables:{enable:!e}}),[a,{loading:s}]=(0,u.useMutation)(k(),{variables:{mode:"DEFAULT"},onCompleted:()=>(0,g.addToast)({intent:"success",message:(0,v.jsx)(S,{content:"successDefault"})})}),[o,{loading:c}]=(0,u.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:c,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}}}))},2476:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>u,withFirewallTabs:()=>d});var i=n(285),a=n(580),s=n(581),r=n(286),o=n(89),l=n(646);const c=()=>{const{pathname:e}=(0,a.useLocation)(),t=(0,i.useMemo)((()=>[{title:o.Locale.getSection("components.pages.firewall-general").lmsg("title"),url:"/cp/firewall/general",id:"tabGeneral"},{title:o.Locale.getSection("components.pages.firewall-icmp").lmsg("title"),url:"/cp/firewall/icmp",id:"tabIcmp"},{title:o.Locale.getSection("components.pages.firewall-rules").lmsg("title"),url:"/cp/firewall/rules",id:"tabRules"}]),[]),n=(0,i.useMemo)((()=>t.findIndex((({url:t})=>(0,s.matchPath)(t,e)))+1),[t,e]);return(0,i.jsx)(r.Tabs,{active:n,children:t.map((({url:e,...t})=>(0,i.jsx)(r.Tab,{component:l.default,to:e,...t},e)))})},d=e=>{const t=t=>(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(c,{...t}),(0,i.jsx)(e,{...t})]});return t.displayName=`withFirewallTabs(${e.displayName||e.name||"Component"})`,t.WrappedComponent=e,t},u=c},2478: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:670}};t.loc.source={body:"mutation SetFirewallMode($mode: FirewallModeEnum!) {\n setFirewallMode(input: {mode: $mode }) {\n query {\n server {\n firewall {\n icmpRules {\n key\n isEnabled\n }\n rules {\n key\n name\n action\n port\n protocol\n profiles\n remoteAddresses\n isEnabled\n isReadonly\n }\n }\n }\n }\n }\n}\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?a472d63a74106eb5ec45