Skip to content

Commit

Permalink
Use ComfirmDialog component for Reset Settings Modal
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Mar 8, 2024
1 parent dddef2f commit c3208a1
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions src/admin/editor-config/components/controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import { Button, Flex, Modal } from '@wordpress/components';
import { Button, __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';

export default function Controls( { isWaiting, onUpdateOptions, onResetOptions } ) {
const [ isModalOpen, setIsModalOpen ] = useState( false );
Expand Down Expand Up @@ -35,31 +35,19 @@ export default function Controls( { isWaiting, onUpdateOptions, onResetOptions }
</li>
</ul>
{ isModalOpen && (
<Modal
title={ __( 'Reset settings', 'custom-html-block-extension' ) }
onRequestClose={ () => setIsModalOpen( false ) }
<ConfirmDialog
onConfirm={ () => {
onResetOptions();
setIsModalOpen( false );
} }
onCancel={ () => setIsModalOpen( false ) }
confirmButtonText={ __( 'Reset settings', 'custom-html-block-extension' ) }
>
<p>
{ __(
'Are you sure that reset all settings to default values ?',
'custom-html-block-extension'
) }
</p>
<Flex>
<Button
variant="primary"
onClick={ () => {
onResetOptions();
setIsModalOpen( false );
} }
>
{ __( 'Reset settings', 'custom-html-block-extension' ) }
</Button>
<Button variant="secondary" onClick={ () => setIsModalOpen( false ) }>
{ __( 'Cancel', 'custom-html-block-extension' ) }
</Button>
</Flex>
</Modal>
{ __(
'Are you sure that reset all settings to default values ?',
'custom-html-block-extension'
) }
</ConfirmDialog>
) }
</>
);
Expand Down

0 comments on commit c3208a1

Please sign in to comment.