@jbrowse/plugin-data-management 1.5.0 → 1.5.4

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.
Files changed (30) hide show
  1. package/dist/AddTrackWidget/model.d.ts +1 -434
  2. package/dist/AssemblyManager/AssemblyTable.d.ts +8 -2
  3. package/dist/PluginStoreWidget/components/CustomPluginForm.d.ts +1 -1
  4. package/dist/PluginStoreWidget/components/PluginCard.d.ts +2 -2
  5. package/dist/SetDefaultSession/SetDefaultSession.d.ts +4 -6
  6. package/dist/index.d.ts +8 -12
  7. package/dist/plugin-data-management.cjs.development.js +387 -324
  8. package/dist/plugin-data-management.cjs.development.js.map +1 -1
  9. package/dist/plugin-data-management.cjs.production.min.js +1 -1
  10. package/dist/plugin-data-management.cjs.production.min.js.map +1 -1
  11. package/dist/plugin-data-management.esm.js +389 -326
  12. package/dist/plugin-data-management.esm.js.map +1 -1
  13. package/package.json +3 -2
  14. package/src/AddTrackWidget/components/AddTrackWidget.test.js +1 -1
  15. package/src/AddTrackWidget/components/AddTrackWidget.tsx +3 -1
  16. package/src/AddTrackWidget/components/ConfirmTrack.tsx +101 -32
  17. package/src/AddTrackWidget/components/TrackSourceSelect.tsx +2 -3
  18. package/src/AddTrackWidget/index.test.jsx +34 -15
  19. package/src/AddTrackWidget/model.ts +5 -14
  20. package/src/AssemblyManager/AssemblyManager.tsx +3 -1
  21. package/src/AssemblyManager/AssemblyTable.tsx +40 -39
  22. package/src/HierarchicalTrackSelectorWidget/model.js +3 -2
  23. package/src/PluginStoreWidget/components/CustomPluginForm.tsx +164 -56
  24. package/src/PluginStoreWidget/components/InstalledPlugin.tsx +16 -11
  25. package/src/PluginStoreWidget/components/PluginCard.tsx +7 -9
  26. package/src/PluginStoreWidget/components/PluginStoreWidget.test.js +8 -7
  27. package/src/PluginStoreWidget/components/PluginStoreWidget.tsx +34 -25
  28. package/src/PluginStoreWidget/components/__snapshots__/PluginStoreWidget.test.js.snap +69 -52
  29. package/src/SetDefaultSession/SetDefaultSession.test.tsx +6 -81
  30. package/src/SetDefaultSession/SetDefaultSession.tsx +51 -162
@@ -1,9 +1,11 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
4
- <div>
4
+ <div
5
+ class="makeStyles-root"
6
+ >
5
7
  <div
6
- class="MuiFormControl-root MuiTextField-root makeStyles-searchBox MuiFormControl-fullWidth"
8
+ class="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
7
9
  >
8
10
  <label
9
11
  class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated"
@@ -116,9 +118,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
116
118
  >
117
119
  <svg
118
120
  aria-hidden="true"
119
- class="MuiSvgIcon-root"
121
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
120
122
  focusable="false"
121
- style="margin-right: 0.5rem;"
122
123
  title="This plugin was installed by an administrator, you cannot remove it."
123
124
  viewBox="0 0 24 24"
124
125
  >
@@ -137,9 +138,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
137
138
  >
138
139
  <svg
139
140
  aria-hidden="true"
140
- class="MuiSvgIcon-root"
141
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
141
142
  focusable="false"
142
- style="margin-right: 0.5rem;"
143
143
  title="This plugin was installed by an administrator, you cannot remove it."
144
144
  viewBox="0 0 24 24"
145
145
  >
@@ -158,9 +158,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
158
158
  >
159
159
  <svg
160
160
  aria-hidden="true"
161
- class="MuiSvgIcon-root"
161
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
162
162
  focusable="false"
163
- style="margin-right: 0.5rem;"
164
163
  title="This plugin was installed by an administrator, you cannot remove it."
165
164
  viewBox="0 0 24 24"
166
165
  >
@@ -179,9 +178,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
179
178
  >
180
179
  <svg
