Files
php_assessment_2/wp-content/plugins/mailpoet/assets/dist/js/automation.js
T

1 line
19 KiB
JavaScript
Raw Normal View History

2025-02-05 23:15:46 +01:00
"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[662],{11806:(t,e,a)=>{var o={};a.r(o),a.d(o,{deleteAutomation:()=>$,duplicateAutomation:()=>P,loadAutomations:()=>M,restoreAutomation:()=>I,trashAutomation:()=>D});var i={};a.r(i),a.d(i,{deleteLegacyAutomation:()=>Q,loadLegacyAutomations:()=>J,restoreLegacyAutomation:()=>K,trashLegacyAutomation:()=>W});var n={};a.r(n),a.d(n,{getAllAutomations:()=>Z,getAutomationCount:()=>tt,getAutomations:()=>V,getLegacyAutomations:()=>X});var s=a(7378),l=a(79124),r=a(65069),m=a(29975),u=a(16221),c=a(77906),d=a(78631),p=a(89470),_=a(82808),h=a(57450),g=a(33191);const A="mailpoet/automation-listing";var y=a(54132),x=a(31528),f=a(95376),j=a(75379),T=a(59437),w=a(74679),b=a(30827),v=a(66248),N=a(82321),k=a(43318),S=a(86106);function E({automation:t,label:e,variant:a="link"}){const{id:o,isLegacy:i}=t;return i?(0,S.jsx)(v.Ay,{variant:a,href:`?page=mailpoet-newsletter-editor&id=${o}`,children:e??(0,T.__)("Edit","mailpoet")}):(0,S.jsx)(v.Ay,{variant:a,href:(0,N.F)(k.U.urls.automationEditor,{id:t.id}),children:e??(0,T.__)("Edit","mailpoet")})}var U=a(14687);function O({automation:t,previousStatus:e}){const{restoreAutomation:a}=(0,U.A)(A);return(0,S.jsx)(v.Ay,{variant:"link",onClick:()=>a(t,e),children:(0,T.__)("Undo","mailpoet")})}const L=(t,e)=>(0,j.J)(w.store).createSuccessNotice(t,e),C=t=>(0,j.J)(w.store).removeNotice(t);function*M(){return{type:"SET_AUTOMATIONS",automations:(yield(0,f.apiFetch)({path:"/automations"})).data}}function*P(t){const e=yield(0,f.apiFetch)({path:`/automations/${t.id}/duplicate`,method:"POST"});return L((0,T.sprintf)((0,T.__)('Automation "%s" was duplicated.',"mailpoet"),t.name)),{type:"ADD_AUTOMATION",automation:e.data}}function*D(t){const e=yield(0,f.apiFetch)({path:`/automations/${t.id}`,method:"PUT",data:{status:b.i.TRASH}}),a=(0,T.sprintf)((0,T.__)('Automation "%s" was moved to the trash.',"mailpoet"),t.name);return L(a,{id:`automation-trashed-${t.id}`,__unstableHTML:(0,S.jsxs)("p",{children:[a," ",(0,S.jsx)(O,{automation:t,previousStatus:t.status})]})}),{type:"UPDATE_AUTOMATION",automation:e.data}}function*I(t,e){const a=yield(0,f.apiFetch)({path:`/automations/${t.id}`,method:"PUT",data:{status:e}});C(`automation-trashed-${t.id}`);const o=(0,T.sprintf)((0,T.__)('Automation "%s" was restored from the trash.',"mailpoet"),t.name);return L(o,{__unstableHTML:(0,S.jsxs)("p",{children:[o," ",(0,S.jsx)(E,{automation:t,label:(0,T.__)("Edit automation","mailpoet")})]})}),{type:"UPDATE_AUTOMATION",automation:a.data}}function*$(t){return yield(0,f.apiFetch)({path:`/automations/${t.id}`,method:"DELETE"}),L((0,T.sprintf)((0,T.__)('Automation "%s" and all associated data were permanently deleted.',"mailpoet"),t.name)),{type:"DELETE_AUTOMATION",automation:t}}var F=a(46928);const H=window.mailpoet_roles||{},R=window.mailpoet_segments||[],Y=window.mailpoet_woocommerce_automatic_emails||{},B=t=>{const e="welcome"===t.type?(t=>{const e=t.options;if("user"===e.event)return"mailpoet_all"===e.role?(0,T.__)("Sent when a new WordPress user is added to your site.","mailpoet"):(0,T.sprintf)((0,T.__)("Sent when a new WordPress user with the role %s is added to your site.","mailpoet"),H[e.role]);const a=Object.values(R).find((({id:t})=>Number(t)===Number(e.segment)));return void 0===a?(0,S.jsx)("a",{href:`/send/${t.id}`,children:(0,T.__)("You need to select a list to send to.","mailpoet")}):(0,T.sprintf)((0,T.__)("Sent when someone subscribes to the list: %s.","mailpoet"),a.name)})(t):(t=>{const e=t.options,a=Y[e.group].events[e.event];let o;try{o=JSON.parse(e.meta??null)}catch(t){o=e.meta??null}const i=o&&o.option&&Array.isArray(o.option)?o.option.map((({name:t})=>t)):[];if(o&&0===i.length)return(0,S.jsx)("span",{className:"mailpoet-listing-error",children:(0,T.__)("You need to configure email options before this email can be sent.","mailpoet")});const n=i.length>1&&"listingScheduleDisplayTextPlural"in a?a.listingScheduleDisplayTextPlural:a.listingScheduleDisplayText;return(0,T.sprintf)(n.endsWith(".")?n:`${n}.`,i.join(", "))})(t),a=e?(t=>{const e=t.options;if("imm