@wordpress/block-library
Version:
Block library for the WordPress editor.
37 lines (36 loc) • 1.47 kB
JavaScript
import { Button, __experimentalConfirmDialog } from "@wordpress/components";
import { store, 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";
// packages/block-library/src/navigation/edit/navigation-menu-delete-control.jsx
function NavigationMenuDeleteControl({ onDelete }) {
const [isConfirmDialogVisible, setIsConfirmDialogVisible] = useState(false);
const id = useEntityId("postType", "wp_navigation");
const { deleteEntityRecord } = useDispatch(store);
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(__experimentalConfirmDialog, {
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.mjs.map