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

Adds the ability to highlight regions using the bookmarks widget #4003

Merged
merged 27 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c8a156f
WIP: adding highlights to bookmarks
carolinebridge Oct 20, 2023
84eec12
Merge branch 'main' into bookmark-highlights
carolinebridge Nov 6, 2023
0eba41a
Adds label to highlights on the LGV; adds options to toggle on/off; a…
carolinebridge Nov 6, 2023
785b55f
Moving Highlight to GridBookmarkPlugin, lint, various checks and UI
carolinebridge Nov 9, 2023
77984ae
listen for storage events in other tabs
carolinebridge Nov 9, 2023
7a69acf
update menu items to submenu and tests
carolinebridge Nov 9, 2023
9c68872
make default color of highlight static
carolinebridge Nov 10, 2023
c0d6f8d
ensure highlights display on load new session
carolinebridge Nov 10, 2023
e67e7cc
edit dialog > highlight dialog
carolinebridge Nov 10, 2023
226e748
update tests
carolinebridge Nov 10, 2023
f6bc113
Avoid doing manual typing for callbacks
cmdcolin Nov 20, 2023
051e055
review feedback
carolinebridge Nov 22, 2023
c12b211
revert for lint
carolinebridge Nov 22, 2023
1abddc8
lint
carolinebridge Nov 22, 2023
fdb751a
type
carolinebridge Nov 22, 2023
b8b9cc7
rev changes to index.ts
carolinebridge Nov 22, 2023
16bbeec
Simplified behavior of the check for all views
cmdcolin Nov 23, 2023
8bec53e
possible side effect routine
carolinebridge Nov 23, 2023
085f2df
improving clear all and minor text edit
carolinebridge Nov 24, 2023
b261a67
lint and use colord
carolinebridge Nov 27, 2023
7b9366b
Merge branch 'main' into bookmark-highlights
carolinebridge Nov 27, 2023
219b45a
Use hamburger menu for bookmark options
cmdcolin Dec 13, 2023
bf59037
Attempt test fixes
cmdcolin Dec 13, 2023
26e8efc
Updates
cmdcolin Dec 13, 2023
97cc23e
Test bookmark widget using integration test
cmdcolin Dec 13, 2023
b0dccff
Misc
cmdcolin Dec 13, 2023
da18c17
Updates
cmdcolin Dec 13, 2023
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,4 +1,4 @@
import React, { Suspense, lazy, useState } from 'react'
import React, { lazy, useState } from 'react'
import { observer } from 'mobx-react'
import { Link } from '@mui/material'
import { makeStyles } from 'tss-react/mui'
Expand All @@ -9,14 +9,17 @@ import {
measureGridWidth,
measureText,
} from '@jbrowse/core/util'
import { useResizeBar } from '@jbrowse/core/ui/useResizeBar'
import ResizeBar from '@jbrowse/core/ui/ResizeBar'
import ColorPicker from '@jbrowse/core/ui/ColorPicker'

// locals
import { navToBookmark } from '../utils'
import { GridBookmarkModel, IExtendedLabeledRegionModel } from '../model'
import { useResizeBar } from '@jbrowse/core/ui/useResizeBar'
import ResizeBar from '@jbrowse/core/ui/ResizeBar'
import { GridBookmarkModel } from '../model'

const EditBookmarkLabelDialog = lazy(() => import('./EditBookmarkLabelDialog'))
const EditBookmarkLabelDialog = lazy(
() => import('./dialogs/EditBookmarkLabelDialog'),
)

