UNPKG

@wordpress/block-library

Version:
55 lines (54 loc) 1.72 kB
// packages/block-library/src/navigation/edit/navigation-menu-delete-control.js import { Button, __experimentalConfirmDialog as ConfirmDialog } from "@wordpress/components"; import { store as coreStore, useEntityId } from "@wordpress/core-data"; import { useDispatch } from "@wordpress/data"; import { useState } from "@wordpress/element"; import { __ } from "@wordpress/i18n"; import { Fragment, jsx, jsxs } from "react/jsx-runtime"; function NavigationMenuDeleteControl({ onDelete }) { const [isConfirmDialogVisible, setIsConfirmDialogVisible] = useState(false); const id = useEntityId("postType", "wp_navigation"); const { deleteEntityRecord } = useDispatch(coreStore); return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx( Button, { __next40pxDefaultSize: true, className: "wp-block-navigation-delete-menu-button", variant: "secondary", isDestructive: true, onClick: () => { setIsConfirmDialogVisible(true); }, children: __("Delete menu") } ), isConfirmDialogVisible && /* @__PURE__ */ jsx( ConfirmDialog, { isOpen: true, onConfirm: () => { deleteEntityRecord("postType", "wp_navigation", id, { force: true }); onDelete(); }, onCancel: () => { setIsConfirmDialogVisible(false); }, confirmButtonText: __("Delete"), size: "medium", children: __( "Are you sure you want to delete this Navigation Menu?" ) } ) ] }); } export { NavigationMenuDeleteControl as default }; //# sourceMappingURL=navigation-menu-delete-control.js.map