Command Menu improvements (#857)
* Add dialogs for reset and clear actions + clear stores * Catch failures * Improve tests, don't reset store on failure * Remove unnecessary i18n string --------- Co-authored-by: philon- <philon-@users.noreply.github.com>
This commit is contained in:
co-authored by
philon-
parent
1bdd923365
commit
8cc451546d
@@ -0,0 +1,35 @@
|
||||
import { clearAllStores } from "@core/stores";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { DialogWrapper } from "../DialogWrapper.tsx";
|
||||
|
||||
export interface ClearAllStoresDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}
|
||||
|
||||
export const ClearAllStoresDialog = ({
|
||||
open,
|
||||
onOpenChange,
|
||||
}: ClearAllStoresDialogProps) => {
|
||||
const { t } = useTranslation("dialog");
|
||||
|
||||
const handleClearAllStores = () => {
|
||||
clearAllStores();
|
||||
|
||||
// Reload the app to ensure all state is cleared
|
||||
window.location.href = "/";
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogWrapper
|
||||
open={open}
|
||||
onOpenChange={onOpenChange}
|
||||
type="confirm"
|
||||
variant="destructive"
|
||||
title={t("clearAllStores.title")}
|
||||
description={t("clearAllStores.description")}
|
||||
confirmText={t("clearAllStores.confirm")}
|
||||
onConfirm={handleClearAllStores}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user