const useStyles = makeStyles()(() => ({
link: {
Expand All @@ -35,7 +38,6 @@ const BookmarkGrid = observer(function ({
model: GridBookmarkModel
}) {
const { classes, cx } = useStyles()
const [dialogRow, setDialogRow] = useState<IExtendedLabeledRegionModel>()
const { ref, scrollLeft } = useResizeBar()
const {
bookmarks,
Expand All @@ -59,8 +61,6 @@ const BookmarkGrid = observer(function ({
}
})

// reset selections if bookmarked regions change
// needed especially if bookmarked regions are deleted, then
const [widths, setWidths] = useState([
50,
Math.max(
Expand All @@ -75,86 +75,94 @@ const BookmarkGrid = observer(function ({
measureText('Assembly', 12) + 30,
measureGridWidth(rows.map(row => row.assemblyName)),
),
100,
])

return (
<>
<div ref={ref}>
<ResizeBar
widths={widths}
setWidths={setWidths}
scrollLeft={scrollLeft}
/>
<DataGrid
autoHeight
density="compact"
rows={rows}
columns={[
{
...GRID_CHECKBOX_SELECTION_COL_DEF,
width: widths[0],
},
{
field: 'locString',
headerName: 'Bookmark link',
width: widths[1],
renderCell: ({ value, row }) => (
<Link
className={cx(classes.link, classes.cell)}
href="#"
onClick={async event => {
event.preventDefault()
const { views } = session
await navToBookmark(value, row.assemblyName, views, model)
}}
>
{value}
</Link>
),
},
{
field: 'label',
headerName: 'Label',
width: widths[2],
editable: true,
},
{
field: 'assemblyName',
headerName: 'Assembly',
width: widths[3],
},
]}
onCellDoubleClick={({ row }) => setDialogRow(row)}
processRowUpdate={row => {
const target = rows[row.id]
model.updateBookmarkLabel(target, row.label)
return row
}}
onProcessRowUpdateError={e => session.notify(e.message, 'error')}
checkboxSelection
onRowSelectionModelChange={newRowSelectionModel => {
if (bookmarksWithValidAssemblies.length > 0) {
model.setSelectedBookmarks(
newRowSelectionModel.map(value => ({
...rows[value as number],
})),
)
}
}}
rowSelectionModel={selectedBookmarks.map(r => r.id)}
disableRowSelectionOnClick
/>
</div>
{dialogRow ? (
<Suspense fallback={<React.Fragment />}>
<EditBookmarkLabelDialog
onClose={() => setDialogRow(undefined)}
model={model}
dialogRow={dialogRow}
/>
</Suspense>
) : null}
</>
<div ref={ref}>
<ResizeBar
widths={widths}
setWidths={setWidths}
scrollLeft={scrollLeft}
/>
<DataGrid
autoHeight
density="compact"
rows={rows}
columns={[
{
...GRID_CHECKBOX_SELECTION_COL_DEF,
width: widths[0],
},
{
field: 'locString',
headerName: 'Bookmark link',
width: widths[1],
renderCell: ({ value, row }) => (
<Link
className={cx(classes.link, classes.cell)}
href="#"
onClick={async event => {
event.preventDefault()
const { views } = session
await navToBookmark(value, row.assemblyName, views, model)
}}
>
{value}
</Link>
),
},
{
field: 'label',
headerName: 'Label',
width: widths[2],
editable: true,
},
{
field: 'assemblyName',
headerName: 'Assembly',
width: widths[3],
},
{
field: 'highlight',
headerName: 'Highlight',
width: widths[4],
renderCell: ({ value, row }) => (
<ColorPicker
color={value || 'black'}
onChange={event => {
model.updateBookmarkHighlight(row, event)
}}
/>
),
},
]}
onCellDoubleClick={({ row }) => {
getSession(model).queueDialog(onClose => [
EditBookmarkLabelDialog,
{ onClose, model, dialogRow: row },
])
}}
processRowUpdate={row => {
const target = rows[row.id]
model.updateBookmarkLabel(target, row.label)
return row
}}
onProcessRowUpdateError={e => session.notify(e.message, 'error')}
checkboxSelection
onRowSelectionModelChange={newRowSelectionModel => {
if (bookmarksWithValidAssemblies.length > 0) {
model.setSelectedBookmarks(
newRowSelectionModel.map(value => ({
...rows[value as number],
})),
)
}
}}
rowSelectionModel={selectedBookmarks.map(r => r.id)}
disableRowSelectionOnClick
/>
</div>
)
})

Expand Down

This file was deleted.

This file was deleted.

Loading
Loading