-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2236 from GMOD/assembly_loading_error
Detect assembly loading error and encapsulate error instead of failing at app level
- Loading branch information
Showing
24 changed files
with
1,273 additions
and
1,219 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
87 changes: 87 additions & 0 deletions
87
plugins/circular-view/src/CircularView/components/ImportForm.tsx
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,87 @@ | ||
import React, { useState } from 'react' | ||
import { observer } from 'mobx-react' | ||
import { getSession } from '@jbrowse/core/util' | ||
|
||
// material-ui stuff | ||
import { | ||
Button, | ||
Container, | ||
Grid, | ||
Typography, | ||
makeStyles, | ||
} from '@material-ui/core' | ||
import AssemblySelector from '@jbrowse/core/ui/AssemblySelector' | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
importFormContainer: { | ||
marginBottom: theme.spacing(4), | ||
}, | ||
})) | ||
|
||
const ErrorDisplay = observer(({ error }: { error?: Error | string }) => { | ||
return ( | ||
<Typography variant="h6" color="error"> | ||
{`${error}`} | ||
</Typography> | ||
) | ||
}) | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const ImportForm = observer(({ model }: { model: any }) => { | ||
const classes = useStyles() | ||
const session = getSession(model) | ||
const { error: modelError } = model | ||
const { assemblyNames, assemblyManager } = session | ||
const [selectedAsm, setSelectedAsm] = useState(assemblyNames[0]) | ||
const [error, setError] = useState<Error | undefined>(modelError) | ||
const assembly = assemblyManager.get(selectedAsm) | ||
const assemblyError = assemblyNames.length | ||
? assembly?.error | ||
: 'No configured assemblies' | ||
const regions = assembly?.regions || [] | ||
const err = assemblyError || error | ||
|
||
return ( | ||
<> | ||
<Container className={classes.importFormContainer}> | ||
{err ? ( | ||
<Grid | ||
container | ||
spacing={1} | ||
justifyContent="center" | ||
alignItems="center" | ||
> | ||
<Grid item> | ||
<ErrorDisplay error={err} /> | ||
</Grid> | ||
</Grid> | ||
) : null} | ||
<Grid container spacing={1} justifyContent="center" alignItems="center"> | ||
<Grid item> | ||
<AssemblySelector | ||
onChange={val => { | ||
setError(undefined) | ||
setSelectedAsm(val) | ||
}} | ||
session={session} | ||
selected={selectedAsm} | ||
/> | ||
</Grid> | ||
|
||
<Grid item> | ||
<Button | ||
disabled={!(regions && regions.length)} | ||
onClick={() => model.setDisplayedRegions(regions)} | ||
variant="contained" | ||
color="primary" | ||
> | ||
{regions.length ? 'Open' : 'Loading…'} | ||
</Button> | ||
</Grid> | ||
</Grid> | ||
</Container> | ||
</> | ||
) | ||
}) | ||
|
||
export default ImportForm |
Oops, something went wrong.