Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error reporting on jbrowse-web start screen when user attempts to open a broken recent session #3198

Merged
merged 4 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ const useStyles = makeStyles()({
},
})

function RecentSessionCard({ sessionName, onClick, onDelete }) {
function RecentSessionCard({
sessionName,
onClick,
onDelete,
}: {
sessionName: string
onClick: (arg: string) => void
onDelete: (arg: string) => void
}) {
const { classes } = useStyles()
const [hovered, setHovered] = useState(false)
const [menuAnchorEl, setMenuAnchorEl] = useState(null)
const [menuAnchorEl, setMenuAnchorEl] = useState<HTMLElement | null>(null)

function onMenuClick(event) {
event.stopPropagation()
setMenuAnchorEl(event.currentTarget)
}

const handleMenuClose = action => {
const handleMenuClose = (action: string) => {
setMenuAnchorEl(null)
if (action === 'delete') {
return onDelete(sessionName)
Expand All @@ -38,19 +40,19 @@ function RecentSessionCard({ sessionName, onClick, onDelete }) {

return (
<>
<ListItem
onMouseOver={() => setHovered(true)}
onMouseOut={() => setHovered(false)}
onClick={() => onClick(sessionName)}
raised={Boolean(hovered)}
button
>
<ListItem onClick={() => onClick(sessionName)} button>
<Tooltip title={sessionName} enterDelay={300}>
<Typography variant="body2" noWrap style={{ width: 250 }}>
{sessionName}
</Typography>
</Tooltip>
<IconButton className={classes.menu} onClick={onMenuClick}>
<IconButton
className={classes.menu}
onClick={event => {
event.stopPropagation()
setMenuAnchorEl(event.currentTarget)
}}
>
<MoreVertIcon color="secondary" />
</IconButton>
</ListItem>
Expand Down
8 changes: 4 additions & 4 deletions products/jbrowse-web/src/StartScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { makeStyles } from 'tss-react/mui'
import WarningIcon from '@mui/icons-material/Warning'
import SettingsIcon from '@mui/icons-material/Settings'

import { LogoFull, FactoryResetDialog } from '@jbrowse/core/ui'
import { LogoFull, FactoryResetDialog, ErrorMessage } from '@jbrowse/core/ui'
import {
NewEmptySession,
NewLinearGenomeViewSession,
Expand Down Expand Up @@ -109,6 +109,7 @@ export default function StartScreen({
const [sessions, setSessions] = useState<Record<string, any>>()
const [sessionToDelete, setSessionToDelete] = useState<string>()
const [sessionToLoad, setSessionToLoad] = useState<string>()
const [error, setError] = useState<unknown>()
const [updateSessionsList, setUpdateSessionsList] = useState(true)
const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null)
const [reset, setReset] = useState(false)
Expand All @@ -121,9 +122,7 @@ export default function StartScreen({
rootModel.activateSession(sessionToLoad)
}
} catch (e) {
setSessions(() => {
throw e
})
setError(e)
}
})()
}, [rootModel, sessionToLoad])
Expand Down Expand Up @@ -226,6 +225,7 @@ export default function StartScreen({
/>
))}
</List>
{error ? <ErrorMessage error={error} /> : null}
</div>
</Container>

Expand Down