Skip to content

Commit 445619e

Browse files
committed
Small fix
1 parent 9b36951 commit 445619e

File tree

1 file changed

+98
-96
lines changed
  • plugins/linear-genome-view/src/LinearGenomeView/components

1 file changed

+98
-96
lines changed

plugins/linear-genome-view/src/LinearGenomeView/components/ImportForm.tsx

Lines changed: 98 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const LinearGenomeViewImportForm = observer(
3838
const { classes } = useStyles()
3939
const session = getSession(model)
4040
const { assemblyNames, assemblyManager } = session
41-
const { error } = model
41+
const { initialized, error } = model
4242
const [selectedAsm, setSelectedAsm] = useState(assemblyNames[0]!)
4343
const [option, setOption] = useState<BaseResult>()
4444
const assembly = assemblyManager.get(selectedAsm)
@@ -66,104 +66,106 @@ const LinearGenomeViewImportForm = observer(
6666
return (
6767
<div className={classes.container}>
6868
{displayError ? <ErrorMessage error={displayError} /> : null}
69-
<Container className={classes.importFormContainer}>
70-
<form
71-
onSubmit={async event => {
72-
event.preventDefault()
73-
model.setError(undefined)
74-
if (value) {
75-
// has it's own error handling
76-
try {
77-
if (
78-
option?.getDisplayString() === value &&
79-
option.hasLocation()
80-
) {
81-
await navToOption({
82-
option,
83-
model,
84-
assemblyName: selectedAsm,
85-
})
86-
} else if (option?.results?.length) {
87-
model.setSearchResults(
88-
option.results,
89-
option.getLabel(),
90-
selectedAsm,
91-
)
92-
} else if (assembly) {
93-
await handleSelectedRegion({
94-
input: value,
95-
assembly,
96-
model,
97-
})
69+
{initialized ? (
70+
<Container className={classes.importFormContainer}>
71+
<form
72+
onSubmit={async event => {
73+
event.preventDefault()
74+
model.setError(undefined)
75+
if (value) {
76+
// has it's own error handling
77+
try {
78+
if (
79+
option?.getDisplayString() === value &&
80+
option.hasLocation()
81+
) {
82+
await navToOption({
83+
option,
84+
model,
85+
assemblyName: selectedAsm,
86+
})
87+
} else if (option?.results?.length) {
88+
model.setSearchResults(
89+
option.results,
90+
option.getLabel(),
91+
selectedAsm,
92+
)
93+
} else if (assembly) {
94+
await handleSelectedRegion({
95+
input: value,
96+
assembly,
97+
model,
98+
})
99+
}
100+
} catch (e) {
101+
console.error(e)
102+
session.notify(`${e}`, 'warning')
98103
}
99-
} catch (e) {
100-
console.error(e)
101-
session.notify(`${e}`, 'warning')
102104
}
103-
}
104-
}}
105-
>
106-
<Grid
107-
container
108-
spacing={1}
109-
justifyContent="center"
110-
alignItems="center"
105+
}}
111106
>
112-
<FormControl>
113-
<AssemblySelector
114-
onChange={val => {
115-
setSelectedAsm(val)
116-
}}
117-
localStorageKey="lgv"
118-
session={session}
119-
selected={selectedAsm}
120-
/>
121-
</FormControl>
122-
{selectedAsm ? (
123-
assemblyError ? (
124-
<CloseIcon style={{ color: 'red' }} />
125-
) : assemblyLoaded ? (
126-
<FormControl>
127-
<ImportFormRefNameAutocomplete
128-
value={value}
129-
setValue={setValue}
130-
selectedAsm={selectedAsm}
131-
setOption={setOption}
132-
model={model}
133-
/>
134-
</FormControl>
135-
) : (
136-
<CircularProgress size={20} disableShrink />
137-
)
138-
) : null}
139-
<FormControl>
140-
<Button
141-
type="submit"
142-
disabled={!value}
143-
className={classes.button}
144-
variant="contained"
145-
color="primary"
146-
>
147-
Open
148-
</Button>
149-
</FormControl>
150-
<FormControl>
151-
<Button
152-
disabled={!value}
153-
className={classes.button}
154-
onClick={() => {
155-
model.setError(undefined)
156-
model.showAllRegionsInAssembly(selectedAsm)
157-
}}
158-
variant="contained"
159-
color="secondary"
160-
>
161-
Show all regions in assembly
162-
</Button>
163-
</FormControl>
164-
</Grid>
165-
</form>
166-
</Container>
107+
<Grid
108+
container
109+
spacing={1}
110+
justifyContent="center"
111+
alignItems="center"
112+
>
113+
<FormControl>
114+
<AssemblySelector
115+
onChange={val => {
116+
setSelectedAsm(val)
117+
}}
118+
localStorageKey="lgv"
119+
session={session}
120+
selected={selectedAsm}
121+
/>
122+
</FormControl>
123+
{selectedAsm ? (
124+
assemblyError ? (
125+
<CloseIcon style={{ color: 'red' }} />
126+
) : assemblyLoaded ? (
127+
<FormControl>
128+
<ImportFormRefNameAutocomplete
129+
value={value}
130+
setValue={setValue}
131+
selectedAsm={selectedAsm}
132+
setOption={setOption}
133+
model={model}
134+
/>
135+
</FormControl>
136+
) : (
137+
<CircularProgress size={20} disableShrink />
138+
)
139+
) : null}
140+
<FormControl>
141+
<Button
142+
type="submit"
143+
disabled={!value}
144+
className={classes.button}
145+
variant="contained"
146+
color="primary"
147+
>
148+
Open
149+
</Button>
150+
</FormControl>
151+
<FormControl>
152+
<Button
153+
disabled={!value}
154+
className={classes.button}
155+
onClick={() => {
156+
model.setError(undefined)
157+
model.showAllRegionsInAssembly(selectedAsm)
158+
}}
159+
variant="contained"
160+
color="secondary"
161+
>
162+
Show all regions in assembly
163+
</Button>
164+
</FormControl>
165+
</Grid>
166+
</form>
167+
</Container>
168+
) : null}
167169
</div>
168170
)
169171
},

0 commit comments

Comments
 (0)