-
Notifications
You must be signed in to change notification settings - Fork 0
feat: added json validation and import error modal #25
base: main
Are you sure you want to change the base?
Conversation
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 👍 |
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!) |
{errorFiles.length > 0 ? ( | ||
<FileErrorModal | ||
onClose={() => setErrorFiles([])} | ||
files={errorFiles} | ||
/> | ||
) : null} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{errorFiles.length > 0 ? ( | |
<FileErrorModal | |
onClose={() => setErrorFiles([])} | |
files={errorFiles} | |
/> | |
) : null} | |
{errorFiles.length > 0 && ( | |
<FileErrorModal | |
onClose={() => setErrorFiles([])} | |
files={errorFiles} | |
/> | |
)} |
<ErrorHeader>There was an error importing some files.</ErrorHeader> | ||
<ErrorText>Files that could not be imported:</ErrorText> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a header
and description
value to FileErrorModalProps
to make it easier to reuse in the future.
<ErrorList> | ||
{files.map((file, i) => ( | ||
<ErrorItem key={`${file}-${i}`}>{file}</ErrorItem> | ||
))} | ||
</ErrorList> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise for the error content, the list could be specified via a prop.
@@ -0,0 +1,455 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for naming, could we move this file to FeatureCollection.schema.json
?
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.