@jbrowse/plugin-data-management 2.12.3 → 2.13.0

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.
@@ -58,7 +58,7 @@ function Category({ isOpen, setOpen, data, }) {
58
58
  setOpen(!isOpen);
59
59
  }
60
60
  } },
61
- react_1.default.createElement(material_1.Typography, null,
61
+ react_1.default.createElement(material_1.Typography, { "data-testid": `htsCategory-${name}` },
62
62
  isOpen ? react_1.default.createElement(ArrowDropDown_1.default, null) : react_1.default.createElement(ArrowRight_1.default, null),
63
63
  name,
64
64
  react_1.default.createElement(material_1.IconButton, { onClick: event => {
@@ -2,6 +2,7 @@ import { Instance } from 'mobx-state-tree';
2
2
  import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
3
  import PluginManager from '@jbrowse/core/PluginManager';
4
4
  type MaybeAnyConfigurationModel = AnyConfigurationModel | undefined;
5
+ type MaybeBoolean = boolean | undefined;
5
6
  /**
6
7
  * #stateModel HierarchicalTrackSelectorWidget
7
8
  */
@@ -103,8 +104,8 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
103
104
  favorites: string[];
104
105
  recentlyUsed: string[];
105
106
  selection: AnyConfigurationModel[];
106
- sortTrackNames: boolean;
107
- sortCategories: boolean;
107
+ sortTrackNames: MaybeBoolean;
108
+ sortCategories: MaybeBoolean;
108
109
  collapsed: import("mobx").ObservableMap<string, boolean>;
109
110
  filterText: string;
110
111
  recentlyUsedCounter: number;
@@ -250,11 +251,11 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
250
251
  /**
251
252
  * #getter
252
253
  */
253
- readonly activeSortTrackNames: boolean;
254
+ readonly activeSortTrackNames: any;
254
255
  /**
255
256
  * #getter
256
257
  */
257
- readonly activeSortCategories: boolean;
258
+ readonly activeSortCategories: any;
258
259
  /**
259
260
  * #getter
260
261
  * filter out tracks that don't match the current assembly/display types
@@ -11,19 +11,15 @@ const filterTracks_1 = require("./filterTracks");
11
11
  const generateHierarchy_1 = require("./generateHierarchy");
12
12
  const util_2 = require("./util");
13
13
  const facetedModel_1 = require("./facetedModel");
14
- // for settings that are not config dependent
15
- function keyNoConfigPostFix() {
16
- return typeof window !== 'undefined'
17
- ? [window.location.host, window.location.pathname].join('-')
18
- : 'empty';
19
- }
20
14
  // for settings that are config dependent
21
15
  function keyConfigPostFix() {
22
16
  return typeof window !== 'undefined'
23
17
  ? [
24
- keyNoConfigPostFix(),
18
+ window.location.pathname,
25
19
  new URLSearchParams(window.location.search).get('config'),
26
- ].join('-')
20
+ ]
21
+ .filter(f => !!f)
22
+ .join('-')
27
23
  : 'empty';
28
24
  }
29
25
  function recentlyUsedK(assemblyNames) {
@@ -51,11 +47,15 @@ function sortCategoriesK() {
51
47
  return 'sortCategories';
52
48
  }
53
49
  function localStorageGetJSON(key, defaultValue) {
54
- var _a;
55
- return JSON.parse((_a = (0, util_1.localStorageGetItem)(key)) !== null && _a !== void 0 ? _a : defaultValue);
50
+ const val = (0, util_1.localStorageGetItem)(key);
51
+ return val !== undefined && val !== null && val
52
+ ? JSON.parse(val)
53
+ : defaultValue;
56
54
  }
57
55
  function localStorageSetJSON(key, val) {
58
- (0, util_1.localStorageSetItem)(key, JSON.stringify(val));
56
+ if (val !== undefined && val !== null) {
57
+ (0, util_1.localStorageSetItem)(key, JSON.stringify(val));
58
+ }
59
59
  }
60
60
  const MAX_RECENTLY_USED = 10;
61
61
  /**
@@ -82,11 +82,11 @@ function stateTreeFactory(pluginManager) {
82
82
  faceted: mobx_state_tree_1.types.optional((0, facetedModel_1.facetedStateTreeF)(), {}),
83
83
  })
84
84
  .volatile(() => ({
85
- favorites: localStorageGetJSON(favoritesK(), '[]'),
85
+ favorites: localStorageGetJSON(favoritesK(), []),
86
86
  recentlyUsed: [],
87
87
  selection: [],
88
- sortTrackNames: !!localStorageGetJSON(sortTrackNamesK(), 'false'),
89
- sortCategories: !!localStorageGetJSON(sortCategoriesK(), 'false'),
88
+ sortTrackNames: localStorageGetJSON(sortTrackNamesK(), undefined),
89
+ sortCategories: localStorageGetJSON(sortCategoriesK(), undefined),
90
90
  collapsed: mobx_1.observable.map(),
91
91
  filterText: '',
92
92
  recentlyUsedCounter: 0,
@@ -454,46 +454,35 @@ function stateTreeFactory(pluginManager) {
454
454
  // this should be the first autorun to properly initialize
455
455
  (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
456
456
  const { assemblyNames, view } = self;
457
- self.setRecentlyUsed(localStorageGetJSON(recentlyUsedK(assemblyNames), '[]'));
457
+ self.setRecentlyUsed(localStorageGetJSON(recentlyUsedK(assemblyNames), []));
458
458
  if (view) {
459
- const val = (0, util_1.localStorageGetItem)(collapsedK(assemblyNames, view.type));
460
- if (!val) {
459
+ const lc = localStorageGetJSON(collapsedK(assemblyNames, view.type), undefined);
460
+ const r = ['hierarchical', 'defaultCollapsed'];
461
+ const session = (0, util_1.getSession)(self);
462
+ if (!lc) {
461
463
  self.expandAllCategories();
462
- const session = (0, util_1.getSession)(self);
463
- if ((0, configuration_1.getConf)(session, [
464
- 'hierarchical',
465
- 'defaultCollapsed',
466
- 'topLevelCategories',
467
- ])) {
464
+ if ((0, configuration_1.getConf)(session, [...r, 'topLevelCategories'])) {
468
465
  self.collapseTopLevelCategories();
469
466
  }
470
- if ((0, configuration_1.getConf)(session, [
471
- 'hierarchical',
472
- 'defaultCollapsed',
473
- 'subCategories',
474
- ])) {
467
+ if ((0, configuration_1.getConf)(session, [...r, 'subCategories'])) {
475
468
  self.collapseSubCategories();
476
469
  }
477
- for (const entry of (0, configuration_1.getConf)(session, [
478
- 'hierarchical',
479
- 'defaultCollapsed',
480
- 'categoryNames',
481
- ])) {
482
- self.setCategoryCollapsed(`Tracks-${entry}`, true);
470
+ for (const elt of (0, configuration_1.getConf)(session, [...r, 'categoryNames'])) {
471
+ self.setCategoryCollapsed(`Tracks-${elt}`, true);
483
472
  }
484
473
  }
485
474
  else {
486
- self.setCollapsedCategories(JSON.parse(val));
475
+ self.setCollapsedCategories(lc);
487
476
  }
488
477
  }
489
478
  }));
490
479
  // this should be the second autorun
491
480
  (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
492
- const { assemblyNames, collapsed, view } = self;
493
- localStorageSetJSON(recentlyUsedK(assemblyNames), self.recentlyUsed);
494
- localStorageSetJSON(favoritesK(), self.favorites);
495
- localStorageSetJSON(sortTrackNamesK(), self.sortTrackNames);
496
- localStorageSetJSON(sortCategoriesK(), self.sortCategories);
481
+ const { sortTrackNames, sortCategories, favorites, recentlyUsed, assemblyNames, collapsed, view, } = self;
482
+ localStorageSetJSON(recentlyUsedK(assemblyNames), recentlyUsed);
483
+ localStorageSetJSON(favoritesK(), favorites);
484
+ localStorageSetJSON(sortTrackNamesK(), sortTrackNames);
485
+ localStorageSetJSON(sortCategoriesK(), sortCategories);
497
486
  if (view) {
498
487
  localStorageSetJSON(collapsedK(assemblyNames, view.type), collapsed);
499
488
  }
@@ -29,7 +29,7 @@ export default function Category({ isOpen, setOpen, data, }) {
29
29
  setOpen(!isOpen);
30
30
  }
31
31
  } },
32
- React.createElement(Typography, null,
32
+ React.createElement(Typography, { "data-testid": `htsCategory-${name}` },
33
33
  isOpen ? React.createElement(ArrowDropDownIcon, null) : React.createElement(ArrowRightIcon, null),
34
34
  name,
35
35
  React.createElement(IconButton, { onClick: event => {
@@ -2,6 +2,7 @@ import { Instance } from 'mobx-state-tree';
2
2
  import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
3
  import PluginManager from '@jbrowse/core/PluginManager';
4
4
  type MaybeAnyConfigurationModel = AnyConfigurationModel | undefined;
5
+ type MaybeBoolean = boolean | undefined;
5
6
  /**
6
7
  * #stateModel HierarchicalTrackSelectorWidget
7
8
  */
@@ -103,8 +104,8 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
103
104
  favorites: string[];
104
105
  recentlyUsed: string[];
105
106
  selection: AnyConfigurationModel[];
106
- sortTrackNames: boolean;
107
- sortCategories: boolean;
107
+ sortTrackNames: MaybeBoolean;
108
+ sortCategories: MaybeBoolean;
108
109
  collapsed: import("mobx").ObservableMap<string, boolean>;
109
110
  filterText: string;
110
111
  recentlyUsedCounter: number;
@@ -250,11 +251,11 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
250
251
  /**
251
252
  * #getter
252
253
  */
253
- readonly activeSortTrackNames: boolean;
254
+ readonly activeSortTrackNames: any;
254
255
  /**
255
256
  * #getter
256
257
  */
257
- readonly activeSortCategories: boolean;
258
+ readonly activeSortCategories: any;
258
259
  /**
259
260
  * #getter
260
261
  * filter out tracks that don't match the current assembly/display types
@@ -8,19 +8,15 @@ import { filterTracks } from './filterTracks';
8
8
  import { generateHierarchy } from './generateHierarchy';
9
9
  import { findSubCategories, findTopLevelCategories } from './util';
10
10
  import { facetedStateTreeF } from './facetedModel';
11
- // for settings that are not config dependent
12
- function keyNoConfigPostFix() {
13
- return typeof window !== 'undefined'
14
- ? [window.location.host, window.location.pathname].join('-')
15
- : 'empty';
16
- }
17
11
  // for settings that are config dependent
18
12
  function keyConfigPostFix() {
19
13
  return typeof window !== 'undefined'
20
14
  ? [
21
- keyNoConfigPostFix(),
15
+ window.location.pathname,
22
16
  new URLSearchParams(window.location.search).get('config'),
23
- ].join('-')
17
+ ]
18
+ .filter(f => !!f)
19
+ .join('-')
24
20
  : 'empty';
25
21
  }
26
22
  function recentlyUsedK(assemblyNames) {
@@ -48,11 +44,15 @@ function sortCategoriesK() {
48
44
  return 'sortCategories';
49
45
  }
50
46
  function localStorageGetJSON(key, defaultValue) {
51
- var _a;
52
- return JSON.parse((_a = localStorageGetItem(key)) !== null && _a !== void 0 ? _a : defaultValue);
47
+ const val = localStorageGetItem(key);
48
+ return val !== undefined && val !== null && val
49
+ ? JSON.parse(val)
50
+ : defaultValue;
53
51
  }
54
52
  function localStorageSetJSON(key, val) {
55
- localStorageSetItem(key, JSON.stringify(val));
53
+ if (val !== undefined && val !== null) {
54
+ localStorageSetItem(key, JSON.stringify(val));
55
+ }
56
56
  }
57
57
  const MAX_RECENTLY_USED = 10;
58
58
  /**
@@ -79,11 +79,11 @@ export default function stateTreeFactory(pluginManager) {
79
79
  faceted: types.optional(facetedStateTreeF(), {}),
80
80
  })
81
81
  .volatile(() => ({
82
- favorites: localStorageGetJSON(favoritesK(), '[]'),
82
+ favorites: localStorageGetJSON(favoritesK(), []),
83
83
  recentlyUsed: [],
84
84
  selection: [],
85
- sortTrackNames: !!localStorageGetJSON(sortTrackNamesK(), 'false'),
86
- sortCategories: !!localStorageGetJSON(sortCategoriesK(), 'false'),
85
+ sortTrackNames: localStorageGetJSON(sortTrackNamesK(), undefined),
86
+ sortCategories: localStorageGetJSON(sortCategoriesK(), undefined),
87
87
  collapsed: observable.map(),
88
88
  filterText: '',
89
89
  recentlyUsedCounter: 0,
@@ -451,46 +451,35 @@ export default function stateTreeFactory(pluginManager) {
451
451
  // this should be the first autorun to properly initialize
452
452
  addDisposer(self, autorun(() => {
453
453
  const { assemblyNames, view } = self;
454
- self.setRecentlyUsed(localStorageGetJSON(recentlyUsedK(assemblyNames), '[]'));
454
+ self.setRecentlyUsed(localStorageGetJSON(recentlyUsedK(assemblyNames), []));
455
455
  if (view) {
456
- const val = localStorageGetItem(collapsedK(assemblyNames, view.type));
457
- if (!val) {
456
+ const lc = localStorageGetJSON(collapsedK(assemblyNames, view.type), undefined);
457
+ const r = ['hierarchical', 'defaultCollapsed'];
458
+ const session = getSession(self);
459
+ if (!lc) {
458
460
  self.expandAllCategories();
459
- const session = getSession(self);
460
- if (getConf(session, [
461
- 'hierarchical',
462
- 'defaultCollapsed',
463
- 'topLevelCategories',
464
- ])) {
461
+ if (getConf(session, [...r, 'topLevelCategories'])) {
465
462
  self.collapseTopLevelCategories();
466
463
  }
467
- if (getConf(session, [
468
- 'hierarchical',
469
- 'defaultCollapsed',
470
- 'subCategories',
471
- ])) {
464
+ if (getConf(session, [...r, 'subCategories'])) {
472
465
  self.collapseSubCategories();
473
466
  }
474
- for (const entry of getConf(session, [
475
- 'hierarchical',
476
- 'defaultCollapsed',
477
- 'categoryNames',
478
- ])) {
479
- self.setCategoryCollapsed(`Tracks-${entry}`, true);
467
+ for (const elt of getConf(session, [...r, 'categoryNames'])) {
468
+ self.setCategoryCollapsed(`Tracks-${elt}`, true);
480
469
  }
481
470
  }
482
471
  else {
483
- self.setCollapsedCategories(JSON.parse(val));
472
+ self.setCollapsedCategories(lc);
484
473
  }
485
474
  }
486
475
  }));
487
476
  // this should be the second autorun
488
477
  addDisposer(self, autorun(() => {
489
- const { assemblyNames, collapsed, view } = self;
490
- localStorageSetJSON(recentlyUsedK(assemblyNames), self.recentlyUsed);
491
- localStorageSetJSON(favoritesK(), self.favorites);
492
- localStorageSetJSON(sortTrackNamesK(), self.sortTrackNames);
493
- localStorageSetJSON(sortCategoriesK(), self.sortCategories);
478
+ const { sortTrackNames, sortCategories, favorites, recentlyUsed, assemblyNames, collapsed, view, } = self;
479
+ localStorageSetJSON(recentlyUsedK(assemblyNames), recentlyUsed);
480
+ localStorageSetJSON(favoritesK(), favorites);
481
+ localStorageSetJSON(sortTrackNamesK(), sortTrackNames);
482
+ localStorageSetJSON(sortCategoriesK(), sortCategories);
494
483
  if (view) {
495
484
  localStorageSetJSON(collapsedK(assemblyNames, view.type), collapsed);
496
485
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-data-management",
3
- "version": "2.12.3",
3
+ "version": "2.13.0",
4
4
  "description": "JBrowse 2 linear genome view",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -60,5 +60,5 @@
60
60
  "distModule": "esm/index.js",
61
61
  "srcModule": "src/index.ts",
62
62
  "module": "esm/index.js",
63
- "gitHead": "2775490221cde56af344acebb0afa7e14531cd81"
63
+ "gitHead": "efe02fb9616e20e929cceeed46eb96420c1b6923"
64
64
  }