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

Fix 'Show no tracks active button' checkbox not working #4473

Merged
merged 1 commit into from
Jul 1, 2024
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
@@ -1,19 +1,16 @@
import React, { lazy, useEffect, useRef } from 'react'
import { Button, Paper, Typography } from '@mui/material'
import React, { lazy, Suspense, useEffect, useRef } from 'react'
import { makeStyles } from 'tss-react/mui'
import { LoadingEllipses } from '@jbrowse/core/ui'
import { getSession } from '@jbrowse/core/util'
import { observer } from 'mobx-react'

// icons
import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons'

// locals
import { LinearGenomeViewModel } from '..'
import TrackContainer from './TrackContainer'
import TracksContainer from './TracksContainer'

const ImportForm = lazy(() => import('./ImportForm'))
const NoTracksActiveButton = lazy(() => import('./NoTracksActiveButton'))

type LGV = LinearGenomeViewModel

Expand All @@ -31,31 +28,6 @@ const useStyles = makeStyles()(theme => ({
},
}))

function NoTracksActive({ model }: { model: LinearGenomeViewModel }) {
const { classes } = useStyles()
const { hideNoTracksActive } = model
return (
<Paper className={classes.note}>
{!hideNoTracksActive ? (
<>
<Typography>No tracks active.</Typography>
<Button
variant="contained"
color="primary"
onClick={() => model.activateTrackSelector()}
className={classes.top}
startIcon={<TrackSelectorIcon />}
>
Open track selector
</Button>
</>
) : (
<div style={{ height: '48px' }}></div>
)}
</Paper>
)
}

const LinearGenomeView = observer(({ model }: { model: LGV }) => {
const { tracks, error, initialized, hasDisplayedRegions } = model
const ref = useRef<HTMLDivElement>(null)
Expand Down Expand Up @@ -109,7 +81,9 @@ const LinearGenomeView = observer(({ model }: { model: LGV }) => {
<MiniControlsComponent model={model} />
<TracksContainer model={model}>
{!tracks.length ? (
<NoTracksActive model={model} />
<Suspense fallback={<React.Fragment />}>
<NoTracksActiveButton model={model} />
</Suspense>
) : (
tracks.map(track => (
<TrackContainer key={track.id} model={model} track={track} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react'
import { Button, Paper, Typography } from '@mui/material'
import { makeStyles } from 'tss-react/mui'
import { observer } from 'mobx-react'

// icons
import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons'

// locals
import { LinearGenomeViewModel } from '..'

const useStyles = makeStyles()(theme => ({
note: {
textAlign: 'center',
paddingTop: theme.spacing(1),
paddingBottom: theme.spacing(1),
},
top: {
zIndex: 1000,
},
}))

const NoTracksActiveButton = observer(function ({
model,
}: {
model: LinearGenomeViewModel
}) {
const { classes } = useStyles()
const { hideNoTracksActive } = model
return (
<Paper className={classes.note}>
{!hideNoTracksActive ? (
<>
<Typography>No tracks active.</Typography>
<Button
variant="contained"
color="primary"
onClick={() => model.activateTrackSelector()}
className={classes.top}
startIcon={<TrackSelectorIcon />}
>
Open track selector
</Button>
</>
) : (
<div style={{ height: '48px' }}></div>
)}
</Paper>
)
})

export default NoTracksActiveButton
Loading