Plugin Directory

Changeset 3131144


Ignore:
Timestamp:
08/05/2024 03:14:30 PM (19 months ago)
Author:
notificationmaster
Message:

version 1.1.4

Location:
notification-master
Files:
263 added
13 edited

Legend:

Unmodified
Added
Removed
  • notification-master/trunk/dist/index.asset.php

    r3125253 r3131144  
    1 <?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-url'), 'version' => '913606e8cec251466c21');
     1<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-url'), 'version' => 'a6c8c1ed030522709f1f');
  • notification-master/trunk/dist/index.js

    r3125253 r3131144  
    99/* translators: %s: Number of days */
    1010/* translators: %s: Number of days */
    11 (0,c.sprintf)((0,c.__)("All debug logs older than {%s} days will be deleted.","notification-master"),e.delete_logs_every)})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(c$,{type:"number",value:e.delete_logs_every,onChange:e=>{n("delete_logs_every",e.target.value)}})})]}),(0,s.jsx)("div",{className:"notification-master__settings--header",children:(0,s.jsx)("h3",{className:"notification-master-heading",children:(0,c.__)("Triggers","notification-master")})}),!LS.isPro&&(0,s.jsx)(qw.Ribbon,{text:(0,c.__)("Pro","notification-master"),children:(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),onClick:()=>r(!0),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("WooCommerce","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the WooCommerce product, review, or order changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:!1,onChange:()=>{r(!0)}})})]})}),LS.isPro&&(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("WooCommerce","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the WooCommerce product, review, or order changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.woocommerce_change_trigger||!0,onChange:e=>{n("woocommerce_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item",{"notification-master__settings--item--has-subitem":e.post_status_change_trigger}),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Post status change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the post status changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.post_status_change_trigger,onChange:e=>{n("post_status_change_trigger",e)}})})]}),e.post_status_change_trigger&&(0,s.jsxs)("div",{className:"notification-master__settings--item notification-master__settings--item--block",children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Post types","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("Select the post types for which you want to send notifications when the post status changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--select",children:(0,s.jsx)($j,{mode:"multiple",size:"large",placeholder:(0,c.__)("Select post types","notification-master"),options:h,value:e.post_types,onChange:e=>{n("post_types",e)},style:{width:"100%"}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item",{"notification-master__settings--item--has-subitem":e.taxonomy_term_change_trigger}),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Taxonomy term change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the taxonomy term changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.taxonomy_term_change_trigger,onChange:e=>{n("taxonomy_term_change_trigger",e)}})})]}),e.taxonomy_term_change_trigger&&(0,s.jsxs)("div",{className:"notification-master__settings--item notification-master__settings--item--block",children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Taxonomies","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("Select the taxonomies for which you want to send notifications when the taxonomy term changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--select",children:(0,s.jsx)($j,{mode:"multiple",size:"large",placeholder:(0,c.__)("Select taxonomies","notification-master"),options:f,value:e.taxonomies,onChange:e=>{n("taxonomies",e)},style:{width:"100%"}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item",{"notification-master__settings--item--has-subitem":e.comment_change_trigger}),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Comment change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the comment status changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.comment_change_trigger,onChange:e=>{n("comment_change_trigger",e)}})})]}),e.comment_change_trigger&&(0,s.jsxs)("div",{className:"notification-master__settings--item notification-master__settings--item--block",children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Comment types","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("Select the comment types for which you want to send notifications when the comment status changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--select",children:(0,s.jsx)($j,{mode:"multiple",size:"large",placeholder:(0,c.__)("Select comment types","notification-master"),options:p,value:e.comment_types,onChange:e=>{n("comment_types",e)},style:{width:"100%"}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Media change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the media changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.media_change_trigger,onChange:e=>{n("media_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("User change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the user changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.user_change_trigger,onChange:e=>{n("user_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Theme change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the theme changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.theme_change_trigger,onChange:e=>{n("theme_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Plugin change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the plugin changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.plugin_change_trigger,onChange:e=>{n("plugin_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsx)("div",{className:"notification-master__settings--item--title",children:(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Privacy","notification-master")})}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.privacy_trigger,onChange:e=>{n("privacy_trigger",e)}})})]}),(0,s.jsx)("div",{className:"notification-master__settings--footer-placeholder"}),(0,s.jsx)("div",{className:"notification-master__settings--footer",ref:i,children:(0,s.jsx)(Eu,{type:"primary",size:"large",onClick:async()=>{if(!a){u(!0);try{await zT()({path:"/ntfm/v1/settings",method:"POST",data:{settings:e}}),o({type:"success",message:(0,c.__)("Settings saved successfully","notification-master")}),window.location.reload()}catch(e){o({type:"error",message:(0,c.__)("Failed to save settings","notification-master")})}finally{u(!1)}}},loading:a,children:(0,c.__)("Save","notification-master")})})]})]})}},{path:"/notification-log",slug:"notification-log",title:(0,c.__)("Notification Log","notification-master"),component:()=>{const[e,t]=(0,l.useState)(!0),[n,o]=(0,l.useState)([]),[r,i]=(0,l.useState)(10),[a,u]=(0,l.useState)(1),[h,f]=(0,l.useState)(null),[p,m]=(0,l.useState)(!1),[g,v]=(0,l.useState)(0),{addNotice:b}=(0,d.useDispatch)("notification-master/core");if(lz((0,c.__)("Notification Log","notification-master")),(0,l.useEffect)((()=>{(async()=>{t(!0);try{const e=await zT()({path:(0,pJ.addQueryArgs)("/ntfm/v1/notification-logs",{per_page:r,page:a})});e&&(o((0,Gf.isArray)(e?.logs)?e.logs:[]),v(e?.count||0))}catch(e){b({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}t(!1)})()}),[r,a]),e&&(0,Gf.isEmpty)(n))return(0,s.jsx)("div",{className:"notification-master__log--loading",children:(0,s.jsx)(az,{color:"var(--notification-master-color-primary)"})});const y=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(t){return e}return(0,Gf.isObject)(e)?x(e):e},x=e=>{const t={};for(const n in e)"notification_name"!==n&&"trigger"!==n&&"trigger_name"!==n&&(0,Gf.set)(t,n,y(e[n]));return t};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("h2",{className:"notification-master-heading",children:[(0,s.jsx)(zN,{component:VJ,width:20,height:20}),(0,c.__)("Notification Log","notification-master")]}),(0,s.jsx)("div",{className:"notification-master__log",children:(0,Gf.isEmpty)(n)?(0,s.jsx)(Bk.Title,{level:5,style:{textAlign:"center"},children:(0,c.__)("No logs found.","notification-master")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tT,{align:"center",style:{marginBottom:"1rem"},children:(0,s.jsx)($z,{title:(0,c.__)("Are you sure?","notification-master"),onConfirm:async()=>{if(!p){m(!0);try{await zT()({path:"/ntfm/v1/notification-logs",method:"DELETE"}),o([])}catch(e){b({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}m(!1)}},okText:(0,c.__)("Yes","notification-master"),cancelText:(0,c.__)("No","notification-master"),children:(0,s.jsx)(Eu,{type:"primary",danger:!0,children:(0,c.__)("Delete All","notification-master")})})}),(0,s.jsx)(HX,{columns:WJ,dataSource:n.map((e=>({...e,log_status:(0,s.jsx)(Bk.Text,{type:"error"===e.status?"danger":"success",children:e.status}),notification:(0,s.jsx)(Bk.Text,{children:e.content.notification_name}),date:new Date(e.date).toLocaleString(),view:(0,s.jsx)(gS,{title:(0,c.__)("View","notification-master"),children:(0,s.jsx)(Eu,{type:"primary",shape:"circle",icon:(0,s.jsx)(Qk,{}),onClick:()=>f(e)})})}))),pagination:{total:g,showSizeChanger:!0,showQuickJumper:!0,showTotal:e=>`${(0,c.__)("Total","notification-master")}: ${e}`,onChange:(e,t)=>{u(e),i(t)}},loading:e,rowKey:"id",style:{width:"100%"}})]})}),(0,s.jsx)(Xf,{title:(0,c.__)("Log Details","notification-master"),open:!!h,onCancel:()=>f(null),footer:null,width:800,children:(0,s.jsxs)("div",{className:"notification-master__log--view",children:[(0,s.jsxs)(tT,{gap:10,children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Name","notification-master")," : "]}),(0,s.jsx)(Bk.Text,{children:h?.content.notification_name})]}),(0,s.jsxs)(tT,{gap:10,style:{marginTop:"1rem"},children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Trigger","notification-master")," : "]}),(0,s.jsxs)(Bk.Text,{children:[h?.content.trigger_name," ",`"${h?.content.trigger}"`]})]}),(0,s.jsxs)(tT,{gap:10,style:{marginTop:"1rem"},children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Integration","notification-master")," : "]}),(0,s.jsx)(Bk.Text,{children:h?.integration})]}),(0,s.jsxs)(tT,{gap:10,style:{marginTop:"1rem"},children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Status","notification-master")," : "]}),(0,s.jsx)(Bk.Text,{type:"error"===h?.status?"danger":"success",children:h?.status})]}),(0,s.jsxs)(tT,{gap:10,style:{marginTop:"1rem"},children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Date","notification-master")," : "]}),(0,s.jsx)(Bk.Text,{children:h?.date})]}),(0,s.jsxs)(tT,{style:{marginTop:"1rem",flexDirection:"column"},children:[(0,s.jsx)(Bk.Text,{strong:!0,children:(0,c.__)("Details","notification-master")}),(0,s.jsx)("pre",{style:{overflowX:"auto"},children:JSON.stringify(x(h?.content),null,2)})]})]})})]})}},{path:"/debug-log",slug:"debug-log",title:(0,c.__)("Debug Log","notification-master"),component:()=>{const[e,t]=(0,l.useState)(!0),[n,o]=(0,l.useState)([]),[r,i]=(0,l.useState)(10),[a,u]=(0,l.useState)(1),[h,f]=(0,l.useState)(null),[p,m]=(0,l.useState)(!1),[g,v]=(0,l.useState)(0),[b,y]=(0,l.useState)(!1),{addNotice:x}=(0,d.useDispatch)("notification-master/core");return lz((0,c.__)("Debug Log","notification-master")),(0,l.useEffect)((()=>{(async()=>{try{const e=await zT()({path:(0,pJ.addQueryArgs)("/ntfm/v1/logs",{per_page:r,page:a})});e?(o((0,Gf.isArray)(e?.logs)?e.logs:[]),v(e?.count||0)):x({type:"error",message:(0,c.__)("An error occurred","notification-master")})}catch(e){x({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}t(!1)})()}),[r,a]),e?(0,s.jsx)("div",{className:"notification-master__log--loading",children:(0,s.jsx)(az,{color:"var(--notification-master-color-primary)"})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("h2",{className:"notification-master-heading",children:[(0,s.jsx)(zN,{component:VJ,width:20,height:20}),(0,c.__)("Debug Log","notification-master")]}),(0,s.jsx)("div",{className:"notification-master__log",children:(0,Gf.isEmpty)(n)?(0,s.jsx)(Bk.Title,{level:5,style:{textAlign:"center"},children:(0,c.__)("No logs found.","notification-master")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tT,{align:"center",style:{marginBottom:"1rem"},children:[(0,s.jsx)(Eu,{type:"primary",onClick:async()=>{if(b)return;y(!0);const e=await zT()({path:"/ntfm/v1/logs/export",method:"GET",parse:!1});if(e){const t=await e.blob(),n=window.URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download="logs.json",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n)}y(!1)},style:{marginRight:"1rem"},loading:b,children:(0,c.__)("Export All","notification-master")}),(0,s.jsx)($z,{title:(0,c.__)("Are you sure?","notification-master"),onConfirm:async()=>{if(!p){m(!0);try{await zT()({path:"/ntfm/v1/logs",method:"DELETE"}),o([])}catch(e){x({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}m(!1)}},okText:(0,c.__)("Yes","notification-master"),cancelText:(0,c.__)("No","notification-master"),children:(0,s.jsx)(Eu,{type:"primary",danger:!0,children:(0,c.__)("Delete All","notification-master")})})]}),(0,s.jsx)(HX,{columns:qJ,dataSource:n.map((e=>({...e,log_type:(0,s.jsx)(Bk.Text,{type:"error"===e.type?"danger":"debug"===e.type?"warning":"secondary",children:e.type.toUpperCase()}),date:new Date(e.date).toLocaleString(),view:(0,s.jsx)(gS,{title:(0,c.__)("View","notification-master"),children:(0,s.jsx)(Eu,{type:"primary",shape:"circle",icon:(0,s.jsx)(Qk,{}),onClick:()=>f(e.id)})})}))),pagination:{total:g,showSizeChanger:!0,showQuickJumper:!0,showTotal:e=>`${(0,c.__)("Total","notification-master")}: ${e}`,onChange:(e,t)=>{u(e),i(t)}},rowKey:"id",style:{width:"100%"}})]})}),(0,s.jsx)(Xf,{title:(0,c.__)("Log Details","notification-master"),open:!!h,onCancel:()=>f(null),footer:null,width:600,children:(0,s.jsx)("pre",{style:{maxHeight:"400px",overflowX:"auto"},children:(e=>{const t={};for(const n in e)if("notification_name"!==n&&"trigger"!==n&&"trigger_name"!==n)if("string"==typeof e[n])try{(0,Gf.set)(t,n,JSON.parse(e[n]))}catch(o){(0,Gf.set)(t,n,e[n])}else(0,Gf.set)(t,n,e[n]);return JSON.stringify(t,null,2)})(n.find((e=>e.id===h))?.content)})})]})}}]),UJ=()=>{const{notices:e}=(0,d.useSelect)((e=>({notices:e("notification-master/core").getNotices()}))),{deleteNotice:t}=(0,d.useDispatch)("notification-master/core"),[n,o]=Jl.useNotification();return(0,l.useEffect)((()=>{(0,Gf.size)(e)&&(0,Gf.map)(e,((e,o)=>{const{message:r,description:i,type:a,duration:s}=e;n[a]({message:r,duration:s||6,description:i,onClose:()=>t(o),placement:"bottomRight"})}))}),[e]),o},XJ=({children:e})=>(0,s.jsx)(Ga,{theme:{token:{colorPrimary:"#F07539"},components:{Button:{borderRadius:0,colorPrimary:"#312a30",colorPrimaryHover:"#F07539",defaultShadow:"none",primaryShadow:"none",borderRadiusLG:0,borderRadiusSM:0,borderRadiusOuter:0,algorithm:!1},Input:{borderRadius:0,borderRadiusLG:0,borderRadiusSM:0,borderRadiusOuter:0,paddingBlock:14,paddingInline:14}}},children:e}),GJ=({slug:e,component:t})=>{const{proAlert:n}=(0,d.useSelect)((e=>({proAlert:e("notification-master/core").getProAlert()}))),{toggleProAlert:o}=(0,d.useDispatch)("notification-master/core"),r=J(),i=(0,l.useCallback)(((e,t)=>n=>{n.preventDefault(),r(gT(e)),t?.classList.add("current"),Array.from(t?.parentElement?.children||[]).forEach((e=>{e!==t&&e.classList.remove("current")}))}),[]);return(0,l.useEffect)((()=>{const e=new Map;return(0,Gf.map)((0,Gf.filter)(KJ,(e=>!e.hidden)),"slug").forEach((t=>{const n=t,o=document.querySelector(`.wp-submenu-wrap a[href*="ntfm-${n}"]`);if(!o||!o.parentElement)return;const r=i(n,o.parentElement);e.set(o,r),o.addEventListener("click",r)})),()=>{e.forEach(((e,t)=>{t.removeEventListener("click",e)}))}}),[i]),(0,s.jsxs)("div",{className:`notification-master-page notification-master-page__${e}`,children:[(0,s.jsx)(Xf,{title:!1,open:n,onCancel:()=>o(!1),footer:null,children:(0,s.jsx)(DT,{})}),(0,s.jsx)(RS,{icon:(0,s.jsx)(fw,{}),onClick:()=>{const e=LS.ntfmSiteUrl;window.open(`${e}/docs/getting-started`,"_blank")},tooltip:(0,c.__)("Help","notification-master")}),(0,s.jsx)(UJ,{}),(0,s.jsx)(xT,{}),(0,s.jsx)(XJ,{children:(0,s.jsx)(uw.div,{className:"notification-master-page__content",children:(0,s.jsx)(t,{})})})]})},YJ=window.wp.dataControls,ZJ="SET_SETTINGS",QJ="UPDATE_SETTING",JJ="ADD_NOTICE",e0="DELETE_NOTICE",t0="SET_TOTAL_NOTIFICATIONS",n0="TOGGLE_PRO_ALERT",o0="TOGGLE_MERGE_TAGS",r0=e=>({type:ZJ,settings:e}),i0=(e,t)=>({type:QJ,key:e,value:t}),a0=e=>({type:JJ,notice:e}),s0=e=>({type:e0,id:e}),l0=e=>({type:t0,total:e}),c0=e=>({type:n0,status:e}),u0=e=>({type:o0,status:e}),d0=e=>e.settings,h0=e=>e.notices,f0=(e,t)=>e.notices[t],p0=e=>e.totalNotifications,m0=e=>e.proAlert,g0=e=>e.mergeTags,v0=()=>async({dispatch:e})=>{const t=await zT()({path:(0,pJ.addQueryArgs)("/ntfm/v1/settings")});e.setSettings(t)},b0=e=>async({dispatch:t})=>{const n=await zT()({path:(0,pJ.addQueryArgs)(`/ntfm/v1/integrations/${e}`)});t.receiveIntegration(e,n)},y0=()=>async({dispatch:e})=>{const t=parseInt(LS.totalNotifications)||0;e.setTotalNotifications(t)},x0={settings:{},notices:{},totalNotifications:0,proAlert:!1,mergeTags:!1},w0={reducer:(e=x0,t)=>{switch(t.type){case ZJ:return{...e,settings:t.settings};case QJ:return{...e,settings:{...e.settings,[t.key]:t.value}};case JJ:const n=Math.random().toString(36).substr(2,9),o={...t.notice,noteId:n};return{...e,notices:{...e.notices,[n]:o}};case e0:const r={...e.notices};return r[t.id]&&delete r[t.id],{...e,notices:r};case t0:return{...e,totalNotifications:t.total};case n0:return{...e,proAlert:t.status};case o0:return{...e,mergeTags:!e.mergeTags};default:return e}},actions:r,selectors:i,controls:YJ.controls,resolvers:a},C0=(0,d.createReduxStore)("notification-master/core",w0);(0,d.register)(C0),(0,l.render)((0,s.jsx)((()=>(0,s.jsx)("div",{className:"notification-master__pages",children:(0,s.jsx)(ge,{history:mT(),children:(0,s.jsx)(de,{children:KJ.map((e=>(0,s.jsx)(ce,{path:e.path,element:(0,s.jsx)(GJ,{...e})},e.slug)))})})})),{}),document.getElementById("notification-master-admin"))},1609:e=>{"use strict";e.exports=window.React},2634:()=>{},6942:(e,t)=>{var n;!function(){"use strict";var o={}.hasOwnProperty;function r(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=a(e,i(n)))}return e}function i(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return r.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)o.call(e,n)&&e[n]&&(t=a(t,n));return t}function a(e,t){return t?e?e+" "+t:e+t:e}e.exports?(r.default=r,e.exports=r):void 0===(n=function(){return r}.apply(t,[]))||(e.exports=n)}()}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return t[e](i,i.exports,o),i.loaded=!0,i.exports}o.m=t,e=[],o.O=(t,n,r,i)=>{if(!n){var a=1/0;for(u=0;u<e.length;u++){for(var[n,r,i]=e[u],s=!0,l=0;l<n.length;l++)(!1&i||a>=i)&&Object.keys(o.O).every((e=>o.O[e](n[l])))?n.splice(l--,1):(s=!1,i<a&&(a=i));if(s){e.splice(u--,1);var c=r();void 0!==c&&(t=c)}}return t}i=i||0;for(var u=e.length;u>0&&e[u-1][2]>i;u--)e[u]=e[u-1];e[u]=[n,r,i]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={57:0,350:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var r,i,[a,s,l]=n,c=0;if(a.some((t=>0!==e[t]))){for(r in s)o.o(s,r)&&(o.m[r]=s[r]);if(l)var u=l(o)}for(t&&t(n);c<a.length;c++)i=a[c],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(u)},n=globalThis.webpackChunknotification_master=globalThis.webpackChunknotification_master||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var r=o.O(void 0,[350],(()=>o(2163)));r=o.O(r)})();
     11(0,c.sprintf)((0,c.__)("All debug logs older than {%s} days will be deleted.","notification-master"),e.delete_logs_every)})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(c$,{type:"number",value:e.delete_logs_every,onChange:e=>{n("delete_logs_every",e.target.value)}})})]}),(0,s.jsx)("div",{className:"notification-master__settings--header",children:(0,s.jsx)("h3",{className:"notification-master-heading",children:(0,c.__)("Triggers","notification-master")})}),!LS.isPro&&(0,s.jsx)(qw.Ribbon,{text:(0,c.__)("Pro","notification-master"),children:(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),onClick:()=>r(!0),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("WooCommerce","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the WooCommerce product, review, or order changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:!1,onChange:()=>{r(!0)}})})]})}),LS.isPro&&(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("WooCommerce","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the WooCommerce product, review, or order changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.woocommerce_change_trigger||!0,onChange:e=>{n("woocommerce_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item",{"notification-master__settings--item--has-subitem":e.post_status_change_trigger}),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Post status change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the post status changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.post_status_change_trigger,onChange:e=>{n("post_status_change_trigger",e)}})})]}),e.post_status_change_trigger&&(0,s.jsxs)("div",{className:"notification-master__settings--item notification-master__settings--item--block",children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Post types","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("Select the post types for which you want to send notifications when the post status changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--select",children:(0,s.jsx)($j,{mode:"multiple",size:"large",placeholder:(0,c.__)("Select post types","notification-master"),options:h,value:e.post_types,onChange:e=>{n("post_types",e)},style:{width:"100%"}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item",{"notification-master__settings--item--has-subitem":e.taxonomy_term_change_trigger}),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Taxonomy term change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the taxonomy term changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.taxonomy_term_change_trigger,onChange:e=>{n("taxonomy_term_change_trigger",e)}})})]}),e.taxonomy_term_change_trigger&&(0,s.jsxs)("div",{className:"notification-master__settings--item notification-master__settings--item--block",children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Taxonomies","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("Select the taxonomies for which you want to send notifications when the taxonomy term changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--select",children:(0,s.jsx)($j,{mode:"multiple",size:"large",placeholder:(0,c.__)("Select taxonomies","notification-master"),options:f,value:e.taxonomies,onChange:e=>{n("taxonomies",e)},style:{width:"100%"}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item",{"notification-master__settings--item--has-subitem":e.comment_change_trigger}),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Comment change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the comment status changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.comment_change_trigger,onChange:e=>{n("comment_change_trigger",e)}})})]}),e.comment_change_trigger&&(0,s.jsxs)("div",{className:"notification-master__settings--item notification-master__settings--item--block",children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Comment types","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("Select the comment types for which you want to send notifications when the comment status changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--select",children:(0,s.jsx)($j,{mode:"multiple",size:"large",placeholder:(0,c.__)("Select comment types","notification-master"),options:p,value:e.comment_types,onChange:e=>{n("comment_types",e)},style:{width:"100%"}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Media change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the media changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.media_change_trigger,onChange:e=>{n("media_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("User change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the user changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.user_change_trigger,onChange:e=>{n("user_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Theme change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the theme changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.theme_change_trigger,onChange:e=>{n("theme_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsxs)("div",{className:"notification-master__settings--item--title",children:[(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Plugin change","notification-master")}),(0,s.jsx)(Bk.Text,{children:(0,c.__)("If enabled, will be able to add notifications when the plugin changes.","notification-master")})]}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.plugin_change_trigger,onChange:e=>{n("plugin_change_trigger",e)}})})]}),(0,s.jsxs)("div",{className:ei()("notification-master__settings--item"),children:[(0,s.jsx)("div",{className:"notification-master__settings--item--title",children:(0,s.jsx)(Bk.Title,{level:5,children:(0,c.__)("Privacy","notification-master")})}),(0,s.jsx)("div",{className:"notification-master__settings--item--switch",children:(0,s.jsx)(Dj,{title:(0,c.__)("Enable","notification-master"),checkedChildren:(0,c.__)("On","notification-master"),unCheckedChildren:(0,c.__)("Off","notification-master"),checked:e.privacy_trigger,onChange:e=>{n("privacy_trigger",e)}})})]}),(0,s.jsx)("div",{className:"notification-master__settings--footer-placeholder"}),(0,s.jsx)("div",{className:"notification-master__settings--footer",ref:i,children:(0,s.jsx)(Eu,{type:"primary",size:"large",onClick:async()=>{if(!a){u(!0);try{await zT()({path:"/ntfm/v1/settings",method:"POST",data:{settings:e}}),o({type:"success",message:(0,c.__)("Settings saved successfully","notification-master")}),window.location.reload()}catch(e){o({type:"error",message:(0,c.__)("Failed to save settings","notification-master")})}finally{u(!1)}}},loading:a,children:(0,c.__)("Save","notification-master")})})]})]})}},{path:"/notification-log",slug:"notification-log",title:(0,c.__)("Notification Log","notification-master"),component:()=>{const[e,t]=(0,l.useState)(!0),[n,o]=(0,l.useState)([]),[r,i]=(0,l.useState)(10),[a,u]=(0,l.useState)(1),[h,f]=(0,l.useState)(null),[p,m]=(0,l.useState)(!1),[g,v]=(0,l.useState)(0),{addNotice:b}=(0,d.useDispatch)("notification-master/core"),[y,x]=(0,l.useState)([]),[w,C]=(0,l.useState)(""),[S,E]=(0,l.useState)(!1);lz((0,c.__)("Notification Log","notification-master"));const k=async()=>{t(!0);try{const e=await zT()({path:(0,pJ.addQueryArgs)("/ntfm/v1/notification-logs",{per_page:r,page:a})});e&&(o((0,Gf.isArray)(e?.logs)?e.logs:[]),v(e?.count||0))}catch(e){b({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}t(!1)};if((0,l.useEffect)((()=>{k()}),[r,a]),e&&(0,Gf.isEmpty)(n))return(0,s.jsx)("div",{className:"notification-master__log--loading",children:(0,s.jsx)(az,{color:"var(--notification-master-color-primary)"})});const $=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(t){return e}return(0,Gf.isObject)(e)?O(e):e},O=e=>{const t={};for(const n in e)"notification_name"!==n&&"trigger"!==n&&"trigger_name"!==n&&(0,Gf.set)(t,n,$(e[n]));return t};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("h2",{className:"notification-master-heading",children:[(0,s.jsx)(zN,{component:VJ,width:20,height:20}),(0,c.__)("Notification Log","notification-master")]}),(0,s.jsx)("div",{className:"notification-master__log",children:(0,Gf.isEmpty)(n)?(0,s.jsx)(Bk.Title,{level:5,style:{textAlign:"center"},children:(0,c.__)("No logs found.","notification-master")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tT,{gap:20,justify:"space-between",children:[(0,s.jsxs)(tT,{gap:"small",children:[(0,s.jsx)($j,{options:[{label:(0,c.__)("Bulk Actions","notification-master"),value:"",disabled:!0},{label:(0,c.__)("Delete","notification-master"),value:"delete"}],value:w,onChange:e=>C(e)}),(0,s.jsx)(Eu,{type:"primary",onClick:()=>(async e=>{if("delete"===e){if((0,Gf.isEmpty)(y))return void b({type:"error",message:(0,c.__)("Please select a log.","notification-master")});E(!0);try{await zT()({path:(0,pJ.addQueryArgs)("/ntfm/v1/notification-logs"),method:"DELETE",data:{ids:y}}),x([]),k()}catch(e){b({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}finally{E(!1)}}})(w),loading:S,children:(0,c.__)("Apply","notification-master")})]}),(0,s.jsx)(tT,{align:"center",style:{marginBottom:"1rem"},children:(0,s.jsx)($z,{title:(0,c.__)("Are you sure?","notification-master"),onConfirm:async()=>{if(!p){m(!0);try{await zT()({path:"/ntfm/v1/notification-logs",method:"DELETE"}),o([])}catch(e){b({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}m(!1)}},okText:(0,c.__)("Yes","notification-master"),cancelText:(0,c.__)("No","notification-master"),children:(0,s.jsx)(Eu,{type:"primary",danger:!0,children:(0,c.__)("Delete All","notification-master")})})})]}),(0,s.jsx)(HX,{columns:WJ,dataSource:n.map((e=>({...e,log_status:(0,s.jsx)(Bk.Text,{type:"error"===e.status?"danger":"success",children:e.status}),notification:(0,s.jsx)(Bk.Text,{children:e.content.notification_name}),date:new Date(e.date).toLocaleString(),view:(0,s.jsx)(gS,{title:(0,c.__)("View","notification-master"),children:(0,s.jsx)(Eu,{type:"primary",shape:"circle",icon:(0,s.jsx)(Qk,{}),onClick:()=>f(e)})})}))),pagination:{total:g,showSizeChanger:!0,showQuickJumper:!0,showTotal:e=>`${(0,c.__)("Total","notification-master")}: ${e}`,onChange:(e,t)=>{u(e),i(t)}},loading:e,rowKey:"id",style:{width:"100%"},rowSelection:{selectedRowKeys:y,onChange:e=>x(e)}})]})}),(0,s.jsx)(Xf,{title:(0,c.__)("Log Details","notification-master"),open:!!h,onCancel:()=>f(null),footer:null,width:800,children:(0,s.jsxs)("div",{className:"notification-master__log--view",children:[(0,s.jsxs)(tT,{gap:10,children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Name","notification-master")," : "]}),(0,s.jsx)(Bk.Text,{children:h?.content.notification_name})]}),(0,s.jsxs)(tT,{gap:10,style:{marginTop:"1rem"},children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Trigger","notification-master")," : "]}),(0,s.jsxs)(Bk.Text,{children:[h?.content.trigger_name," ",`"${h?.content.trigger}"`]})]}),(0,s.jsxs)(tT,{gap:10,style:{marginTop:"1rem"},children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Integration","notification-master")," : "]}),(0,s.jsx)(Bk.Text,{children:h?.integration})]}),(0,s.jsxs)(tT,{gap:10,style:{marginTop:"1rem"},children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Status","notification-master")," : "]}),(0,s.jsx)(Bk.Text,{type:"error"===h?.status?"danger":"success",children:h?.status})]}),(0,s.jsxs)(tT,{gap:10,style:{marginTop:"1rem"},children:[(0,s.jsxs)(Bk.Text,{strong:!0,children:[(0,c.__)("Date","notification-master")," : "]}),(0,s.jsx)(Bk.Text,{children:h?.date})]}),(0,s.jsxs)(tT,{style:{marginTop:"1rem",flexDirection:"column"},children:[(0,s.jsx)(Bk.Text,{strong:!0,children:(0,c.__)("Details","notification-master")}),(0,s.jsx)("pre",{style:{overflowX:"auto"},children:JSON.stringify(O(h?.content),null,2)})]})]})})]})}},{path:"/debug-log",slug:"debug-log",title:(0,c.__)("Debug Log","notification-master"),component:()=>{const[e,t]=(0,l.useState)(!0),[n,o]=(0,l.useState)([]),[r,i]=(0,l.useState)(10),[a,u]=(0,l.useState)(1),[h,f]=(0,l.useState)(null),[p,m]=(0,l.useState)(!1),[g,v]=(0,l.useState)(0),[b,y]=(0,l.useState)(!1),{addNotice:x}=(0,d.useDispatch)("notification-master/core"),[w,C]=(0,l.useState)([]),[S,E]=(0,l.useState)(""),[k,$]=(0,l.useState)(!1);lz((0,c.__)("Debug Log","notification-master"));const O=async()=>{try{const e=await zT()({path:(0,pJ.addQueryArgs)("/ntfm/v1/logs",{per_page:r,page:a})});e?(o((0,Gf.isArray)(e?.logs)?e.logs:[]),v(e?.count||0)):x({type:"error",message:(0,c.__)("An error occurred","notification-master")})}catch(e){x({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}t(!1)};return(0,l.useEffect)((()=>{O()}),[r,a]),e?(0,s.jsx)("div",{className:"notification-master__log--loading",children:(0,s.jsx)(az,{color:"var(--notification-master-color-primary)"})}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("h2",{className:"notification-master-heading",children:[(0,s.jsx)(zN,{component:VJ,width:20,height:20}),(0,c.__)("Debug Log","notification-master")]}),(0,s.jsx)("div",{className:"notification-master__log",children:(0,Gf.isEmpty)(n)?(0,s.jsx)(Bk.Title,{level:5,style:{textAlign:"center"},children:(0,c.__)("No logs found.","notification-master")}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tT,{gap:20,justify:"space-between",children:[(0,s.jsxs)(tT,{gap:"small",children:[(0,s.jsx)($j,{options:[{label:(0,c.__)("Bulk Actions","notification-master"),value:"",disabled:!0},{label:(0,c.__)("Delete","notification-master"),value:"delete"}],value:S,onChange:e=>E(e)}),(0,s.jsx)(Eu,{type:"primary",onClick:()=>(async e=>{if("delete"===e){if((0,Gf.isEmpty)(w))return void x({type:"error",message:(0,c.__)("Please select a log.","notification-master")});$(!0);try{await zT()({path:(0,pJ.addQueryArgs)("/ntfm/v1/logs"),method:"DELETE",data:{ids:w}}),C([]),O()}catch(e){x({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}finally{$(!1)}}})(S),loading:k,children:(0,c.__)("Apply","notification-master")})]}),(0,s.jsxs)(tT,{align:"center",style:{marginBottom:"1rem"},children:[(0,s.jsx)(Eu,{type:"primary",onClick:async()=>{if(b)return;y(!0);const e=await zT()({path:"/ntfm/v1/logs/export",method:"GET",parse:!1});if(e){const t=await e.blob(),n=window.URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download="logs.json",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n)}y(!1)},style:{marginRight:"1rem"},loading:b,children:(0,c.__)("Export All","notification-master")}),(0,s.jsx)($z,{title:(0,c.__)("Are you sure?","notification-master"),onConfirm:async()=>{if(!p){m(!0);try{await zT()({path:"/ntfm/v1/logs",method:"DELETE"}),o([])}catch(e){x({type:"error",message:e?.message||(0,c.__)("An error occurred","notification-master")})}m(!1)}},okText:(0,c.__)("Yes","notification-master"),cancelText:(0,c.__)("No","notification-master"),children:(0,s.jsx)(Eu,{type:"primary",danger:!0,children:(0,c.__)("Delete All","notification-master")})})]})]}),(0,s.jsx)(HX,{columns:qJ,dataSource:n.map((e=>({...e,log_type:(0,s.jsx)(Bk.Text,{type:"error"===e.type?"danger":"debug"===e.type?"warning":"secondary",children:e.type.toUpperCase()}),date:new Date(e.date).toLocaleString(),view:(0,s.jsx)(gS,{title:(0,c.__)("View","notification-master"),children:(0,s.jsx)(Eu,{type:"primary",shape:"circle",icon:(0,s.jsx)(Qk,{}),onClick:()=>f(e.id)})})}))),pagination:{total:g,showSizeChanger:!0,showQuickJumper:!0,showTotal:e=>`${(0,c.__)("Total","notification-master")}: ${e}`,onChange:(e,t)=>{u(e),i(t)}},rowKey:"id",style:{width:"100%"},rowSelection:{selectedRowKeys:w,onChange:e=>C(e)}})]})}),(0,s.jsx)(Xf,{title:(0,c.__)("Log Details","notification-master"),open:!!h,onCancel:()=>f(null),footer:null,width:600,children:(0,s.jsx)("pre",{style:{maxHeight:"400px",overflowX:"auto"},children:(e=>{const t={};for(const n in e)if("notification_name"!==n&&"trigger"!==n&&"trigger_name"!==n)if("string"==typeof e[n])try{(0,Gf.set)(t,n,JSON.parse(e[n]))}catch(o){(0,Gf.set)(t,n,e[n])}else(0,Gf.set)(t,n,e[n]);return JSON.stringify(t,null,2)})(n.find((e=>e.id===h))?.content)})})]})}}]),UJ=()=>{const{notices:e}=(0,d.useSelect)((e=>({notices:e("notification-master/core").getNotices()}))),{deleteNotice:t}=(0,d.useDispatch)("notification-master/core"),[n,o]=Jl.useNotification();return(0,l.useEffect)((()=>{(0,Gf.size)(e)&&(0,Gf.map)(e,((e,o)=>{const{message:r,description:i,type:a,duration:s}=e;n[a]({message:r,duration:s||6,description:i,onClose:()=>t(o),placement:"bottomRight"})}))}),[e]),o},XJ=({children:e})=>(0,s.jsx)(Ga,{theme:{token:{colorPrimary:"#F07539"},components:{Button:{borderRadius:0,colorPrimary:"#312a30",colorPrimaryHover:"#F07539",defaultShadow:"none",primaryShadow:"none",borderRadiusLG:0,borderRadiusSM:0,borderRadiusOuter:0,algorithm:!1},Input:{borderRadius:0,borderRadiusLG:0,borderRadiusSM:0,borderRadiusOuter:0,paddingBlock:14,paddingInline:14}}},children:e}),GJ=({slug:e,component:t})=>{const{proAlert:n}=(0,d.useSelect)((e=>({proAlert:e("notification-master/core").getProAlert()}))),{toggleProAlert:o}=(0,d.useDispatch)("notification-master/core"),r=J(),i=(0,l.useCallback)(((e,t)=>n=>{n.preventDefault(),r(gT(e)),t?.classList.add("current"),Array.from(t?.parentElement?.children||[]).forEach((e=>{e!==t&&e.classList.remove("current")}))}),[]);return(0,l.useEffect)((()=>{const e=new Map;return(0,Gf.map)((0,Gf.filter)(KJ,(e=>!e.hidden)),"slug").forEach((t=>{const n=t,o=document.querySelector(`.wp-submenu-wrap a[href*="ntfm-${n}"]`);if(!o||!o.parentElement)return;const r=i(n,o.parentElement);e.set(o,r),o.addEventListener("click",r)})),()=>{e.forEach(((e,t)=>{t.removeEventListener("click",e)}))}}),[i]),(0,s.jsxs)("div",{className:`notification-master-page notification-master-page__${e}`,children:[(0,s.jsx)(Xf,{title:!1,open:n,onCancel:()=>o(!1),footer:null,children:(0,s.jsx)(DT,{})}),(0,s.jsx)(RS,{icon:(0,s.jsx)(fw,{}),onClick:()=>{const e=LS.ntfmSiteUrl;window.open(`${e}/docs/getting-started`,"_blank")},tooltip:(0,c.__)("Help","notification-master")}),(0,s.jsx)(UJ,{}),(0,s.jsx)(xT,{}),(0,s.jsx)(XJ,{children:(0,s.jsx)(uw.div,{className:"notification-master-page__content",children:(0,s.jsx)(t,{})})})]})},YJ=window.wp.dataControls,ZJ="SET_SETTINGS",QJ="UPDATE_SETTING",JJ="ADD_NOTICE",e0="DELETE_NOTICE",t0="SET_TOTAL_NOTIFICATIONS",n0="TOGGLE_PRO_ALERT",o0="TOGGLE_MERGE_TAGS",r0=e=>({type:ZJ,settings:e}),i0=(e,t)=>({type:QJ,key:e,value:t}),a0=e=>({type:JJ,notice:e}),s0=e=>({type:e0,id:e}),l0=e=>({type:t0,total:e}),c0=e=>({type:n0,status:e}),u0=e=>({type:o0,status:e}),d0=e=>e.settings,h0=e=>e.notices,f0=(e,t)=>e.notices[t],p0=e=>e.totalNotifications,m0=e=>e.proAlert,g0=e=>e.mergeTags,v0=()=>async({dispatch:e})=>{const t=await zT()({path:(0,pJ.addQueryArgs)("/ntfm/v1/settings")});e.setSettings(t)},b0=e=>async({dispatch:t})=>{const n=await zT()({path:(0,pJ.addQueryArgs)(`/ntfm/v1/integrations/${e}`)});t.receiveIntegration(e,n)},y0=()=>async({dispatch:e})=>{const t=parseInt(LS.totalNotifications)||0;e.setTotalNotifications(t)},x0={settings:{},notices:{},totalNotifications:0,proAlert:!1,mergeTags:!1},w0={reducer:(e=x0,t)=>{switch(t.type){case ZJ:return{...e,settings:t.settings};case QJ:return{...e,settings:{...e.settings,[t.key]:t.value}};case JJ:const n=Math.random().toString(36).substr(2,9),o={...t.notice,noteId:n};return{...e,notices:{...e.notices,[n]:o}};case e0:const r={...e.notices};return r[t.id]&&delete r[t.id],{...e,notices:r};case t0:return{...e,totalNotifications:t.total};case n0:return{...e,proAlert:t.status};case o0:return{...e,mergeTags:!e.mergeTags};default:return e}},actions:r,selectors:i,controls:YJ.controls,resolvers:a},C0=(0,d.createReduxStore)("notification-master/core",w0);(0,d.register)(C0),(0,l.render)((0,s.jsx)((()=>(0,s.jsx)("div",{className:"notification-master__pages",children:(0,s.jsx)(ge,{history:mT(),children:(0,s.jsx)(de,{children:KJ.map((e=>(0,s.jsx)(ce,{path:e.path,element:(0,s.jsx)(GJ,{...e})},e.slug)))})})})),{}),document.getElementById("notification-master-admin"))},1609:e=>{"use strict";e.exports=window.React},2634:()=>{},6942:(e,t)=>{var n;!function(){"use strict";var o={}.hasOwnProperty;function r(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=a(e,i(n)))}return e}function i(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return r.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)o.call(e,n)&&e[n]&&(t=a(t,n));return t}function a(e,t){return t?e?e+" "+t:e+t:e}e.exports?(r.default=r,e.exports=r):void 0===(n=function(){return r}.apply(t,[]))||(e.exports=n)}()}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return t[e](i,i.exports,o),i.loaded=!0,i.exports}o.m=t,e=[],o.O=(t,n,r,i)=>{if(!n){var a=1/0;for(u=0;u<e.length;u++){for(var[n,r,i]=e[u],s=!0,l=0;l<n.length;l++)(!1&i||a>=i)&&Object.keys(o.O).every((e=>o.O[e](n[l])))?n.splice(l--,1):(s=!1,i<a&&(a=i));if(s){e.splice(u--,1);var c=r();void 0!==c&&(t=c)}}return t}i=i||0;for(var u=e.length;u>0&&e[u-1][2]>i;u--)e[u]=e[u-1];e[u]=[n,r,i]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={57:0,350:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var r,i,[a,s,l]=n,c=0;if(a.some((t=>0!==e[t]))){for(r in s)o.o(s,r)&&(o.m[r]=s[r]);if(l)var u=l(o)}for(t&&t(n);c<a.length;c++)i=a[c],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(u)},n=globalThis.webpackChunknotification_master=globalThis.webpackChunknotification_master||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var r=o.O(void 0,[350],(()=>o(2163)));r=o.O(r)})();
  • notification-master/trunk/includes/class-logger.php

    r3118722 r3131144  
    184184     *
    185185     * @since 1.0.0
    186      */
    187     public function delete() {
    188         Logs_Model::delete();
     186     *
     187     * @param array $ids IDs.
     188     */
     189    public function delete( $ids = array() ) {
     190        if ( empty( $ids ) ) {
     191            Logs_Model::delete();
     192        } else {
     193            Logs_Model::delete_by_ids( $ids );
     194        }
    189195    }
    190196
  • notification-master/trunk/includes/class-notification-logger.php

    r3118722 r3131144  
    158158     *
    159159     * @since 1.0.0
     160     *
     161     * @param array $ids IDs.
    160162     */
    161     public function delete() {
    162         Notification_Logs_Model::delete();
     163    public function delete( $ids = array() ) {
     164        if ( empty( $ids ) ) {
     165            Notification_Logs_Model::delete();
     166        } else {
     167            Notification_Logs_Model::delete_by_ids( $ids );
     168        }
    163169    }
    164170
  • notification-master/trunk/includes/db/models/class-logs-model.php

    r3118722 r3131144  
    117117
    118118    /**
     119     * Delete by IDs.
     120     *
     121     * @since 1.0.0
     122     *
     123     * @param array $ids IDs.
     124     */
     125    public static function delete_by_ids( $ids ) {
     126        global $wpdb;
     127
     128        $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}ntfm_logs WHERE id IN (%s)", implode( ',', $ids ) ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- No caching needed.
     129    }
     130
     131    /**
    119132     * Delete by date.
    120133     *
  • notification-master/trunk/includes/db/models/class-notification-logs-model.php

    r3118722 r3131144  
    135135
    136136    /**
     137     * Delete by IDs.
     138     *
     139     * @since 1.0.0
     140     *
     141     * @param array $ids IDs.
     142     *
     143     * @return int
     144     */
     145    public static function delete_by_ids( $ids ) {
     146        global $wpdb;
     147
     148        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}ntfm_notification_logs WHERE id IN (%s)", implode( ',', $ids ) ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- No caching needed.
     149    }
     150
     151    /**
    137152     * Delete by date.
    138153     *
  • notification-master/trunk/includes/rest-api/controllers/v1/class-rest-logs-controller.php

    r3118722 r3131144  
    6868                    'callback'            => array( $this, 'delete_logs' ),
    6969                    'permission_callback' => array( $this, 'delete_logs_permissions_check' ),
     70                    'args'                => array(
     71                        'ids' => array(
     72                            'type'        => 'array',
     73                            'description' => __( 'Log IDs.', 'notification-master' ),
     74                            'required'    => false,
     75                        ),
     76                    ),
    7077                ),
    7178            )
     
    137144     */
    138145    public function delete_logs( $request ) {
    139         Notification_Master()->logger->delete();
     146        $ids = $request->get_param( 'ids' ) ? $request->get_param( 'ids' ) : array();
     147        Notification_Master()->logger->delete( $ids );
    140148
    141149        return new WP_REST_Response( null, 204 );
  • notification-master/trunk/includes/rest-api/controllers/v1/class-rest-notification-logs-controller.php

    r3118722 r3131144  
    6868                    'callback'            => array( $this, 'delete_logs' ),
    6969                    'permission_callback' => array( $this, 'delete_logs_permissions_check' ),
     70                    'args'                => array(
     71                        'ids' => array(
     72                            'type'        => 'array',
     73                            'description' => __( 'Log IDs.', 'notification-master' ),
     74                            'required'    => false,
     75                        ),
     76                    ),
    7077                ),
    7178            )
     
    138145     */
    139146    public function delete_logs( $request ) {
    140         Notification_Master()->notification_logger->delete();
     147        $ids = $request->get_param( 'ids' ) ? $request->get_param( 'ids' ) : array();
     148        Notification_Master()->notification_logger->delete( $ids );
    141149
    142150        return new WP_REST_Response( null, 204 );
  • notification-master/trunk/languages/notification-master.pot

    r3125271 r3131144  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Notification Master 1.1.3\n"
     5"Project-Id-Version: Notification Master 1.1.4\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/notification-master\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-07-25T14:33:52+02:00\n"
     12"POT-Creation-Date: 2024-08-05T17:09:11+02:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.10.0\n"
     
    13171317msgstr ""
    13181318
     1319#: includes/rest-api/controllers/v1/class-rest-logs-controller.php:73
     1320#: includes/rest-api/controllers/v1/class-rest-notification-logs-controller.php:73
     1321msgid "Log IDs."
     1322msgstr ""
     1323
    13191324#: includes/rest-api/controllers/v1/class-rest-notification-controller.php:51
    13201325msgid "Trigger."
     
    17471752#: dist/index.js:1
    17481753#: dist/index.js:5
     1754#: dist/index.js:11
    17491755msgid "Delete"
    17501756msgstr ""
     
    18341840
    18351841#: dist/index.js:1
     1842#: dist/index.js:11
    18361843msgid "Bulk Actions"
    18371844msgstr ""
     
    18661873
    18671874#: dist/index.js:1
     1875#: dist/index.js:11
    18681876msgid "Apply"
    18691877msgstr ""
     
    20992107
    21002108#: dist/index.js:11
     2109msgid "Please select a log."
     2110msgstr ""
     2111
     2112#: dist/index.js:11
    21012113msgid "Delete All"
    21022114msgstr ""
  • notification-master/trunk/notifications-master.php

    r3125271 r3131144  
    55 * Description: Enhance user engagement. Trigger notifications for events, support multiple channels like email and Discord, and personalize with dynamic merge tags. Easy setup and customization.
    66 *
    7  * Version: 1.1.3
     7 * Version: 1.1.4
    88 *
    99 * Author: Notification Master
     
    2626
    2727// Define notification-master constants.
    28 define( 'NOTIFICATION_MASTER_VERSION', '1.1.3' );
     28define( 'NOTIFICATION_MASTER_VERSION', '1.1.4' );
    2929define( 'NOTIFICATION_MASTER_FILE', __FILE__ );
    3030define( 'NOTIFICATION_MASTER_DIR', plugin_dir_path( __FILE__ ) );
  • notification-master/trunk/readme.txt

    r3125271 r3131144  
    33Donate link: https://notification-master.com
    44Tags: notification, email, alerts, notifications, webhooks
    5 Stable tag: 1.1.3
     5Stable tag: 1.1.4
    66Requires at least: 4.9
    77Tested up to: 6.6
     
    149149== Changelog ==
    150150
     151= 1.1.4 =
     152* Feature: Added the ability to delete logs by selected IDs.
     153* Feature: Added the ability to delete notification logs by selected IDs.
     154
    151155= 1.1.3 =
    152156* Fixed: Issue when updating notifications.
  • notification-master/trunk/src/pages/debug-log/index.tsx

    r3118722 r3131144  
    1919    Popconfirm,
    2020    Typography,
     21    Select,
    2122} from 'antd';
    2223import Icon, { FileExclamationOutlined, EyeOutlined } from '@ant-design/icons';
     
    7576    const [isExporting, setIsExporting] = useState(false);
    7677    const { addNotice } = useDispatch('notification-master/core');
     78    const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
     79    const [selectedAction, setSelectedAction] = useState('');
     80    const [isApplying, setIsApplying] = useState(false);
     81
    7782    usePageTitle(__('Debug Log', 'notification-master'));
    7883
     
    134139
    135140        setIsDeleting(false);
     141    };
     142
     143    const handleBulkAction = async (action: string) => {
     144        if (action === 'delete') {
     145            if (isEmpty(selectedRowKeys)) {
     146                addNotice({
     147                    type: 'error',
     148                    message: __('Please select a log.', 'notification-master'),
     149                });
     150                return;
     151            }
     152
     153            setIsApplying(true);
     154
     155            try {
     156                // @ts-ignore
     157                const response = await apiFetch({
     158                    path: addQueryArgs('/ntfm/v1/logs'),
     159                    method: 'DELETE',
     160                    data: { ids: selectedRowKeys },
     161                });
     162
     163                setSelectedRowKeys([]);
     164                fetchLogs();
     165            } catch (error: any) {
     166                addNotice({
     167                    type: 'error',
     168                    message:
     169                        error?.message ||
     170                        __('An error occurred', 'notification-master'),
     171                });
     172            } finally {
     173                setIsApplying(false);
     174            }
     175        }
    136176    };
    137177
     
    215255                ) : (
    216256                    <>
    217                         <Flex align="center" style={{ marginBottom: '1rem' }}>
    218                             <Button
    219                                 type="primary"
    220                                 onClick={exportLogs}
    221                                 style={{ marginRight: '1rem' }}
    222                                 loading={isExporting}
     257                        <Flex gap={20} justify="space-between">
     258                            <Flex gap={'small'}>
     259                                <Select
     260                                    options={[
     261                                        {
     262                                            label: __(
     263                                                'Bulk Actions',
     264                                                'notification-master'
     265                                            ),
     266                                            value: '',
     267                                            disabled: true,
     268                                        },
     269                                        {
     270                                            label: __(
     271                                                'Delete',
     272                                                'notification-master'
     273                                            ),
     274                                            value: 'delete',
     275                                        },
     276                                    ]}
     277                                    value={selectedAction}
     278                                    onChange={(value) =>
     279                                        setSelectedAction(value)
     280                                    }
     281                                />
     282                                <Button
     283                                    type="primary"
     284                                    onClick={() =>
     285                                        handleBulkAction(selectedAction)
     286                                    }
     287                                    loading={isApplying}
     288                                >
     289                                    {__('Apply', 'notification-master')}
     290                                </Button>
     291                            </Flex>
     292                            <Flex
     293                                align="center"
     294                                style={{ marginBottom: '1rem' }}
    223295                            >
    224                                 {__('Export All', 'notification-master')}
    225                             </Button>
    226                             <Popconfirm
    227                                 title={__(
    228                                     'Are you sure?',
    229                                     'notification-master'
    230                                 )}
    231                                 onConfirm={deleteAllLogs}
    232                                 okText={__('Yes', 'notification-master')}
    233                                 cancelText={__('No', 'notification-master')}
    234                             >
    235                                 <Button type="primary" danger>
    236                                     {__('Delete All', 'notification-master')}
     296                                <Button
     297                                    type="primary"
     298                                    onClick={exportLogs}
     299                                    style={{ marginRight: '1rem' }}
     300                                    loading={isExporting}
     301                                >
     302                                    {__('Export All', 'notification-master')}
    237303                                </Button>
    238                             </Popconfirm>
     304                                <Popconfirm
     305                                    title={__(
     306                                        'Are you sure?',
     307                                        'notification-master'
     308                                    )}
     309                                    onConfirm={deleteAllLogs}
     310                                    okText={__('Yes', 'notification-master')}
     311                                    cancelText={__('No', 'notification-master')}
     312                                >
     313                                    <Button type="primary" danger>
     314                                        {__(
     315                                            'Delete All',
     316                                            'notification-master'
     317                                        )}
     318                                    </Button>
     319                                </Popconfirm>
     320                            </Flex>
    239321                        </Flex>
    240322                        <Table
     
    285367                            rowKey="id"
    286368                            style={{ width: '100%' }}
     369                            rowSelection={{
     370                                selectedRowKeys,
     371                                onChange: (selectedRowKeys) =>
     372                                    setSelectedRowKeys(selectedRowKeys),
     373                            }}
    287374                        />
    288375                    </>
  • notification-master/trunk/src/pages/notification-log/index.tsx

    r3118722 r3131144  
    1919    Popconfirm,
    2020    Typography,
     21    Select,
    2122} from 'antd';
    2223import Icon, { FileExclamationOutlined, EyeOutlined } from '@ant-design/icons';
     
    8081    const [count, setCount] = useState(0);
    8182    const { addNotice } = useDispatch('notification-master/core');
     83    const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
     84    const [selectedAction, setSelectedAction] = useState('');
     85    const [isApplying, setIsApplying] = useState(false);
    8286
    8387    usePageTitle(__('Notification Log', 'notification-master'));
     
    136140
    137141        setIsDeleting(false);
     142    };
     143
     144    const handleBulkAction = async (action: string) => {
     145        if (action === 'delete') {
     146            if (isEmpty(selectedRowKeys)) {
     147                addNotice({
     148                    type: 'error',
     149                    message: __('Please select a log.', 'notification-master'),
     150                });
     151                return;
     152            }
     153
     154            setIsApplying(true);
     155
     156            try {
     157                // @ts-ignore
     158                const response = await apiFetch({
     159                    path: addQueryArgs('/ntfm/v1/notification-logs'),
     160                    method: 'DELETE',
     161                    data: { ids: selectedRowKeys },
     162                });
     163
     164                setSelectedRowKeys([]);
     165                fetchLogs();
     166            } catch (error: any) {
     167                addNotice({
     168                    type: 'error',
     169                    message:
     170                        error?.message ||
     171                        __('An error occurred', 'notification-master'),
     172                });
     173            } finally {
     174                setIsApplying(false);
     175            }
     176        }
    138177    };
    139178
     
    199238                ) : (
    200239                    <>
    201                         <Flex align="center" style={{ marginBottom: '1rem' }}>
    202                             <Popconfirm
    203                                 title={__(
    204                                     'Are you sure?',
    205                                     'notification-master'
    206                                 )}
    207                                 onConfirm={deleteAllLogs}
    208                                 okText={__('Yes', 'notification-master')}
    209                                 cancelText={__('No', 'notification-master')}
     240                        <Flex gap={20} justify="space-between">
     241                            <Flex gap={'small'}>
     242                                <Select
     243                                    options={[
     244                                        {
     245                                            label: __(
     246                                                'Bulk Actions',
     247                                                'notification-master'
     248                                            ),
     249                                            value: '',
     250                                            disabled: true,
     251                                        },
     252                                        {
     253                                            label: __(
     254                                                'Delete',
     255                                                'notification-master'
     256                                            ),
     257                                            value: 'delete',
     258                                        },
     259                                    ]}
     260                                    value={selectedAction}
     261                                    onChange={(value) =>
     262                                        setSelectedAction(value)
     263                                    }
     264                                />
     265                                <Button
     266                                    type="primary"
     267                                    onClick={() =>
     268                                        handleBulkAction(selectedAction)
     269                                    }
     270                                    loading={isApplying}
     271                                >
     272                                    {__('Apply', 'notification-master')}
     273                                </Button>
     274                            </Flex>
     275                            <Flex
     276                                align="center"
     277                                style={{ marginBottom: '1rem' }}
    210278                            >
    211                                 <Button type="primary" danger>
    212                                     {__('Delete All', 'notification-master')}
    213                                 </Button>
    214                             </Popconfirm>
     279                                <Popconfirm
     280                                    title={__(
     281                                        'Are you sure?',
     282                                        'notification-master'
     283                                    )}
     284                                    onConfirm={deleteAllLogs}
     285                                    okText={__('Yes', 'notification-master')}
     286                                    cancelText={__('No', 'notification-master')}
     287                                >
     288                                    <Button type="primary" danger>
     289                                        {__(
     290                                            'Delete All',
     291                                            'notification-master'
     292                                        )}
     293                                    </Button>
     294                                </Popconfirm>
     295                            </Flex>
    215296                        </Flex>
    216297                        <Table
     
    265346                            rowKey="id"
    266347                            style={{ width: '100%' }}
     348                            rowSelection={{
     349                                selectedRowKeys,
     350                                onChange: (selectedRowKeys) =>
     351                                    setSelectedRowKeys(selectedRowKeys),
     352                            }}
    267353                        />
    268354                    </>
Note: See TracChangeset for help on using the changeset viewer.