Make the send action configurable

[MAILPOET-6429]
This commit is contained in:
Pavel Dohnal
2025-01-22 14:01:05 +01:00
committed by Aschepikov
parent 997de285c9
commit 6f8a1716c0

View File

@@ -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 }