181
180
  aria-hidden="true"
182
- class="MuiSvgIcon-root"
181
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
183
182
  focusable="false"
184
- style="margin-right: 0.5rem;"
185
183
  title="This plugin was installed by an administrator, you cannot remove it."
186
184
  viewBox="0 0 24 24"
187
185
  >
@@ -200,9 +198,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
200
198
  >
201
199
  <svg
202
200
  aria-hidden="true"
203
- class="MuiSvgIcon-root"
201
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
204
202
  focusable="false"
205
- style="margin-right: 0.5rem;"
206
203
  title="This plugin was installed by an administrator, you cannot remove it."
207
204
  viewBox="0 0 24 24"
208
205
  >
@@ -221,9 +218,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
221
218
  >
222
219
  <svg
223
220
  aria-hidden="true"
224
- class="MuiSvgIcon-root"
221
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
225
222
  focusable="false"
226
- style="margin-right: 0.5rem;"
227
223
  title="This plugin was installed by an administrator, you cannot remove it."
228
224
  viewBox="0 0 24 24"
229
225
  >
@@ -242,9 +238,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
242
238
  >
243
239
  <svg
244
240
  aria-hidden="true"
245
- class="MuiSvgIcon-root"
241
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
246
242
  focusable="false"
247
- style="margin-right: 0.5rem;"
248
243
  title="This plugin was installed by an administrator, you cannot remove it."
249
244
  viewBox="0 0 24 24"
250
245
  >
@@ -263,9 +258,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
263
258
  >
264
259
  <svg
265
260
  aria-hidden="true"
266
- class="MuiSvgIcon-root"
261
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
267
262
  focusable="false"
268
- style="margin-right: 0.5rem;"
269
263
  title="This plugin was installed by an administrator, you cannot remove it."
270
264
  viewBox="0 0 24 24"
271
265
  >
@@ -284,9 +278,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
284
278
  >
285
279
  <svg
286
280
  aria-hidden="true"
287
- class="MuiSvgIcon-root"
281
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
288
282
  focusable="false"
289
- style="margin-right: 0.5rem;"
290
283
  title="This plugin was installed by an administrator, you cannot remove it."
291
284
  viewBox="0 0 24 24"
292
285
  >
@@ -305,9 +298,28 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
305
298
  >
306
299
  <svg
307
300
  aria-hidden="true"
308
- class="MuiSvgIcon-root"
301
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
302
+ focusable="false"
303
+ title="This plugin was installed by an administrator, you cannot remove it."
304
+ viewBox="0 0 24 24"
305
+ >
306
+ <path
307
+ d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"
308
+ />
309
+ </svg>
310
+ <p
311
+ class="MuiTypography-root MuiTypography-body1"
312
+ >
313
+ GTFPlugin
314
+ </p>
315
+ </li>
316
+ <li
317
+ class="MuiListItem-root MuiListItem-gutters"
318
+ >
319
+ <svg
320
+ aria-hidden="true"
321
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
309
322
  focusable="false"
310
- style="margin-right: 0.5rem;"
311
323
  title="This plugin was installed by an administrator, you cannot remove it."
312
324
  viewBox="0 0 24 24"
313
325
  >
@@ -326,9 +338,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
326
338
  >
327
339
  <svg
328
340
  aria-hidden="true"
329
- class="MuiSvgIcon-root"
341
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
330
342
  focusable="false"
331
- style="margin-right: 0.5rem;"
332
343
  title="This plugin was installed by an administrator, you cannot remove it."
333
344
  viewBox="0 0 24 24"
334
345
  >
@@ -347,9 +358,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
347
358
  >
348
359
  <svg
349
360
  aria-hidden="true"
350
- class="MuiSvgIcon-root"
361
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
351
362
  focusable="false"
352
- style="margin-right: 0.5rem;"
353
363
  title="This plugin was installed by an administrator, you cannot remove it."
354
364
  viewBox="0 0 24 24"
355
365
  >
@@ -368,9 +378,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
368
378
  >
369
379
  <svg
370
380
  aria-hidden="true"
371
- class="MuiSvgIcon-root"
381
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
372
382
  focusable="false"
