@wordpress/widget-dashboard
Version:
Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.
41 lines (40 loc) • 1.3 kB
JavaScript
// packages/widget-dashboard/src/components/reset-confirmation/reset-confirmation.tsx
import { __ } from "@wordpress/i18n";
import { AlertDialog } from "@wordpress/ui";
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
import { useDashboardUIContext } from "../../context/ui-context.mjs";
import { jsx } from "react/jsx-runtime";
function ResetConfirmation() {
const { onLayoutReset, onEditChange, canPerform } = useDashboardInternalContext();
const { resetDialogOpen, setResetDialogOpen } = useDashboardUIContext();
if (!canPerform({ operation: "reset" })) {
return null;
}
return /* @__PURE__ */ jsx(
AlertDialog.Root,
{
open: resetDialogOpen,
onOpenChange: setResetDialogOpen,
onConfirm: async () => {
await onLayoutReset?.();
onEditChange?.(false);
setResetDialogOpen(false);
},
children: /* @__PURE__ */ jsx(
AlertDialog.Popup,
{
intent: "irreversible",
title: __("Reset dashboard to default?"),
description: __(
"All customizations will be permanently lost."
),
confirmButtonText: __("Reset")
}
)
}
);
}
export {
ResetConfirmation
};
//# sourceMappingURL=reset-confirmation.mjs.map