FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
mailpoet
/
assets
/
dist
/
js
Edit File: automation_editor.js
"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([[574],{36051(e,t,a){var o=a(3698),i=a.n(o),s=a(79124),n=a(7378),r=a(16221),l=a(66248),c=a(56973),d=a(74679),m=a(8301),u=a(75379),p=a(57257),g=a(62694),_=a(28636),b=a(2103),h=a(60697),v=a(99671),x=a(67268),j=a(82321),f=a(27029),A=a(65490),y=a(24652),w=(a(99242),a(86106)),S=a(14687),N=a(37833);function k(){const{isSidebarOpened:e,selectedStep:t,savedState:a}=(0,p.A)(e=>({isSidebarOpened:e(N.storeName).isSidebarOpened,selectedStep:e(N.storeName).getSelectedStep,savedState:e(N.storeName).getSavedState()})),{openSidebar:o,closeSidebar:i,save:s,toggleFeature:r}=(0,S.A)(N.storeName),{registerShortcut:l}=(0,S.A)(v.M_);return(0,n.useEffect)(()=>{l({name:"mailpoet/automation-editor/toggle-fullscreen",category:"global",description:(0,x.__)("Toggle fullscreen mode.","mailpoet"),keyCombination:{modifier:"secondary",character:"f"}}),l({name:"mailpoet/automation-editor/toggle-sidebar",category:"global",description:(0,x.__)("Show or hide the settings sidebar.","mailpoet"),keyCombination:{modifier:"primaryShift",character:","}}),l({name:"mailpoet/automation-editor/save",category:"global",description:(0,x.__)("Save your changes.","mailpoet"),keyCombination:{modifier:"primary",character:"s"}})},[l]),(0,v.wk)("mailpoet/automation-editor/toggle-fullscreen",()=>{r("fullscreenMode")}),(0,v.wk)("mailpoet/automation-editor/toggle-sidebar",a=>{if(a.preventDefault(),e())i();else{const e=t()?N.stepSidebarKey:N.automationSidebarKey;o(e)}}),(0,v.wk)("mailpoet/automation-editor/save",e=>{e.preventDefault(),"unsaved"===a&&s()}),null}var D=a(54735),C=a(8092),I=a(96606),O=a(87520);const{lock:T,unlock:L}=(0,O.yf)("I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.","@wordpress/edit-post"),{Tabs:E}=L(I.j),K=n.forwardRef(function(e,t){return(0,w.jsxs)(E.TabList,{ref:t,children:[(0,w.jsx)(E.Tab,{tabId:N.automationSidebarKey,children:(0,x.__)("Automation","mailpoet")}),(0,w.jsx)(E.Tab,{tabId:N.stepSidebarKey,children:(0,x.__)("Step","mailpoet")})]})});var F=a(78048),M=a(99252),J=a(50025),P=a(90712),V=a(84390);function R({title:e,description:t,icon:a}){return(0,w.jsxs)("div",{className:"block-editor-block-card",children:[(0,w.jsx)(V.W,{icon:a}),(0,w.jsxs)("div",{className:"block-editor-block-card__content",children:[(0,w.jsx)("h2",{className:"block-editor-block-card__title",children:e}),(0,w.jsx)("span",{className:"block-editor-block-card__description",children:t})]})]})}function W(){const{errors:e}=(0,p.A)(e=>({errors:e(N.storeName).getStepError(e(N.storeName).getSelectedStep().id)}),[]);if(!e||!e?.fields)return null;const t=e.fields?.general;return t?(0,w.jsx)(F.A,{isDismissible:!1,status:"error",children:t}):null}function B(){const{selectedStep:e,selectedStepType:t}=(0,p.A)(e=>({selectedStep:e(N.storeName).getSelectedStep(),selectedStepType:e(N.storeName).getSelectedStepType()}),[]);if(!e)return(0,w.jsx)(M.Ay,{children:"No step selected."});if(!t)return(0,w.jsx)(M.Ay,{children:"Unknown step type."});const a=t.edit;return(0,w.jsxs)("div",{className:"block-editor-block-inspector",children:[(0,w.jsx)(W,{}),(0,w.jsx)(R,{title:t.title(e,"sidebar"),description:t.description(e,"sidebar"),icon:t.icon}),(0,w.jsx)(a,{},e.id),"trigger"===e.type&&(0,w.jsx)(P.qn,{strings:J.t})]})}var G=a(64214),U=a(85716),q=a(91856),H=a(37024),z=a(65999);function Q(){const{automationId:e}=(0,p.A)(e=>({automationId:e(N.storeName).getAutomationData().id}),[]),t=H.Hooks.applyFilters("mailpoet.automation.settings.render",{});return 0===Object.keys(t).length?null:(0,w.jsx)(M.Ay,{title:(0,x.__)("Automation settings","mailpoet"),initialOpen:!0,onToggle:t=>(0,z.O)(t?"section_expand":"section_collapse",{card_section:"automation_settings",automation_id:e}),children:Object.keys(t).map(e=>(0,w.jsx)(G.A,{children:t[e]},e))})}function Y(){const{automationData:e}=(0,p.A)(e=>({automationData:e(N.storeName).getAutomationData()}),[]),t={year:"numeric",month:"long",day:"numeric"};return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(M.Ay,{title:(0,x.__)("Automation details","mailpoet"),initialOpen:!0,onToggle:t=>(0,z.O)(t?"section_expand":"section_collapse",{card_section:"automation_details",automation_id:e.id}),children:[(0,w.jsxs)(G.A,{children:[(0,w.jsx)("strong",{children:"Date added"})," ",new Date(Date.parse(e.created_at)).toLocaleDateString(q.locale.toString(),t)]}),(0,w.jsxs)(G.A,{children:[(0,w.jsx)("strong",{children:"Activated"})," ","active"===e.status&&new Date(Date.parse(e.updated_at)).toLocaleDateString(q.locale.toString(),t),"active"!==e.status&&e.activated_at&&new Date(Date.parse(e.activated_at)).toLocaleDateString(q.locale.toString(),t),"active"!==e.status&&!e.activated_at&&(0,w.jsx)("span",{className:"mailpoet-deactive",children:"Not activated yet."})]}),(0,w.jsxs)(G.A,{children:[(0,w.jsx)("strong",{children:"Author"})," ",e.author.name]}),(0,w.jsx)(G.A,{children:(0,w.jsx)(U.J,{})})]}),(0,w.jsx)(Q,{})]})}const{Tabs:X}=L(I.j),Z=_.A.select({web:!0,native:!1});function $(e){const{keyboardShortcut:t,sidebarKey:a,showIconLabels:o,automationName:i}=(0,p.A)(e=>({keyboardShortcut:e(v.M_).getShortcutRepresentation("mailpoet/automation-editor/toggle-sidebar"),sidebarKey:e(h.M_).getActiveComplementaryArea(N.storeName)??N.automationSidebarKey,showIconLabels:e(N.storeName).isFeatureActive("showIconLabels"),automationName:e(N.storeName).getAutomationData().name}),[]),s=(0,n.useRef)(null),r=(0,n.useContext)(X.Context);return(0,w.jsx)(h.WK,{identifier:a,header:(0,w.jsx)(X.Context.Provider,{value:r,children:(0,w.jsx)(K,{ref:s})}),closeLabel:(0,x.__)("Close settings","mailpoet"),headerClassName:"editor-sidebar__panel-tabs",title:(0,x.__)("Settings","mailpoet"),icon:C.A,className:"edit-site-sidebar mailpoet-automation-sidebar",panelClassName:"edit-site-sidebar",smallScreenTitle:i||(0,x.__)("(no title)","mailpoet"),scope:N.storeName,toggleShortcut:t,isActiveByDefault:Z,showIconLabels:o,...e,children:(0,w.jsxs)(X.Context.Provider,{value:r,children:[(0,w.jsx)(X.TabPanel,{tabId:N.automationSidebarKey,children:(0,w.jsx)(Y,{})}),(0,w.jsx)(X.TabPanel,{tabId:N.stepSidebarKey,children:(0,w.jsx)(B,{})})]})})}function ee(e){const{openSidebar:t}=(0,S.A)(N.storeName),{sidebarKey:a,automationId:o}=(0,p.A)(e=>({sidebarKey:e(h.M_).getActiveComplementaryArea(N.storeName)??N.automationSidebarKey,automationId:e(N.storeName).getAutomationData().id}),[]);return(0,w.jsx)(X,{selectedTabId:a,onSelect:e=>{(0,z.O)("tab_click",{tab_name:a===N.automationSidebarKey?"automation":"step",selected_value:e===N.automationSidebarKey?"automation":"step",automation_id:o}),t(e)},children:(0,w.jsx)($,{...e})})}var te=a(39004),ae=a(10319),oe=a(15198),ie=a(32627),se=a(6997),ne=a(83471),re=a(63254),le=a(67992);function ce({onClose:e}){const[t,a]=(0,n.useState)(!1),{activate:o}=(0,S.A)(N.storeName);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"mailpoet-automation-activate-panel__header",children:[(0,w.jsx)("div",{className:"mailpoet-automation-activate-panel__header-activate-button",children:(0,w.jsxs)(l.Ay,{variant:"primary",disabled:t,isBusy:t,autoFocus:!t,onClick:()=>{a(!0),o()},children:[t&&(0,x.__)("Activating…","mailpoet"),!t&&(0,x.__)("Activate","mailpoet")]})}),(0,w.jsx)("div",{className:"mailpoet-automation-activate-panel__header-cancel-button",children:(0,w.jsx)(l.Ay,{variant:"secondary",onClick:e,disabled:t,children:(0,x.__)("Cancel","mailpoet")})})]}),t&&(0,w.jsx)("div",{className:"mailpoet-automation-activate-panel__body",children:(0,w.jsx)(ne.Ay,{})}),!t&&(0,w.jsxs)("div",{className:"mailpoet-automation-activate-panel__body",children:[(0,w.jsx)("p",{children:(0,w.jsx)("strong",{children:(0,x.__)("Are you ready to activate?","mailpoet")})}),(0,w.jsx)("p",{children:(0,x.__)("Double-check your settings before activating.","mailpoet")})]})]})}function de({onClose:e}){const{automation:t}=(0,p.A)(e=>({automation:e(N.storeName).getAutomationData()}),[]);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)("div",{className:"mailpoet-automation-activate-panel__header",children:(0,w.jsx)(l.Ay,{icon:re.A,onClick:e,label:(0,x.__)("Close","mailpoet")})}),(0,w.jsxs)("div",{className:"mailpoet-automation-activate-panel__body",children:[(0,w.jsx)("div",{className:"mailpoet-automation-activate-panel__section",children:(0,x.sprintf)((0,x.__)('"%s" is now live.',"mailpoet"),t.name)}),(0,w.jsx)("p",{children:(0,w.jsx)("strong",{children:(0,x.__)("What’s next?","mailpoet")})}),(0,w.jsx)("p",{children:(0,x.__)("View all your automations to track statistics and create new ones.","mailpoet")}),(0,w.jsx)(l.Ay,{variant:"secondary",onClick:()=>{window.parent&&window.parent!==window?window.parent.postMessage({type:"mailpoet-navigate-to-automation-listing"},window.location.origin):window.location.href=oe.U.urls.automationListing},children:(0,x.__)("View all automations","mailpoet")})]})]})}function me(){const{automation:e,errors:t}=(0,p.A)(e=>({errors:e(N.storeName).getErrors(),automation:e(N.storeName).getAutomationData()}),[]),{closeActivationPanel:a}=(0,S.A)(N.storeName);if((0,n.useEffect)(()=>{t&&a()},[t,a]),t)return null;const o=e.status===le.i.ACTIVE;return(0,w.jsxs)("div",{className:"mailpoet-automation-activate-panel",children:[o&&(0,w.jsx)(de,{onClose:a}),!o&&(0,w.jsx)(ce,{onClose:a})]})}var ue=a(9513);function pe(e){if("saved"!==(0,m.L)(N.storeName).getSavedState()){const t=(0,m.L)(N.storeName).getAutomationData();return(0,z.O)("page_abandon",{automation_id:t.id,automation_status:t.status}),e.returnValue=(0,x.__)("There are unsaved changes that will be lost. Do you want to continue?","mailpoet"),e.returnValue}return""}function ge(){const{isFullscreenActive:e,isInserterOpened:t,isActivationPanelOpened:a,isSidebarOpened:o,showIconLabels:s,automation:g}=(0,p.A)(e=>({isFullscreenActive:e(N.storeName).isFeatureActive("fullscreenMode"),isInserterOpened:e(N.storeName).isInserterSidebarOpened(),isSidebarOpened:e(N.storeName).isSidebarOpened(),isActivationPanelOpened:e(N.storeName).isActivationPanelOpened(),showIconLabels:e(N.storeName).isFeatureActive("showIconLabels"),automation:e(N.storeName).getAutomationData()}),[]),[_,f]=(0,n.useState)(!0),A=(0,n.useRef)(!1);if((0,n.useEffect)(()=>(window.addEventListener("beforeunload",pe),()=>window.removeEventListener("beforeunload",pe)),[]),(0,n.useEffect)(()=>{_&&("trash"===g.status&&(window.location.href=(0,j.F)(oe.U.urls.automationListing,{notice:ie.f.automationHadBeenDeleted,"notice-args":[g.name]})),function(){const e=(0,m.L)(N.storeName).getAutomationData();if(![le.i.ACTIVE,le.i.DEACTIVATING].includes(e.status))return;if(0===e.stats.totals.in_progress)return;const{createNotice:t}=(0,u.J)(d.store);t("success",(0,x.__)("Editing an active automation is currently unavailable.","mailpoet"),{type:"snackbar"})}(),A.current||(A.current=!0,(0,z.O)("page_view",{automation_id:g.id,automation_status:g.status,is_new:"draft"===g.status&&!g.activated_at})),f(!1))},[g.name,g.status,g.id,g.activated_at,_]),"trash"===g.status)return null;const S=i()("interface-interface-skeleton",{"is-sidebar-opened":o,"show-icon-labels":s});return(0,w.jsx)(v.Ee,{children:(0,w.jsxs)(r.Kq,{children:[(0,w.jsx)(h.fA,{isActive:e}),(0,w.jsx)(k,{}),(0,w.jsx)(ee,{}),(0,w.jsx)(h.Du,{className:S,drawer:e&&(0,w.jsx)("div",{className:"edit-site-navigation-toggle",children:(0,w.jsx)(l.Ay,{className:"edit-site-navigation-toggle__button has-icon",href:"admin.php?page=mailpoet-automation",children:(0,w.jsx)(c.A,{size:36,icon:b.A})})}),header:(0,w.jsx)(y.Y9,{showInserterToggle:false}),content:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(D.D,{}),(0,w.jsx)(te.G,{context:"edit"})]}),sidebar:(0,w.jsx)(h.WK.Slot,{scope:N.storeName}),secondarySidebar:null}),a&&(0,w.jsx)(me,{})]})})}window.addEventListener("DOMContentLoaded",()=>{if((0,x.setLocaleData)(window.wp.i18n.getLocaleData()),void 0!==window.wp.date.getSettings){const e=window.wp;(0,g.setSettings)(e.date.getSettings())}else{const e=window.wp;(0,g.setSettings)(e.date.__experimentalGetSettings())}(0,N.createStore)();const e=_.A.select({web:!0,native:!1});(0,u.J)(h.M_).enableComplementaryArea(N.storeName,e?N.automationSidebarKey:void 0);const t=(0,f.d)(window.location.href,"fullscreen");("true"===t||"1"===t)&&((0,u.J)("core/preferences").set(N.storeName,"fullscreenMode",!0),(0,u.J)(N.storeName).setFullscreenForced(!0));const a=document.getElementById("mailpoet_automation_editor");a&&((0,A.registerTranslations)(),se.default.use(async(e,t)=>{try{return await t(e)}catch(t){if(e.signal?.aborted)return;const a=t,o=a.data?.status;if("mailpoet_automation_not_valid"===a.code)return void(0,u.J)(N.storeName).setErrors({steps:a.data.errors});if(o&&o>=400&&o<500){const e=a.message;return(0,u.J)(d.store).createErrorNotice(e??(0,x.__)("An unknown error occurred.","mailpoet"),{explicitDismiss:!0}),void(0,u.J)(N.storeName).setErrors({steps:[]})}throw(0,u.J)(d.store).createErrorNotice((0,x.__)("An unknown error occurred.","mailpoet"),{explicitDismiss:!0}),t}}),(0,ae.b)(),(0,ue.g)(),(0,s.createRoot)(a).render((0,w.jsx)(ge,{})))})},41669(e){e.exports=jQuery}},e=>{e.O(0,[223],()=>e(e.s=36051)),e.O()}]);
Save
Back