FEATURE: get rid of the import a query modal (PR #127)

This is the new version of FEATURE: open a system file picker directly instead of opening the import modal by AndrewPrigorshnev · Pull Request #126 · discourse/discourse-data-explorer · GitHub. Now the pick-files-button moved to core.

To import a query into Data Explorer, you need to push the button and then deal with the import modal:

124735139-d168f500-df26-11eb-8b71-82f0ada18129

124735161-d75ed600-df26-11eb-943b-024c873df6da

Instead, we want just to be triggering a system file picker directly. This PR makes it happen.

GitHub

The title of this pull request changed from “Feature/get rid of the import a query modal 2” to "FEATURE: get rid of the import a query modal

I am just wondering why we need all these variants of the JSON type? Do different browsers send different things? Usually it is application/json

Looking good and I like the new component, just a few questions.

I think we should add some JSON parse error handling here, in case the JSON in the file is not correctly structured. Then you can show a message to the user and reset the loading state

Probably want to implement FileReader.onerror here as well to be able to reset the state and show a message on error. If this is a pattern we use in a few places in future we may want to refactor this out into a lib that we can import. No need for that yet though as this is the only place we are doing this so far :slight_smile:

E.g. app/lib/file-reader.js

You will need to set loading to false here too I assume?

Also do we know what the structure should look like ahead of time? Maybe we should check for the keys that are required and throw an error if the user doesn’t provide them?