"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/PanelNotificationsSettings"],{1642:(e,t,n)=>{n.r(t),n.d(t,{SORT_ASC:()=>d,SORT_DESC:()=>m,default:()=>g});var o=n(236),i=n(238),a=n.n(i),s=n(237),l=n(87);const r=l.Locale.getTranslate("components.list"),c=l.Locale.getSection("components.list"),d="ASC",m="DESC",u="all",p=({data:e,columns:t,itemsPerPage:n,itemsPerPageOptions:i,sortColumn:a,sortDirection:l,searchField:m,locale:p,emptyView:g,emptyFilteredView:f,toolbar:h,selection:y,onSelectionChange:P,searchBarInputProps:x,rowKey:b,...S})=>{const[j,T]=(0,o.useState)(1),[w,C]=(0,o.useState)(a??t.find((({sortable:e})=>e))?.key),[v,F]=(0,o.useState)(l),[L,k]=(0,o.useState)(i.includes(n)?n:i[0]),[N,V]=(0,o.useState)(""),D=(0,o.useMemo)((()=>N?f??(0,o.jsx)(s.ListEmptyView,{reason:"filtered",title:(0,o.jsx)(r,{content:"emptyViewFilteredTitle"}),description:(0,o.jsx)(r,{content:"emptyViewFilteredDescription"})}):g??(0,o.jsx)(s.ListEmptyView,{title:(0,o.jsx)(r,{content:"emptyViewTitle"})})),[N,g,f]),M=(0,o.useMemo)((()=>m?e.filter((e=>(Array.isArray(m)?m:[m]).some((t=>e[t]&&String(e[t]).toLowerCase().includes(N.toLowerCase()))))):e),[e,N,m]),A=(0,o.useMemo)((()=>{if(!w)return M;const e=t.find((({key:e})=>e===w))?.sortDataField??w,n=t.find((({key:e})=>e===w))?.sort??((t,n)=>t[e]<n[e]?-1:t[e]>n[e]?1:0);return[...M].sort(((e,t)=>d===v?n(e,t):n(t,e)))}),[M,w,v,t]),R=(0,o.useMemo)((()=>{if(L===u)return A;const e=L*(j-1),t=e+L;return A.slice(e,t)}),[j,A,L]),q=(0,o.useCallback)((e=>{V(e),e!==N&&T(1)}),[N]),O=(0,o.useCallback)((e=>{k(e);(e===u?1:Math.ceil(M.length/e))<j&&T(1)}),[M.length,j]);return(0,o.useEffect)((()=>{if("function"==typeof P&&y.length){const e=M.map((e=>{return t=e,"function"==typeof(n=b)?n(t):t[n];var t,n})).filter((e=>y.includes(e)));P(e)}}),[M]),(0,o.jsx)(s.List,{pagination:(0,o.jsx)(s.Pagination,{current:j,total:L===u?1:Math.ceil(M.length/L),onSelect:e=>T(e),itemsPerPage:L,itemsPerPageOptions:i,onItemsPerPageChange:O}),toolbar:(h||m)&&(0,o.jsxs)(s.Toolbar,{children:[h,m&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(s.ToolbarExpander,{}),(0,o.jsx)(s.ToolbarGroup,{title:"",children:(0,o.jsx)(s.SearchBar,{inputProps:{placeholder:c.lmsg("searchPlaceholder"),"data-testid":"list-searchbar",...x??{}},onTyping:q})})]})]}),totalRows:M.length,sortColumn:w,sortDirection:v,onSortChange:({sortColumn:e,sortDirection:t})=>{C(e),F(t)},columns:t,data:R,filtered:!!N,locale:{totalRows:({totalRows:e})=>c.formatMessage("recordsTotal",{total:e}),...p},emptyView:D,onSelectionChange:P,selection:y,rowKey:b,...S})};p.propTypes={data:a().array.isRequired,columns:a().array.isRequired,itemsPerPage:a().number,itemsPerPageOptions:a().array,sortColumn:a().string,sortDirection:a().string,searchField:a().oneOfType([a().string,a().arrayOf(a().string.isRequired)]),locale:a().object,emptyView:a().node,emptyFilteredView:a().node,toolbar:a().node,onSelectionChange:a().func,selection:a().array,rowKey:a().oneOfType([a().string,a().func]),searchBarInputProps:a().object},p.defaultProps={itemsPerPage:25,itemsPerPageOptions:[10,25,100,u],sortColumn:void 0,sortDirection:d,searchField:void 0,locale:{},emptyView:void 0,emptyFilteredView:void 0,toolbar:void 0,onSelectionChange:void 0,selection:[],searchBarInputProps:void 0,rowKey:"key"};const g=p},1727:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c,withNotificationTabs:()=>r});var o=n(237),i=n(87),a=n(722),s=n(236);const l=()=>(0,s.jsxs)(o.Tabs,{active:2,children:[(0,s.jsx)(o.Tab,{title:i.Locale.getSection("admin.controllers.notifications.email-settings").lmsg("title"),component:a.default,to:"/admin/notifications/email-settings/"}),(0,s.jsx)(o.Tab,{title:i.Locale.getSection("admin.controllers.notifications.panel-settings").lmsg("title"),component:a.default,to:"/admin/notifications/panel-settings/"})]}),r=e=>{const t=t=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(l,{}),(0,s.jsx)(e,{...t})]});return t.displayName=`withNotificationTabs(${e.displayName||e.name||"Component"})`,t.WrappedComponent=e,t},c=r},1726:(e,t,n)=>{n.r(t),n.d(t,{default:()=>T});var o=n(692),i=n(87),a=n(282),s=n(1642),l=n(237),r=n(819),c=n(1727),d=n(236),m=n(443),u=n(709),p=n(722),g=n(238),f=n(679),h=n(684);const y=i.Locale.getTranslate("admin.controllers.notifications.panel-notifications-toggle"),P=i.Locale.getTranslate("admin.controllers.notifications.template-settings-list"),x=i.Locale.getTranslate("admin.controllers.notifications.template-settings-form"),b=m.gql`
    mutation UpdatePanelNotificationTemplate($input: UpdateNotificationPanelTemplateInput!){
        updateNotificationPanelTemplate (input: $input){
            query {
                notification {
                    panel {
                        templates {
                            code
                            context
                            title
                            sendToAdmin
                        }
                    }
                }
            }
        }
    }
`,S=m.gql`
    mutation updateNotificationPanelSettingsStoragePeriod ($input: UpdateNotificationPanelSettingsInput!) {
        updateNotificationPanelSettings (input: $input) {
            query {
                notification {
                    panel {
                        settings {
                            storagePeriod
                        }
                    }
                }
            }
        }
    }
`,j=({notification:e})=>{const{panel:{settings:{storagePeriod:t},templates:n}}=e,[o]=(0,d.useState)({storagePeriod:t}),[i]=(0,u.useMutation)(b),[a]=(0,u.useMutation)(S),[c,m]=(0,d.useState)(n.map((e=>({...e,loading:!1})))),g=(0,f.useNavigate)(),j="/admin/server/tools",T=(e,t)=>{m((n=>n.map((n=>(n.code===e&&(n={...n,...t}),n)))))};return(0,d.jsxs)(r.default,{applyButton:!1,values:o,mutation:a,onSuccess:()=>{g(j)},cancelButton:{component:p.default,to:j},children:[(0,d.jsx)(P,{content:"hint"}),(0,d.jsx)(s.default,{data:c,columns:[{key:"title",sortable:!0,title:(0,d.jsx)(P,{content:"name"})},{key:"context",sortable:!0,title:(0,d.jsx)(P,{content:"context"})},{key:"sendToAdmin",title:(0,d.jsx)(P,{content:"sendToAdmin"}),align:"right",render:({sendToAdmin:e,code:t,loading:n,title:o})=>(0,d.jsx)(l.Switch,{checked:e,onChange:e=>(async(e,t,n)=>{T(e,{loading:!0});try{await i({variables:{input:{code:e,sendToAdmin:n}}}),n?(0,h.addToast)({intent:"success",message:(0,d.jsx)(y,{content:"successfullyEnabled",params:{title:t}})}):(0,h.addToast)({intent:"success",message:(0,d.jsx)(y,{content:"successfullyDisabled",params:{title:t}})}),T(e,{sendToAdmin:n})}catch({message:e}){(0,h.addToast)({intent:"danger",message:e})}finally{T(e,{loading:!1})}})(t,o,e),loading:n},t)}],sortColumn:"title",searchField:["title","context"]}),(0,d.jsx)(l.Section,{children:(0,d.jsx)(l.FormField,{name:"storagePeriod",label:(0,d.jsx)(x,{content:"storagePeriod"}),required:!0,children:({getValue:e,setValue:t,isDisabled:n})=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l.InputNumber,{value:e(),min:1,max:360,onChange:t,disabled:n()})," ",(0,d.jsx)(x,{content:"days"})]})})})]})};j.propTypes={notification:g.PropTypes.object.isRequired};const T=(0,o.withPageLayout)((0,c.withNotificationTabs)(j),(()=>{const{showFrames:e,pageHeader:t,pageSidebar:n}=(0,a.default)();return{showFrames:e,pageHeader:{...t,helpMenu:{...t.helpMenu,helpContext:"mail"}},pageSidebar:n,pageContentHeader:{breadcrumbs:[n.isPowerUserPanel?null:{title:i.Locale.getSection("admin.controllers.home.admin").lmsg("title"),href:"/admin/home"},{title:i.Locale.getSection("admin.controllers.server.tools").lmsg("title"),href:"/admin/server/tools"},{title:i.Locale.getSection("admin.controllers.notifications.index").lmsg("title"),href:"/admin/notifications"},{title:i.Locale.getSection("admin.controllers.notifications.panel-settings").lmsg("title"),href:"/cp/notifications/panel-settings"}].filter(Boolean),tabs:[],tabsHasRootPage:!0}}}))},1725:(e,t,n)=>{n.r(t),n.d(t,{default:()=>o.default});var o=n(1726)}}]);
//# sourceMappingURL=PanelNotificationsSettings.js.map?e0386b59c5b58bb76a96