-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dep
- Loading branch information
Showing
4 changed files
with
157 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
plugins/variants/src/VariantFeatureWidget/BreakendOptionDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import React, { useState } from 'react' | ||
import { observer } from 'mobx-react' | ||
import { makeStyles } from '@material-ui/core/styles' | ||
import { | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogTitle, | ||
Divider, | ||
IconButton, | ||
FormControlLabel, | ||
Checkbox, | ||
} from '@material-ui/core' | ||
import CloseIcon from '@material-ui/icons/Close' | ||
import { getSnapshot } from 'mobx-state-tree' | ||
import { getSession } from '@jbrowse/core/util' | ||
import { Feature } from '@jbrowse/core/util/simpleFeature' | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
closeButton: { | ||
position: 'absolute', | ||
right: theme.spacing(1), | ||
top: theme.spacing(1), | ||
color: theme.palette.grey[500], | ||
}, | ||
block: { | ||
display: 'block', | ||
}, | ||
})) | ||
|
||
export default observer( | ||
({ | ||
model, | ||
handleClose, | ||
feature, | ||
viewType, | ||
}: { | ||
model: any | ||
handleClose: () => void | ||
feature: Feature | ||
viewType: any | ||
}) => { | ||
const classes = useStyles() | ||
const [copyTracks, setCopyTracks] = useState(true) | ||
const [mirrorTracks, setMirrorTracks] = useState(true) | ||
|
||
return ( | ||
<Dialog open onClose={handleClose}> | ||
<DialogTitle> | ||
Breakpoint split view options | ||
{handleClose ? ( | ||
<IconButton | ||
className={classes.closeButton} | ||
onClick={() => { | ||
handleClose() | ||
}} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
) : null} | ||
</DialogTitle> | ||
<Divider /> | ||
|
||
<DialogContent> | ||
<FormControlLabel | ||
className={classes.block} | ||
control={ | ||
<Checkbox | ||
checked={copyTracks} | ||
onChange={() => setCopyTracks(val => !val)} | ||
/> | ||
} | ||
label="Copy tracks into the new view" | ||
/> | ||
|
||
<FormControlLabel | ||
className={classes.block} | ||
control={ | ||
<Checkbox | ||
checked={mirrorTracks} | ||
onChange={() => setMirrorTracks(val => !val)} | ||
/> | ||
} | ||
label="Mirror tracks vertically in vertically stacked view" | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button | ||
onClick={() => { | ||
const { view } = model | ||
const session = getSession(model) | ||
|
||
const viewSnapshot = viewType.snapshotFromBreakendFeature( | ||
feature, | ||
view, | ||
) | ||
viewSnapshot.views[0].offsetPx -= view.width / 2 + 100 | ||
viewSnapshot.views[1].offsetPx -= view.width / 2 + 100 | ||
viewSnapshot.featureData = feature | ||
const viewTracks: any = getSnapshot(view.tracks) | ||
viewSnapshot.views[0].tracks = viewTracks | ||
viewSnapshot.views[1].tracks = mirrorTracks | ||
? viewTracks.slice().reverse() | ||
: viewTracks | ||
|
||
session.addView('BreakpointSplitView', viewSnapshot) | ||
|
||
handleClose() | ||
}} | ||
variant="contained" | ||
color="primary" | ||
autoFocus | ||
> | ||
OK | ||
</Button> | ||
<Button | ||
onClick={() => { | ||
handleClose() | ||
}} | ||
color="secondary" | ||
variant="contained" | ||
autoFocus | ||
> | ||
Cancel | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
) | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters