diff --git a/packages/js/email-editor/src/components/sidebar/template-info.tsx b/packages/js/email-editor/src/components/sidebar/template-info.tsx index ccc0e236dd..b3d4967985 100644 --- a/packages/js/email-editor/src/components/sidebar/template-info.tsx +++ b/packages/js/email-editor/src/components/sidebar/template-info.tsx @@ -4,10 +4,15 @@ import { PanelRow, DropdownMenu, MenuItem, + Modal, + Button, + Flex, + FlexItem, } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -import { useSelect } from '@wordpress/data'; +import { useSelect, useDispatch } from '@wordpress/data'; import { Icon, layout, moreVertical } from '@wordpress/icons'; +import { useState } from '@wordpress/element'; import { storeName } from '../../store'; export function TemplateInfo() { @@ -15,52 +20,98 @@ export function TemplateInfo() { ( select ) => select( storeName ).getCurrentTemplate(), [] ); + const [ isResetConfirmOpen, setResetConfirmOpen ] = useState( false ); + const { revertAndSaveTemplate } = useDispatch( storeName ); + // @ts-expect-error Todo template type is not defined const description = template?.description || ''; + const closeResetConfirm = () => setResetConfirmOpen( false ); return ( - - - - - - -
-
-

- { /* @ts-expect-error Todo template type is not defined */ } - { template?.title || - __( 'Template', 'mailpoet' ) } -

- - { ( { onClose } ) => ( - { - onClose(); - } } - info={ __( - 'Reset to default to clear all customizations', - 'mailpoet' - ) } - > - { __( 'Reset', 'mailpoet' ) } - + <> + + + + + + +
+
+

+ { /* @ts-expect-error Todo template type is not defined */ } + { template?.title || + __( 'Template', 'mailpoet' ) } +

+ + { ( { onClose } ) => ( + { + setResetConfirmOpen( true ); + onClose(); + } } + info={ __( + 'Reset to default to clear all customizations', + 'mailpoet' + ) } + > + { __( 'Reset', 'mailpoet' ) } + + ) } + +
+ { description &&

{ description || '' }

} +

+ { __( + 'Edit this template to be used across multiple emails.', + 'mailpoet' ) } - +

- { description &&

{ description || '' }

} -

- { __( - 'Edit this template to be used across multiple emails.', - 'mailpoet' - ) } -

-
- - - + + + + { isResetConfirmOpen && ( + +

+ { __( + 'Reset to default and clear all customization?', + 'mailpoet' + ) } +

+ + + + + + + + +
+ ) } + ); }