-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sidebar Navigation: Refactoring the delete modal with ConfirmDialog (#…
- Loading branch information
Showing
1 changed file
with
14 additions
and
35 deletions.
There are no files selected for viewing
49 changes: 14 additions & 35 deletions
49
packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/delete-modal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,24 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__experimentalHStack as HStack, | ||
__experimentalVStack as VStack, | ||
Button, | ||
Modal, | ||
} from '@wordpress/components'; | ||
import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
export default function RenameModal( { onClose, onConfirm } ) { | ||
return ( | ||
<Modal title={ __( 'Delete' ) } onRequestClose={ onClose }> | ||
<form> | ||
<VStack spacing="3"> | ||
<p> | ||
{ __( | ||
'Are you sure you want to delete this Navigation menu?' | ||
) } | ||
</p> | ||
<HStack justify="right"> | ||
<Button variant="tertiary" onClick={ onClose }> | ||
{ __( 'Cancel' ) } | ||
</Button> | ||
<ConfirmDialog | ||
isOpen={ true } | ||
onConfirm={ ( e ) => { | ||
e.preventDefault(); | ||
onConfirm(); | ||
|
||
<Button | ||
variant="primary" | ||
type="submit" | ||
onClick={ ( e ) => { | ||
e.preventDefault(); | ||
onConfirm(); | ||
|
||
// Immediate close avoids ability to hit delete multiple times. | ||
onClose(); | ||
} } | ||
> | ||
{ __( 'Delete' ) } | ||
</Button> | ||
</HStack> | ||
</VStack> | ||
</form> | ||
</Modal> | ||
// Immediate close avoids ability to hit delete multiple times. | ||
onClose(); | ||
} } | ||
onCancel={ onClose } | ||
confirmButtonText={ __( 'Delete' ) } | ||
> | ||
{ __( 'Are you sure you want to delete this Navigation menu?' ) } | ||
</ConfirmDialog> | ||
); | ||
} |