GMOD / jbrowse-components

Source code for JBrowse 2, a modern React-based genome browser
https://jbrowse.org/jb2
Apache License 2.0
207 stars 62 forks source link

Create "Loading" and "Error" states for tracks #251

Closed cmdcolin closed 5 years ago

cmdcolin commented 5 years ago

A track should probably be able to set a loading and/or error state on the model and have the track automatically make a message from it

rbuels commented 5 years ago

Right now loading and error states are part of the block, see the block MST models

On Tue, Apr 16, 2019 at 1:09 PM Colin Diesh notifications@github.com wrote:

A track should probably be able to set a loading and/or error state on the model and have the track automatically make a message from it

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GMOD/jbrowse-components/issues/251, or mute the thread https://github.com/notifications/unsubscribe-auth/AAASAFKWUK24TSJ7RAUBSBLPQYXA3ANCNFSM4HGOOFRA .

cmdcolin commented 5 years ago

I was considering something like this to set it via the track level

diff --git a/packages/jbrowse-web/src/plugins/LinearGenomeView/models/blockBasedTrack.js b/packages/jbrowse-web/src/plugins/LinearGenomeView
/models/blockBasedTrack.js
index 6178b1d..ad6b855 100644
--- a/packages/jbrowse-web/src/plugins/LinearGenomeView/models/blockBasedTrack.js
+++ b/packages/jbrowse-web/src/plugins/LinearGenomeView/models/blockBasedTrack.js
@@ -93,6 +93,16 @@ export default types.compose(
           }),
         )
       },
+      setError(error) {
+        self.blockState.forEach(value => {
+          value.setError(error)
+        })
+      },
+      setLoading() {
+        self.blockState.forEach(value => {
+          value.setLoading()
+        })
+      },
       deleteBlock(key) {
rbuels commented 5 years ago

The right approach would probably be to add states for this to the track MST models, and to alter BlockBasedTrack.js to not call <TrackBlocks> if there is a track message or a track error.

rbuels commented 5 years ago

The track message support was already implemented in https://github.com/GMOD/jbrowse-components/commit/59de2319934a91275c397c59f2eaa69f103a79b0, but we still need track errors.

cmdcolin commented 5 years ago

If we set track.error on the mst model, then the error state is handled properly now following #326

If I misunderstand let me know but things like 404 and other errors are given a simple message