jbrowse-plugin-graphgenomeviewer 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jbrowse-plugin-graphgenomeviewer",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "JBrowse 2 graph genome (pangenome) view: rGFA reference-anchored layouts, the Bandage force-directed engine, and haplotype lanes read from a gbz-base database",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -364,6 +364,27 @@ test("a launch names the pane's props without its type, and opens in that layout
364
364
  expect(display.pane.hostPlacesX).toBe(false)
365
365
  })
366
366
 
367
+ test('a launch that states one pane prop takes the rest from the config', async () => {
368
+ const { view, cuts } = createEnvironment()
369
+ view.zoomTo(60_000 / WIDTH_PX)
370
+ view.scrollTo(1_000_000 / view.bpPerPx)
371
+ view.showTrack(
372
+ 'graph',
373
+ {},
374
+ {
375
+ type: 'LinearGraphDisplay',
376
+ pane: { colorScheme: 'uniform' },
377
+ },
378
+ )
379
+ const display = view.tracks[0]!.displays[0] as LinearGraphDisplayModel
380
+ display.pane.startRenderingBackend(fakeRenderer())
381
+ await wait(SETTLE_MS)
382
+ expect(cuts).toHaveLength(1)
383
+ expect(display.pane.colorScheme).toBe('uniform')
384
+ expect(display.pane.layoutMode).toBe('auto')
385
+ expect(display.pane.hostPlacesX).toBe(true)
386
+ })
387
+
367
388
  test('the track menu offers the layouts, colours and the settings dialog', async () => {
368
389
  const { display } = await shownGraph()
369
390
  const labels = display
@@ -21,6 +21,8 @@ const GraphSettingsDialog = lazy(
21
21
  () => import('../GraphGenomeView/components/GraphSettingsDialog'),
22
22
  )
23
23
 
24
+ type ConfiguredSlot = 'layoutMode' | 'colorScheme' | 'height'
25
+
24
26
  export function stateModelFactory(configSchema: LinearGraphDisplayConfigModel) {
25
27
  const Pane = paneModelFactory()
26
28
  return (
@@ -39,19 +41,31 @@ export function stateModelFactory(configSchema: LinearGraphDisplayConfigModel) {
39
41
  pane: types.optional(Pane, () => ({
40
42
  type: 'GraphGenomeView' as const,
41
43
  })),
42
- // The config's layout and colour reach the pane once, so a choice made
43
- // in the track menu survives a reload.
44
- configured: types.optional(types.boolean, false),
44
+ // Which of the config's slots have reached the pane. Each reaches it
45
+ // once, so a choice made in the track menu survives a reload, and a
46
+ // launch that states a pane prop keeps it over the config's.
47
+ configured: types.optional(
48
+ types.frozen<Partial<Record<ConfiguredSlot, boolean>>>(),
49
+ {},
50
+ ),
45
51
  }),
46
52
  )
47
- // A launch that states the pane's props takes them over the config's
48
- // layout and colour, and names them without the pane's own type.
53
+ // A launch names the pane's props without the pane's own type, and what
54
+ // it states is what the config does not set.
49
55
  .preProcessSnapshot(snapshot => {
50
- const pane = (snapshot as { pane?: Record<string, unknown> }).pane
56
+ const { pane, configured } = snapshot as {
57
+ pane?: Record<string, unknown>
58
+ configured?: Partial<Record<ConfiguredSlot, boolean>>
59
+ }
51
60
  return pane
52
61
  ? ({
53
- configured: true,
54
62
  ...snapshot,
63
+ configured: {
64
+ layoutMode: pane.layoutMode !== undefined,
65
+ colorScheme: pane.colorScheme !== undefined,
66
+ height: pane.paneHeight !== undefined,
67
+ ...configured,
68
+ },
55
69
  pane:
56
70
  pane.type === undefined
57
71
  ? { type: 'GraphGenomeView', ...pane }
@@ -187,8 +201,23 @@ export function stateModelFactory(configSchema: LinearGraphDisplayConfigModel) {
187
201
  },
188
202
  }))
189
203
  .actions(self => ({
190
- setConfigured() {
191
- self.configured = true
204
+ // The config's slots the pane has not yet taken, then all of them.
205
+ applyConfig() {
206
+ const { pane, configured } = self
207
+ if (!configured.layoutMode) {
208
+ pane.setLayoutMode(getConf(self, 'layoutMode'))
209
+ }
210
+ if (!configured.colorScheme) {
211
+ pane.setColorScheme(getConf(self, 'colorScheme'))
212
+ }
213
+ if (!configured.height) {
214
+ pane.setPaneHeight(getConf(self, 'height'))
215
+ }
216
+ self.configured = {
217
+ layoutMode: true,
218
+ colorScheme: true,
219
+ height: true,
220
+ }
192
221
  },
193
222
  // The track's height is the pane's ceiling: a layout shorter than it
194
223
  // takes only what it needs, and a drag on the handle moves the ceiling.
@@ -202,12 +231,7 @@ export function stateModelFactory(configSchema: LinearGraphDisplayConfigModel) {
202
231
  .actions(self => ({
203
232
  afterAttach() {
204
233
  const { pane } = self
205
- if (!self.configured) {
206
- pane.setLayoutMode(getConf(self, 'layoutMode'))
207
- pane.setColorScheme(getConf(self, 'colorScheme'))
208
- pane.setPaneHeight(getConf(self, 'height'))
209
- self.setConfigured()
210
- }
234
+ self.applyConfig()
211
235
  pane.adoptTrack(self.trackId)
212
236
  pane.startHosting()
213
237
  addDisposer(
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '4.0.1'
1
+ export const version = '4.0.2'