373
- style="margin-right: 0.5rem;"
374
383
  title="This plugin was installed by an administrator, you cannot remove it."
375
384
  viewBox="0 0 24 24"
376
385
  >
@@ -389,9 +398,28 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
389
398
  >
390
399
  <svg
391
400
  aria-hidden="true"
392
- class="MuiSvgIcon-root"
401
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
402
+ focusable="false"
403
+ title="This plugin was installed by an administrator, you cannot remove it."
404
+ viewBox="0 0 24 24"
405
+ >
406
+ <path
407
+ d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"
408
+ />
409
+ </svg>
410
+ <p
411
+ class="MuiTypography-root MuiTypography-body1"
412
+ >
413
+ ArcRenderer
414
+ </p>
415
+ </li>
416
+ <li
417
+ class="MuiListItem-root MuiListItem-gutters"
418
+ >
419
+ <svg
420
+ aria-hidden="true"
421
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
393
422
  focusable="false"
394
- style="margin-right: 0.5rem;"
395
423
  title="This plugin was installed by an administrator, you cannot remove it."
396
424
  viewBox="0 0 24 24"
397
425
  >
@@ -410,9 +438,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
410
438
  >
411
439
  <svg
412
440
  aria-hidden="true"
413
- class="MuiSvgIcon-root"
441
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
414
442
  focusable="false"
415
- style="margin-right: 0.5rem;"
416
443
  title="This plugin was installed by an administrator, you cannot remove it."
417
444
  viewBox="0 0 24 24"
418
445
  >
@@ -431,9 +458,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
431
458
  >
432
459
  <svg
433
460
  aria-hidden="true"
434
- class="MuiSvgIcon-root"
461
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
435
462
  focusable="false"
436
- style="margin-right: 0.5rem;"
437
463
  title="This plugin was installed by an administrator, you cannot remove it."
438
464
  viewBox="0 0 24 24"
439
465
  >
@@ -452,9 +478,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
452
478
  >
453
479
  <svg
454
480
  aria-hidden="true"
455
- class="MuiSvgIcon-root"
481
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
456
482
  focusable="false"
457
- style="margin-right: 0.5rem;"
458
483
  title="This plugin was installed by an administrator, you cannot remove it."
459
484
  viewBox="0 0 24 24"
460
485
  >
@@ -473,9 +498,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
473
498
  >
474
499
  <svg
475
500
  aria-hidden="true"
476
- class="MuiSvgIcon-root"
501
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
477
502
  focusable="false"
478
- style="margin-right: 0.5rem;"
479
503
  title="This plugin was installed by an administrator, you cannot remove it."
480
504
  viewBox="0 0 24 24"
481
505
  >
@@ -494,9 +518,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
494
518
  >
495
519
  <svg
496
520
  aria-hidden="true"
497
- class="MuiSvgIcon-root"
521
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
498
522
  focusable="false"
499
- style="margin-right: 0.5rem;"
500
523
  title="This plugin was installed by an administrator, you cannot remove it."
501
524
  viewBox="0 0 24 24"
502
525
  >
@@ -515,9 +538,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
515
538
  >
516
539
  <svg
517
540
  aria-hidden="true"
518
- class="MuiSvgIcon-root"
541
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
519
542
  focusable="false"
520
- style="margin-right: 0.5rem;"
521
543
  title="This plugin was installed by an administrator, you cannot remove it."
522
544
  viewBox="0 0 24 24"
523
545
  >
@@ -536,9 +558,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
536
558
  >
537
559
  <svg
538
560
  aria-hidden="true"
539
- class="MuiSvgIcon-root"
561
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
540
562
  focusable="false"
541
- style="margin-right: 0.5rem;"
542
563
  title="This plugin was installed by an administrator, you cannot remove it."
543
564
  viewBox="0 0 24 24"
544
565
  >
@@ -557,9 +578,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
557
578
  >
558
579
  <svg
559
580
  aria-hidden="true"
560
- class="MuiSvgIcon-root"
581
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
561
582
  focusable="false"
562
- style="margin-right: 0.5rem;"
563
583
  title="This plugin was installed by an administrator, you cannot remove it."
564
584
  viewBox="0 0 24 24"
565
585
  >
