-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow adding session tracks to embedded react component along with di…
…sableAddTracks option if unwanted (#3223) * Add session tracks to embedded * Enable adding tracks to embedded, with a flag to disable it at view creation * Allow passing props to extension point
- Loading branch information
Showing
11 changed files
with
148 additions
and
72 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
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
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 |
---|---|---|
@@ -1,57 +1,68 @@ | ||
import { lazy } from 'react' | ||
import PluginManager from '@jbrowse/core/PluginManager' | ||
import { readConfObject } from '@jbrowse/core/configuration' | ||
import { getSession } from '@jbrowse/core/util' | ||
import { getSession, isSessionWithAddTracks } from '@jbrowse/core/util' | ||
import { HierarchicalTrackSelectorModel } from '@jbrowse/plugin-data-management' | ||
|
||
const ConfirmDialog = lazy(() => import('./ConfirmDialog')) | ||
|
||
export default function (pm: PluginManager) { | ||
pm.addToExtensionPoint('TrackSelector-multiTrackMenuItems', () => { | ||
return [ | ||
{ | ||
label: 'Create multi-wiggle track', | ||
onClick: (model: HierarchicalTrackSelectorModel) => { | ||
const tracks = model.selection | ||
const trackIds = tracks.map(c => readConfObject(c, 'name')) | ||
function makeTrack(arg: { name: string }) { | ||
const subadapters = tracks | ||
.map(c => readConfObject(c, 'adapter')) | ||
.map((c, idx) => ({ ...c, source: trackIds[idx] })) | ||
const assemblyNames = [ | ||
...new Set( | ||
tracks.map(c => readConfObject(c, 'assemblyNames')).flat(), | ||
), | ||
] | ||
const now = +Date.now() | ||
const trackId = `multitrack-${now}-sessionTrack` | ||
pm.addToExtensionPoint( | ||
'TrackSelector-multiTrackMenuItems', | ||
(items: unknown[], props: Record<string, unknown>) => { | ||
const { session } = props | ||
return [ | ||
...items, | ||
...(isSessionWithAddTracks(session) | ||
? [ | ||
{ | ||
label: 'Create multi-wiggle track', | ||
onClick: (model: HierarchicalTrackSelectorModel) => { | ||
const tracks = model.selection | ||
const trackIds = tracks.map(c => readConfObject(c, 'name')) | ||
function makeTrack(arg: { name: string }) { | ||
const subadapters = tracks | ||
.map(c => readConfObject(c, 'adapter')) | ||
.map((c, idx) => ({ ...c, source: trackIds[idx] })) | ||
const assemblyNames = [ | ||
...new Set( | ||
tracks | ||
.map(c => readConfObject(c, 'assemblyNames')) | ||
.flat(), | ||
), | ||
] | ||
const now = +Date.now() | ||
const trackId = `multitrack-${now}-sessionTrack` | ||
|
||
getSession(model).addTrackConf({ | ||
type: 'MultiQuantitativeTrack', | ||
trackId, | ||
name: arg.name, | ||
assemblyNames, | ||
adapter: { | ||
type: 'MultiWiggleAdapter', | ||
subadapters, | ||
}, | ||
}) | ||
model.view.showTrack(trackId) | ||
} | ||
getSession(model).queueDialog(handleClose => [ | ||
ConfirmDialog, | ||
{ | ||
tracks, | ||
onClose: (arg: boolean, arg1: { name: string }) => { | ||
if (arg) { | ||
makeTrack(arg1) | ||
} | ||
handleClose() | ||
getSession(model).addTrackConf({ | ||
type: 'MultiQuantitativeTrack', | ||
trackId, | ||
name: arg.name, | ||
assemblyNames, | ||
adapter: { | ||
type: 'MultiWiggleAdapter', | ||
subadapters, | ||
}, | ||
}) | ||
model.view.showTrack(trackId) | ||
} | ||
getSession(model).queueDialog(handleClose => [ | ||
ConfirmDialog, | ||
{ | ||
tracks, | ||
onClose: (arg: boolean, arg1: { name: string }) => { | ||
if (arg) { | ||
makeTrack(arg1) | ||
} | ||
handleClose() | ||
}, | ||
}, | ||
]) | ||
}, | ||
}, | ||
}, | ||
]) | ||
}, | ||
}, | ||
] | ||
}) | ||
] | ||
: []), | ||
] | ||
}, | ||
) | ||
} |
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
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
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