From 6f8a1716c0229d315572b84f6c449871af39a61b Mon Sep 17 00:00:00 2001 From: Pavel Dohnal Date: Wed, 22 Jan 2025 14:01:05 +0100 Subject: [PATCH] Make the send action configurable [MAILPOET-6429] --- .../src/components/header/send-button.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/js/email-editor/src/components/header/send-button.tsx b/packages/js/email-editor/src/components/header/send-button.tsx index 0687564ee8..5b68d039f5 100644 --- a/packages/js/email-editor/src/components/header/send-button.tsx +++ b/packages/js/email-editor/src/components/header/send-button.tsx @@ -35,6 +35,11 @@ export function SendButton( { validateContent, isContentInvalid } ) { [] ); + const mailpoetEmailData: MailPoetEmailData = mailpoetEmail; + function sendAction() { + window.location.href = `admin.php?page=mailpoet-newsletters#/send/${ mailpoetEmailData.id }`; + } + const [ editorMode ] = useEditorMode(); const isDisabled = @@ -44,7 +49,6 @@ export function SendButton( { validateContent, isContentInvalid } ) { isContentInvalid || isDirty; - const mailpoetEmailData: MailPoetEmailData = mailpoetEmail; const label = applyFilters( 'mailpoet_email_editor_send_button_label', __( 'Send', 'mailpoet' ) @@ -56,7 +60,11 @@ export function SendButton( { validateContent, isContentInvalid } ) { onClick={ () => { recordEvent( 'header_send_button_clicked' ); if ( validateContent() ) { - window.location.href = `admin.php?page=mailpoet-newsletters#/send/${ mailpoetEmailData.id }`; + const action = applyFilters( + 'mailpoet_email_editor_send_action_callback', + sendAction + ) as () => void; + action(); } } } disabled={ isDisabled }