UNPKG

@wordpress/widget-dashboard

Version:

Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.

36 lines (35 loc) • 1.5 kB
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"; // packages/widget-dashboard/src/components/reset-confirmation/reset-confirmation.tsx /** * Confirmation prompt for resetting the dashboard to its default layout, * mounted by the engine and shown while `resetDialogOpen` is set in the * shared UI context. Confirming runs `onLayoutReset` and leaves customize * mode. Renders nothing while the policy denies `reset`, so no trigger can * reach the handler around the hidden entry points. */ 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