Skip to content

Commit

Permalink
Slightly improved typescripting
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Mar 4, 2024
1 parent 7a7e813 commit b21f4e8
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import React, { lazy } from 'react'
import { Tooltip, IconButton } from '@mui/material'

import { makeStyles } from 'tss-react/mui'
import { observer } from 'mobx-react'
import { getParent } from 'mobx-state-tree'
import { LoadingEllipses } from '@jbrowse/core/ui'
import { getSession } from '@jbrowse/core/util'

// icons
import RefreshIcon from '@mui/icons-material/Refresh'
import ReportIcon from '@mui/icons-material/Report'

// locals
import BlockMsg from './BlockMsg'
import { getSession } from '@jbrowse/core/util'

const ErrorMessageStackTraceDialog = lazy(
() => import('@jbrowse/core/ui/ErrorMessageStackTraceDialog'),
Expand All @@ -30,12 +29,10 @@ const useStyles = makeStyles()(theme => {
}
})

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const LoadingMessage = observer(({ model }: { model: any }) => {
const LoadingMessage = observer(({ model }: { model: { status?: string } }) => {
const { classes } = useStyles()
const { status: blockStatus } = model
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const { message: displayStatus } = getParent<any>(model, 2)
const { message: displayStatus } = getParent<{ message?: string }>(model, 2)
const status = displayStatus || blockStatus
return (
<div className={classes.loading}>
Expand All @@ -47,8 +44,14 @@ const LoadingMessage = observer(({ model }: { model: any }) => {
const ServerSideRenderedBlockContent = observer(function ({
model,
}: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
model: any
model: {
error?: unknown
reload: () => void
message: React.ReactNode
filled?: boolean
status?: string
reactElement?: React.ReactElement
}
}) {
if (model.error) {
return (
Expand All @@ -57,20 +60,18 @@ const ServerSideRenderedBlockContent = observer(function ({
severity="error"
action={
<>
<Tooltip title="Reload">
<IconButton
data-testid="reload_button"
onClick={() => model.reload()}
>
<RefreshIcon />
</IconButton>
</Tooltip>
<IconButton
data-testid="reload_button"
onClick={() => model.reload()}
>
<RefreshIcon />
</IconButton>
<Tooltip title="Show stack trace">
<IconButton
onClick={() => {
getSession(model).queueDialog(onClose => [
ErrorMessageStackTraceDialog,
{ onClose, error: model.error },
{ onClose, error: model.error as Error },
])
}}
>
Expand Down

0 comments on commit b21f4e8

Please sign in to comment.