Skip to content

Commit

Permalink
More notifyError
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 24, 2024
1 parent d551ec9 commit 075ed05
Show file tree
Hide file tree
Showing 26 changed files with 169 additions and 168 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export default tseslint.config(
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-deprecated': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const OldHydrate = observer(function OldHydrate(props: Props) {
function doHydrate() {
if (domNode && html) {
if (domNode.innerHTML) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
unmountComponentAtNode(domNode)
}

Expand All @@ -81,15 +81,15 @@ const OldHydrate = observer(function OldHydrate(props: Props) {
// hydration for when we have some free time. helps keep the
// framerate up.
rIC(() => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
hydrate(<RenderingComponent {...props} />, domNode)
})
}
}
doHydrate()
return () => {
if (domNode) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
unmountComponentAtNode(domNode)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ const OldHydrate = observer(function ({
const domNode = ref.current
function doHydrate() {
if (domNode) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
unmountComponentAtNode(domNode)
domNode.innerHTML = html

rIC(() => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
hydrate(
<ThemeProvider theme={jbrowseTheme}>
<RenderingComponent {...rest} />
Expand All @@ -102,7 +102,7 @@ const OldHydrate = observer(function ({

return () => {
if (domNode) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
unmountComponentAtNode(domNode)
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ export function renderToStaticMarkup(
if (createRootFn) {
createRootFn(div).render(node)
} else {
// eslint-disable-next-line @typescript-eslint/no-deprecated
render(node, div)
}
})
Expand Down
69 changes: 39 additions & 30 deletions packages/sv-core/src/BreakendMultiLevelOptionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, DialogActions, DialogContent } from '@mui/material'
import { getSnapshot } from 'mobx-state-tree'
import { Dialog } from '@jbrowse/core/ui'
import { when } from 'mobx'
import { getSession, Feature } from '@jbrowse/core/util'
import { Feature, AbstractSessionModel } from '@jbrowse/core/util'
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
import type { Assembly } from '@jbrowse/core/assemblyManager/assembly'

Expand All @@ -29,17 +29,17 @@ function stripIds(arr: Track[]) {
}

const BreakendMultiLevelOptionDialog = observer(function ({
model,
session,
handleClose,
feature,
assemblyName,
viewType,
view,
}: {
model: unknown
session: AbstractSessionModel
handleClose: () => void
feature: Feature
view: LinearGenomeViewModel
view?: LinearGenomeViewModel
assemblyName: string
viewType: {
getBreakendCoveringRegions: (arg: {
Expand All @@ -63,45 +63,52 @@ const BreakendMultiLevelOptionDialog = observer(function ({
title="Multi-level breakpoint split view options"
>
<DialogContent>
<Checkbox2
checked={copyTracks}
label="Copy tracks into the new view"
onChange={event => {
setCopyTracks(event.target.checked)
}}
/>
<div>Launch multi-level breakpoint split view</div>
{view ? (
<>
<Checkbox2
checked={copyTracks}
label="Copy tracks into the new view"
onChange={event => {
setCopyTracks(event.target.checked)
}}
/>

{copyTracks ? (
<Checkbox2
checked={mirror}
disabled={!copyTracks}
label="Mirror the copied tracks (only available if copying tracks and using two level)"
onChange={event => {
setMirror(event.target.checked)
}}
/>
{copyTracks ? (
<Checkbox2
checked={mirror}
disabled={!copyTracks}
label="Mirror the copied tracks (only available if copying tracks and using two level)"
onChange={event => {
setMirror(event.target.checked)
}}
/>
) : null}
</>
) : null}
</DialogContent>
<DialogActions>
<Button
onClick={() => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
;(async () => {
const session = getSession(model)
try {
const asm =
await session.assemblyManager.waitForAssembly(assemblyName)
if (!asm) {
const { assemblyManager } = session
const assembly =
await assemblyManager.waitForAssembly(assemblyName)
if (!assembly) {
throw new Error(`assembly ${assemblyName} not found`)
}

const { refName, pos, mateRefName, matePos } =
viewType.getBreakendCoveringRegions({
feature,
assembly: asm,
assembly: assembly,
})

const viewTracks = getSnapshot(view.tracks) as Track[]
const viewTracks = view
? (getSnapshot(view.tracks) as Track[])
: []
const breakpointSplitView = session.addView(
'BreakpointSplitView',
{
Expand All @@ -114,7 +121,7 @@ const BreakendMultiLevelOptionDialog = observer(function ({
{
type: 'LinearGenomeView',
hideHeader: true,
tracks: stripIds(getSnapshot(view.tracks)),
tracks: stripIds(viewTracks),
},
{
type: 'LinearGenomeView',
Expand All @@ -126,8 +133,10 @@ const BreakendMultiLevelOptionDialog = observer(function ({
],
},
) as unknown as { views: LinearGenomeViewModel[] }
const r1 = asm.regions!.find(r => r.refName === refName)
const r2 = asm.regions!.find(r => r.refName === mateRefName)
const r1 = assembly.regions!.find(r => r.refName === refName)
const r2 = assembly.regions!.find(
r => r.refName === mateRefName,
)
if (!r1 || !r2) {
throw new Error("can't find regions")
}
Expand Down Expand Up @@ -172,7 +181,7 @@ const BreakendMultiLevelOptionDialog = observer(function ({
breakpointSplitView.views[0]!.centerAt(pos, refName)
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
})()
handleClose()
Expand Down
39 changes: 23 additions & 16 deletions packages/sv-core/src/BreakendSingleLevelOptionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Button, DialogActions, DialogContent, TextField } from '@mui/material'
import { getSnapshot } from 'mobx-state-tree'
import { Dialog } from '@jbrowse/core/ui'
import {
getSession,
Feature,
gatherOverlaps,
useLocalStorage,
AbstractSessionModel,
} from '@jbrowse/core/util'
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
import type { Assembly } from '@jbrowse/core/assemblyManager/assembly'
Expand All @@ -33,17 +33,17 @@ function stripIds(arr: Track[]) {
}

const BreakendSingleLevelOptionDialog = observer(function ({
model,
session,
handleClose,
feature,
assemblyName,
viewType,
view,
}: {
model: unknown
session: AbstractSessionModel
handleClose: () => void
feature: Feature
view: LinearGenomeViewModel
view?: LinearGenomeViewModel
assemblyName: string
viewType: {
getBreakendCoveringRegions: (arg: {
Expand All @@ -70,13 +70,15 @@ const BreakendSingleLevelOptionDialog = observer(function ({
title="Single-level breakpoint split view options"
>
<DialogContent>
<Checkbox2
checked={copyTracks}
label="Copy tracks into the new view"
onChange={event => {
setCopyTracks(event.target.checked)
}}
/>
{view ? (
<Checkbox2
checked={copyTracks}
label="Copy tracks into the new view"
onChange={event => {
setCopyTracks(event.target.checked)
}}
/>
) : null}

<TextField
label="Window size (bp)"
Expand All @@ -89,17 +91,20 @@ const BreakendSingleLevelOptionDialog = observer(function ({
<DialogActions>
<Button
onClick={() => {
const session = getSession(model)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
;(async () => {
try {
const assembly = session.assemblyManager.get(assemblyName)
const { assemblyManager } = session
const assembly =
await assemblyManager.waitForAssembly(assemblyName)
if (!assembly) {
throw new Error(`assembly ${assemblyName} not found`)
}
const w = +windowSize
if (Number.isNaN(w)) {
throw new Error('windowSize not a number')
}
const { refName, pos, mateRefName, matePos } =
// @ts-expect-error
viewType.getBreakendCoveringRegions({ feature, assembly })

const breakpointSplitView = session.addView(
Expand All @@ -112,7 +117,9 @@ const BreakendSingleLevelOptionDialog = observer(function ({
views: [
{
type: 'LinearGenomeView',
tracks: stripIds(getSnapshot(view.tracks)),
tracks: view?.tracks
? stripIds(getSnapshot(view.tracks))
: [],
},
],
},
Expand All @@ -139,7 +146,7 @@ const BreakendSingleLevelOptionDialog = observer(function ({
)
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
})()
handleClose()
Expand Down
2 changes: 1 addition & 1 deletion plugins/alignments/src/AlignmentsFeatureDetail/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export async function navToLoc(locString: string, model: IAnyStateTreeNode) {
}
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export function SharedLinearPileupDisplayMixin(
}
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
},

Expand Down Expand Up @@ -429,7 +429,7 @@ export function SharedLinearPileupDisplayMixin(
}
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
},
}
Expand Down
3 changes: 3 additions & 0 deletions plugins/circular-view/src/CircularView/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ function stateModelFactory(pluginManager: PluginManager) {
}))

.actions(self => ({
clearTracks() {
self.tracks = cast([])
},
/**
* #action
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function AutocompleteTextField({
setInputValue: (arg: string) => void
setCurrentSearch: (arg: string) => void
}) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const { helperText, InputProps = {} } = TextFieldProps
return (
<TextField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function SearchResultsTable({
}
} catch (e) {
console.warn(e)
session.notify(`${e}`, 'warning')
session.notifyError(`${e}`, e)
}
}
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
AbstractSessionModel,
FileLocation,
getSession,
} from '@jbrowse/core/util'
import { getParent } from 'mobx-state-tree'
import { AbstractSessionModel, FileLocation } from '@jbrowse/core/util'
import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'

type LGV = LinearGenomeViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parseStrand } from './util'
import type { Buffer } from 'buffer'

export function parseBedPEBuffer(buffer: Buffer) {
const data = new TextDecoder('utf8', { fatal: true }).decode(buffer)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// re-exported for react lazy
export { BreakendMultiLevelOptionDialog as default } from '@jbrowse/sv-core'
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// re-exported for react lazy
export { BreakendSingleLevelOptionDialog as default } from '@jbrowse/sv-core'
Loading

0 comments on commit 075ed05

Please sign in to comment.