Skip to content

Commit 3c661f3

Browse files
committed
Lint
1 parent 4a5aa2c commit 3c661f3

9 files changed

+234
-169
lines changed

products/jbrowse-desktop/src/components/StartScreen/GenomesPanel.tsx renamed to products/jbrowse-desktop/src/components/StartScreen/FavoriteGenomesPanel.tsx

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { useState } from 'react'
22

33
import { ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui'
4-
import { useLocalStorage } from '@jbrowse/core/util'
54
import { Button, Checkbox, Typography } from '@mui/material'
65
import deepmerge from 'deepmerge'
76
import useSWR from 'swr'
87
import { makeStyles } from 'tss-react/mui'
98

10-
import AllGenomesDialog from './AllGenomesDialog'
119
import { addRelativeUris, fetchjson, loadPluginManager } from './util'
1210

1311
import type { JBrowseConfig } from './types'
@@ -17,6 +15,8 @@ const { ipcRenderer } = window.require('electron')
1715

1816
const useStyles = makeStyles()(theme => ({
1917
button: {
18+
float: 'right',
19+
height: '3em',
2020
margin: theme.spacing(2),
2121
},
2222
panel: {
@@ -32,24 +32,19 @@ const useStyles = makeStyles()(theme => ({
3232
},
3333
table: {
3434
width: '100%',
35-
borderCollapse: 'collapse',
3635
},
3736
}))
3837

3938
function GenomesPanel({
4039
setPluginManager,
40+
favorites,
4141
}: {
4242
setPluginManager: (arg0: PluginManager) => void
43+
favorites: string[]
4344
}) {
4445
const { classes } = useStyles()
4546
const [error, setError] = useState<unknown>()
4647
const [selected, setSelected] = useState({} as Record<string, boolean>)
47-
const [showAll, setShowAll] = useState(false)
48-
const [favorites, setFavorites] = useLocalStorage<string[]>(
49-
'jbrowse-genome-favorites',
50-
['hs1', 'hg38', 'hg19', 'mm39', 'mm10'],
51-
)
52-
5348
const { data: list, error: fetchError } = useSWR(
5449
'quickstarts',
5550
() =>
@@ -90,7 +85,9 @@ function GenomesPanel({
9085
<div>
9186
{e ? <ErrorMessage error={e} /> : null}
9287
<Typography variant="h6" className={classes.mb}>
93-
Favorite genomes{' '}
88+
Favorite genomes
89+
</Typography>
90+
<div>
9491
<Button
9592
className={classes.button}
9693
variant="contained"
@@ -106,15 +103,8 @@ function GenomesPanel({
106103
>
107104
Go
108105
</Button>
109-
<Button
110-
variant="contained"
111-
onClick={() => {
112-
setShowAll(true)
113-
}}
114-
>
115-
Show all available genomes
116-
</Button>
117-
</Typography>
106+
</div>
107+
118108
<div className={classes.panel}>
119109
{list ? (
120110
<table className={classes.table}>
@@ -124,9 +114,9 @@ function GenomesPanel({
124114
.slice(0, 10)
125115
.map(([name, val]) => (
126116
<tr key={name}>
127-
<td>
117+
<td style={{ width: 40 }}>
128118
<Checkbox
129-
style={{ padding: 2 }}
119+
style={{ padding: 0 }}
130120
checked={selected[name] || false}
131121
onChange={() => {
132122
setSelected({
@@ -146,16 +136,6 @@ function GenomesPanel({
146136
<LoadingEllipses />
147137
)}
148138
</div>
149-
{showAll ? (
150-
<AllGenomesDialog
151-
favorites={favorites}
152-
setFavorites={setFavorites}
153-
launch={launchMainBrowsers}
154-
onClose={() => {
155-
setShowAll(false)
156-
}}
157-
/>
158-
) : null}
159139
</div>
160140
)
161141
}

products/jbrowse-desktop/src/components/StartScreen/GenArkDataTable.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const useStyles = makeStyles()(theme => ({
5353
span: {
5454
gap: 10,
5555
display: 'flex',
56+
marginBottom: 20,
5657
},
5758

5859
panel: {
Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1+
import { useState } from 'react'
2+
3+
import { ErrorMessage } from '@jbrowse/core/ui'
4+
import { useLocalStorage } from '@jbrowse/core/util'
5+
import deepmerge from 'deepmerge'
16
import { makeStyles } from 'tss-react/mui'
27

3-
import GenomesPanel from './GenomesPanel'
8+
import FavoriteGenomesPanel from './FavoriteGenomesPanel'
49
import OpenSequencePanel from './OpenSequencePanel'
10+
import QuickstartPanel from './QuickstartPanel'
11+
import { fetchjson, loadPluginManager } from './util'
512

13+
import type { JBrowseConfig } from './types'
614
import type PluginManager from '@jbrowse/core/PluginManager'
715

16+
const { ipcRenderer } = window.require('electron')
17+
818
const useStyles = makeStyles()(theme => ({
919
form: {
1020
marginTop: theme.spacing(4),
21+
display: 'flex',
22+
flexDirection: 'column',
23+
gap: 20,
1124
},
1225
}))
1326

@@ -17,11 +30,52 @@ export default function LauncherPanel({
1730
setPluginManager: (arg0: PluginManager) => void
1831
}) {
1932
const { classes } = useStyles()
33+
const [error, setError] = useState<unknown>()
34+
const [favorites, setFavorites] = useLocalStorage<string[]>(
35+
'jbrowse-genome-favorites',
36+
['hs1', 'hg38', 'hg19', 'mm39', 'mm10'],
37+
)
38+
39+
async function launch(sel: string[]) {
40+
try {
41+
setError(undefined)
42+
const config = deepmerge.all(
43+
await Promise.all(
44+
sel.map(async entry => {
45+
const ret = (await fetchjson(entry)) as JBrowseConfig
46+
// @ts-expect-error
47+
addRelativeUris(ret as Record<string, unknown>, new URL(entry))
48+
return ret
49+
}),
50+
),
51+
)
52+
53+
const path = await ipcRenderer.invoke('createInitialAutosaveFile', {
54+
...config,
55+
defaultSession: {
56+
name: `New session ${new Date().toLocaleString('en-US')}`,
57+
},
58+
})
59+
setPluginManager(await loadPluginManager(path))
60+
} catch (e) {
61+
console.error(e)
62+
setError(e)
63+
}
64+
}
2065
return (
2166
<div className={classes.form}>
22-
<OpenSequencePanel setPluginManager={setPluginManager} />
23-
24-
<GenomesPanel setPluginManager={setPluginManager} />
67+
{error ? <ErrorMessage error={error} /> : null}
68+
<OpenSequencePanel
69+
setPluginManager={setPluginManager}
70+
favorites={favorites}
71+
setFavorites={setFavorites}
72+
launch={launch}
73+
/>
74+
<FavoriteGenomesPanel
75+
favorites={favorites}
76+
setPluginManager={setPluginManager}
77+
/>
78+
<QuickstartPanel setPluginManager={setPluginManager} />
2579
</div>
2680
)
2781
}

products/jbrowse-desktop/src/components/StartScreen/MainGenomesDialogPanel.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import { fetchjson } from './util'
2626
import type { UCSCListGenome } from './types'
2727

2828
const useStyles = makeStyles()(theme => ({
29+
button: {
30+
margin: 5,
31+
},
2932
ml: {
3033
marginLeft: 10,
3134
},
@@ -129,7 +132,7 @@ export default function MainGenomesDialogPanel({
129132
setFavorites(['hs1', 'hg38', 'hg19', 'mm39', 'mm10'])
130133
}}
131134
>
132-
Reset favorites
135+
Reset favorites list to defaults
133136
</Button>
134137
<Checkbox2
135138
className={classes.ml}

products/jbrowse-desktop/src/components/StartScreen/OpenSequencePanel.tsx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,36 @@ import { Button, Typography } from '@mui/material'
44
import { makeStyles } from 'tss-react/mui'
55

66
import OpenSequenceDialog from '../OpenSequenceDialog'
7+
import AllGenomesDialog from './AllGenomesDialog'
78
import { loadPluginManager } from './util'
89

910
import type PluginManager from '@jbrowse/core/PluginManager'
1011

1112
const { ipcRenderer } = window.require('electron')
1213

1314
const useStyles = makeStyles()(() => ({
14-
container: {
15-
marginBottom: 50,
16-
},
1715
button: {
1816
margin: 5,
1917
},
2018
}))
2119

2220
export default function OpenSequencePanel({
2321
setPluginManager,
22+
favorites,
23+
setFavorites,
24+
launch,
2425
}: {
2526
setPluginManager: (arg0: PluginManager) => void
27+
favorites: string[]
28+
setFavorites: (arg: string[]) => void
29+
launch: (arg: any) => void
2630
}) {
2731
const { classes } = useStyles()
2832
const [sequenceDialogOpen, setSequenceDialogOpen] = useState(false)
33+
const [showAll, setShowAll] = useState(false)
2934

3035
return (
31-
<div className={classes.container}>
36+
<div>
3237
<Typography variant="h6" style={{ marginBottom: 5 }}>
3338
Select a sequence file e.g. reference genome FASTA file
3439
</Typography>
@@ -42,6 +47,14 @@ export default function OpenSequencePanel({
4247
>
4348
Open sequence file(s)
4449
</Button>
50+
<Button
51+
variant="contained"
52+
onClick={() => {
53+
setShowAll(true)
54+
}}
55+
>
56+
Show all available genomes
57+
</Button>
4558

4659
{sequenceDialogOpen ? (
4760
<OpenSequenceDialog
@@ -64,6 +77,17 @@ export default function OpenSequencePanel({
6477
}}
6578
/>
6679
) : null}
80+
81+
{showAll ? (
82+
<AllGenomesDialog
83+
favorites={favorites}
84+
setFavorites={setFavorites}
85+
launch={launch}
86+
onClose={() => {
87+
setShowAll(false)
88+
}}
89+
/>
90+
) : null}
6791
</div>
6892
)
6993
}

0 commit comments

Comments
 (0)