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