Skip to content

Commit

Permalink
Move file-reset comfirmation message to a dialog (#261)
Browse files Browse the repository at this point in the history
Move reset files comfirmation to dialog
  • Loading branch information
netalondon authored Apr 6, 2024
1 parent 9b811f0 commit df509e9
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions web/src/shell/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const Settings = () => {
}, [fs, writeLocale]);

const resetWarning = useDialog();
const resetConfirm = useDialog();

const resetFiles = async () => {
const version = getVersion();
Expand All @@ -39,7 +40,6 @@ export const Settings = () => {
localStorage["/chip/project"] = "01";
localStorage["/chip/chip"] = "Not";
await loaders.resetFiles(fs);
setStatus("Your files were reset");
};

const resetWarningDialog = (
Expand All @@ -63,6 +63,7 @@ export const Settings = () => {
onClick={async () => {
await resetFiles();
resetWarning.close();
resetConfirm.open();
}}
>
Yes
Expand All @@ -81,6 +82,17 @@ export const Settings = () => {
</dialog>
);

const resetConfirmDialog = (
<dialog open={resetConfirm.isOpen}>
<article>
<header>Your files were reset</header>
<main>
<button onClick={resetConfirm.close}>Ok</button>
</main>
</article>
</dialog>
);

return (
<>
<dialog open={settings.isOpen}>
Expand Down Expand Up @@ -140,14 +152,6 @@ export const Settings = () => {
>
<Trans>Reset</Trans>
</button>
{/* <button
onClick={async () => {
await loaders.loadSolutions(fs);
setStatus("Loaded sample solutions...");
}}
>
<Trans>Solutions</Trans>
</button> */}
<button
onClick={async () => {
await loaders.loadSamples(fs);
Expand Down Expand Up @@ -248,16 +252,7 @@ export const Settings = () => {
</article>
</dialog>
{resetWarningDialog}
{resetConfirmDialog}
</>
);
// dt("Numeric Format"),
// dd(
// ButtonBar({
// value: "B",
// values: ["B", "D", "X", "A"],
// events: {
// onSelect: () => {},
// },
// })
// )
};

0 comments on commit df509e9

Please sign in to comment.