@@ -578,9 +598,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
578
598
  >
579
599
  <svg
580
600
  aria-hidden="true"
581
- class="MuiSvgIcon-root"
601
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
582
602
  focusable="false"
583
- style="margin-right: 0.5rem;"
584
603
  title="This plugin was installed by an administrator, you cannot remove it."
585
604
  viewBox="0 0 24 24"
586
605
  >
@@ -599,9 +618,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
599
618
  >
600
619
  <svg
601
620
  aria-hidden="true"
602
- class="MuiSvgIcon-root"
621
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
603
622
  focusable="false"
604
- style="margin-right: 0.5rem;"
605
623
  title="This plugin was installed by an administrator, you cannot remove it."
606
624
  viewBox="0 0 24 24"
607
625
  >
@@ -620,9 +638,8 @@ exports[`<PluginStoreWidget /> renders with the available plugins 1`] = `
620
638
  >
621
639
  <svg
622
640
  aria-hidden="true"
623
- class="MuiSvgIcon-root"
641
+ class="MuiSvgIcon-root makeStyles-lockedPluginTooltip"
624
642
  focusable="false"
625
- style="margin-right: 0.5rem;"
626
643
  title="This plugin was installed by an administrator, you cannot remove it."
627
644
  viewBox="0 0 24 24"
628
645
  >
@@ -23,108 +23,33 @@ const mockRootModel = {
23
23
  setDefaultSessionConf: jest.fn(),
24
24
  },
25
25
  session: {
26
- savedSessions: {},
26
+ savedSessions: [],
27
+ notify: jest.fn(),
27
28
  },
28
29
  }
29
30
 
30
31
  describe('SetDefaultSession GUI', () => {
31
- it('renders succesfully', () => {
32
- const { getByText } = render(
33
- <SetDefaultSession
34
- rootModel={mockRootModel}
35
- open
36
- onClose={() => {}}
37
- currentDefault="New session"
38
- />,
39
- )
40
- expect(getByText('Set Default Session')).toBeTruthy()
41
- })
42
-
43
32
  it('closes when the return button is clicked', () => {
44
33
  const onClose = jest.fn()
45
34
  const { getByText } = render(
46
- <SetDefaultSession
47
- rootModel={mockRootModel}
48
- open
49
- onClose={onClose}
50
- currentDefault="New session"
51
- />,
35
+ <SetDefaultSession rootModel={mockRootModel} onClose={onClose} />,
52
36
  )
53
- fireEvent.click(getByText('Return'))
37
+ fireEvent.click(getByText('Cancel'))
54
38
  expect(onClose).toHaveBeenCalled()
55
39
  })
56
40
 
57
- it('shows no sessions if none are saved', () => {
58
- const { getByText } = render(
59
- <SetDefaultSession
60
- rootModel={mockRootModel}
61
- open
62
- onClose={() => {}}
63
- currentDefault="New session"
64
- />,
65
- )
66
- expect(getByText('No saved sessions found')).toBeTruthy()
67
- })
68
-
69
- it('lists the saved sessions', () => {
70
- const MockSavedSessions = {
71
- ...mockRootModel,
72
- session: {
73
- savedSessions: [
74
- {
75
- name: `New session`,
76
- },
77
- ],
78
- },
79
- }
80
- const { getByText } = render(
81
- <SetDefaultSession
82
- rootModel={MockSavedSessions}
83
- open
84
- onClose={() => {}}
85
- currentDefault="New session"
86
- />,
87
- )
88
- expect(getByText('New session')).toBeTruthy()
89
- })
90
-
91
- it('sets to the default session when checked', () => {
92
- const MockSession = {
93
- ...mockRootModel,
94
- session: {
95
- name: `Moo session`,
96
- savedSessions: [],
97
- notify: jest.fn(),
98
- },
99
- }
100
- const { getByRole } = render(
101
- <SetDefaultSession
102
- rootModel={MockSession}
103
- open
104
- onClose={() => {}}
105
- currentDefault="New session"
106
- />,
107
- )
108
- fireEvent.click(getByRole('radio'))
109
- expect(MockSession.jbrowse.setDefaultSessionConf).toHaveBeenCalled()
110
- })
111
-
112
41
  it('unsets to the default session with reset button', () => {
113
42
  const MockSession = {
114
43
  ...mockRootModel,
115
44
  session: {
45
+ ...mockRootModel.session,
116
46
  name: `Moo session`,
117
47
  savedSessions: [],
118
48
  notify: jest.fn(),
119
49
  },
120
50
  }
121
51
  const { getByText } = render(
122
- <SetDefaultSession
123
- rootModel={MockSession}
124
- open
125
- onClose={() => {}}
126
- currentDefault="New session"
127
- />,
52
+ <SetDefaultSession rootModel={MockSession} onClose={() => {}} />,
128
53
  )
129
54
  fireEvent.click(getByText('Clear default session'))
130
55
  expect(MockSession.jbrowse.setDefaultSessionConf).toHaveBeenCalledWith({
@@ -1,181 +1,70 @@
1
- import React, { useState } from 'react'
1
+ import React from 'react'
2
2
  import { observer } from 'mobx-react'
3
- import Dialog from '@material-ui/core/Dialog'
4
- import { makeStyles } from '@material-ui/core/styles'
5
- import DialogTitle from '@material-ui/core/DialogTitle'
6
- import DialogContent from '@material-ui/core/DialogContent'
7
- import DialogActions from '@material-ui/core/DialogActions'
8
- import Button from '@material-ui/core/Button'
9
- import List from '@material-ui/core/List'
10
- import ListItem from '@material-ui/core/ListItem'
11
- import ListItemIcon from '@material-ui/core/ListItemIcon'
12
- import ListItemText from '@material-ui/core/ListItemText'
13
- import ListSubheader from '@material-ui/core/ListSubheader'
14
- import Paper from '@material-ui/core/Paper'
15
- import Typography from '@material-ui/core/Typography'
16
- import Radio from '@material-ui/core/Radio'
17
- import pluralize from 'pluralize'
18
- import { Grid } from '@material-ui/core'
3
+ import {
4
+ Dialog,
5
+ DialogTitle,
6
+ DialogContent,
7
+ DialogActions,
8
+ Button,
9
+ Typography,
10
+ } from '@material-ui/core'
19
11
 
20
- const useStyles = makeStyles(theme => ({
21
- root: {
22
- margin: theme.spacing(1),
23
- },
24
- message: {
25
- padding: theme.spacing(3),
26
- },
27
- titleBox: {
28
- color: '#fff',
29
- backgroundColor: theme.palette.primary.main,
30
- textAlign: 'center',
31
- },
32
- dialogContent: {
33
- width: 600,
34
- },
35
- resetButton: {
36
- justifyContent: 'center',
37
- marginBottom: '6px',
38
- },
39
- }))
40
-
41
- const CurrentSession = observer(
42
- ({
43
- session,
44
- selectedDefault,
45
- handleRadio,
46
- }: {
47
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- session: any
49
- selectedDefault: string
50
- handleRadio: Function
51
- }) => {
52
- const classes = useStyles()
53
-
54
- return (
55
- <Paper className={classes.root}>
56
- <List subheader={<ListSubheader>Currently open session</ListSubheader>}>
57
- <ListItem>
58
- <ListItemIcon>
59
- <Radio
60
- checked={session.name === selectedDefault}
61
- onChange={() => handleRadio(session)}
62
- />
63
- </ListItemIcon>
64
- <ListItemText primary={session.name} />
65
- </ListItem>
66
- </List>
67
- </Paper>
68
- )
69
- },
70
- )
12
+ function canSetDefaultSession(obj: unknown): obj is {
13
+ jbrowse: { setDefaultSessionConf: Function }
14
+ session: unknown
15
+ } {
16
+ return typeof obj === 'object' && !!obj && 'jbrowse' in obj
17
+ }
71
18
 
72
19
  const SetDefaultSession = observer(
73
- ({
74
- rootModel,
75
- open,
76
- onClose,
77
- currentDefault,
78
- }: {
79
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
- rootModel: any
81
- open: boolean
82
- onClose: Function
83
- currentDefault: string
84
- }) => {
85
- const classes = useStyles()
86
- const { session } = rootModel
87
- const [selectedDefault, setSelectedDefault] = useState(currentDefault)
88
-
89
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
- function handleRadio(sessionSnapshot: any) {
91
- setSelectedDefault(sessionSnapshot.name)
92
- rootModel.jbrowse.setDefaultSessionConf(sessionSnapshot)
93
- session.notify(
94
- `Set default session to ${sessionSnapshot.name}`,
95
- 'success',
96
- )
20
+ ({ rootModel, onClose }: { rootModel?: unknown; onClose: () => void }) => {
21
+ if (!rootModel) {
22
+ return null
97
23
  }
24
+ if (!canSetDefaultSession(rootModel)) {
25
+ console.error('Incorrect rootmodel')
26
+ return null
27
+ }
28
+ const { jbrowse, session } = rootModel
98
29
 
99
30
  return (
100
- <Dialog open={open}>
101
- <DialogTitle className={classes.titleBox}>
102
- Set Default Session
103
- </DialogTitle>
31
+ <Dialog open onClose={onClose}>
32
+ <DialogTitle>Set default session</DialogTitle>
104
33
  <DialogContent>
105
- <Grid className={classes.resetButton} container>
106
- <Grid item>
107
- <Button
108
- color="secondary"
109
- variant="contained"
110
- onClick={() => {
111
- setSelectedDefault('New session')
112
- rootModel.jbrowse.setDefaultSessionConf({
113
- name: `New session`,
114
- })
115
- session.notify('Reset default session', 'success')
116
- }}
117
- >
118
- Clear default session
119
- </Button>
120
- </Grid>
121
- </Grid>
122
-
123
- <CurrentSession
124
- session={session}
125
- selectedDefault={selectedDefault}
126
- handleRadio={handleRadio}
127
- />
128
- <Paper className={classes.root}>
129
- <List subheader={<ListSubheader>Saved sessions</ListSubheader>}>
130
- {session.savedSessions.length ? (
131
- session.savedSessions.map(
132
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
- (sessionSnapshot: any) => {
134
- const { views = [] } = sessionSnapshot
135
- const totalTracks = views
136
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
- .map((view: any) => view.tracks.length)
138
- .reduce((a: number, b: number) => a + b, 0)
139
- if (sessionSnapshot.name !== session.name) {
140
- return (
141
- <ListItem key={sessionSnapshot.name}>
142
- <ListItemIcon>
143
- <Radio
144
- checked={sessionSnapshot.name === selectedDefault}
145
- onChange={() => handleRadio(sessionSnapshot)}
146
- />
147
- </ListItemIcon>
148
- <ListItemText
149
- primary={sessionSnapshot.name}
150
- secondary={`${views.length} ${pluralize(
151
- 'view',
152
- views.length,
153
- )}; ${totalTracks}
154
- open ${pluralize('track', totalTracks)}`}
155
- />
156
- </ListItem>
157
- )
158
- }
159
- return null
160
- },
161
- )
162
- ) : (
163
- <Typography className={classes.message}>
164
- No saved sessions found
165
- </Typography>
166
- )}
167
- </List>
168
- </Paper>
34
+ <Typography>
35
+ Select "Set current session as default" to make your current session
36
+ saved to the config file. You can also hit "Clear default session",
37
+ which would remove the default session from the config.
38
+ </Typography>
169
39
  </DialogContent>
170
40
  <DialogActions>
41
+ <Button
42
+ variant="contained"
43
+ onClick={() => {
44
+ jbrowse.setDefaultSessionConf({
45
+ name: `New session`,
46
+ })
47
+ onClose()
48
+ }}
49
+ >
50
+ Clear default session
51
+ </Button>
171
52
  <Button
172
53
  color="secondary"
173
54
  variant="contained"
55
+ onClick={() => onClose()}
56
+ >
57
+ Cancel
58
+ </Button>
59
+ <Button
60
+ color="primary"
61
+ variant="contained"
174
62
  onClick={() => {
175
- onClose(false)
63
+ jbrowse.setDefaultSessionConf(session)
64
+ onClose()
176
65
  }}
177
66
  >
178
- Return
67
+ Set current session as default
179
68
  </Button>
180
69
  </DialogActions>
181
70
  </Dialog>