forked from excalidraw/excalidraw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn on invalid JSON file (excalidraw#1159)
* add error dialog * show error modal on file dnd * add locales * Update src/locales/en.json Co-Authored-By: Lipis <[email protected]> * Update src/data/blob.ts * Update src/data/blob.ts * fix titles, update snapshots * make modal smaller * fix dnd wrong file type * reset errorMessage Co-authored-by: Faustino Kialungila <[email protected]> Co-authored-by: Lipis <[email protected]>
- Loading branch information
1 parent
2be34ef
commit 0c9459e
Showing
9 changed files
with
108 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { useState } from "react"; | ||
import { t } from "../i18n"; | ||
|
||
import { Dialog } from "./Dialog"; | ||
|
||
export function ErrorDialog({ | ||
message, | ||
onClose, | ||
}: { | ||
message: string; | ||
onClose?: () => void; | ||
}) { | ||
const [modalIsShown, setModalIsShown] = useState(!!message); | ||
|
||
const handleClose = React.useCallback(() => { | ||
setModalIsShown(false); | ||
|
||
if (onClose) { | ||
onClose(); | ||
} | ||
}, [onClose]); | ||
|
||
return ( | ||
<> | ||
{modalIsShown && ( | ||
<Dialog | ||
maxWidth={500} | ||
onCloseRequest={handleClose} | ||
title={t("errorDialog.title")} | ||
> | ||
<div>{message}</div> | ||
</Dialog> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.