This repository was archived by the owner on Oct 18, 2024. It is now read-only.
feat: added json validation and import error modal#25
Open
vincendiary wants to merge 2 commits intomainfrom
Open
feat: added json validation and import error modal#25vincendiary wants to merge 2 commits intomainfrom
vincendiary wants to merge 2 commits intomainfrom
Conversation
dellisd
suggested changes
Sep 10, 2021
Member
|
In general, this looks great. I'm a fan of listing the files that weren't able to load, and loading the ones that can 👍 |
Member
|
We could consider using a JSON Schema validator. There are pre-written schemas for GeoJSON out there, and lots of libraries that can validate JSON files (plus they can provide detailed parsing error messages!) |
deenhaque
reviewed
Sep 10, 2021
deenhaque
reviewed
Sep 10, 2021
dellisd
suggested changes
Sep 13, 2021
Comment on lines
+85
to
+90
| {errorFiles.length > 0 ? ( | ||
| <FileErrorModal | ||
| onClose={() => setErrorFiles([])} | ||
| files={errorFiles} | ||
| /> | ||
| ) : null} |
Member
There was a problem hiding this comment.
Suggested change
| {errorFiles.length > 0 ? ( | |
| <FileErrorModal | |
| onClose={() => setErrorFiles([])} | |
| files={errorFiles} | |
| /> | |
| ) : null} | |
| {errorFiles.length > 0 && ( | |
| <FileErrorModal | |
| onClose={() => setErrorFiles([])} | |
| files={errorFiles} | |
| /> | |
| )} |
Comment on lines
+16
to
+17
| <ErrorHeader>There was an error importing some files.</ErrorHeader> | ||
| <ErrorText>Files that could not be imported:</ErrorText> |
Member
There was a problem hiding this comment.
We should add a header and description value to FileErrorModalProps to make it easier to reuse in the future.
Comment on lines
+18
to
+22
| <ErrorList> | ||
| {files.map((file, i) => ( | ||
| <ErrorItem key={`${file}-${i}`}>{file}</ErrorItem> | ||
| ))} | ||
| </ErrorList> |
Member
There was a problem hiding this comment.
Likewise for the error content, the list could be specified via a prop.
| @@ -0,0 +1,455 @@ | |||
| { | |||
Member
There was a problem hiding this comment.
Just for naming, could we move this file to FeatureCollection.schema.json?
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #15
Preview:

I redid the file imports to map a filename to its FeatureCollection so we always have a reference to the file path, which is then passed onto the App. Here, files are filtered into a valid and invalid group using a rigorous and terrible method (very open to suggestions). All valid geo json are passed in as usual. If any invalid files are found, a modal is opened that lists their corresponding file paths. To close the modal, users can click the "x" icon or click outside of the modal.
Tested on an empty directory, a directory containing a half-empty json and a working geo json, and a directory containing working geo json files.