@jbrowse/plugin-menus 3.1.0 → 3.3.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.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const DataGridFlexContainer_1 = __importDefault(require("@jbrowse/core/ui/DataGridFlexContainer"));
7
8
  const util_1 = require("@jbrowse/core/util");
8
9
  const Delete_1 = __importDefault(require("@mui/icons-material/Delete"));
9
10
  const Star_1 = __importDefault(require("@mui/icons-material/Star"));
@@ -32,17 +33,18 @@ const SessionManager = (0, mobx_react_1.observer)(function ({ session, }) {
32
33
  return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: classes.mb, children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: showOnlyFavs, onChange: () => {
33
34
  setShowOnlyFavs(val => !val);
34
35
  } }), label: "Show only favorites?" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: () => {
35
- var _a;
36
36
  let i = 0;
37
- (_a = session.savedSessionMetadata) === null || _a === void 0 ? void 0 : _a.forEach(elt => {
38
- if ((0, date_fns_1.differenceInDays)(+Date.now(), elt.createdAt) > 1 &&
39
- !elt.favorite) {
40
- session.deleteSavedSession(elt.id);
41
- i++;
37
+ if (session.savedSessionMetadata) {
38
+ for (const elt of session.savedSessionMetadata) {
39
+ if ((0, date_fns_1.differenceInDays)(+Date.now(), elt.createdAt) > 1 &&
40
+ !elt.favorite) {
41
+ session.deleteSavedSession(elt.id);
42
+ i++;
43
+ }
42
44
  }
43
- });
45
+ }
44
46
  session.notify(`${i} sessions deleted`, 'info');
45
- }, children: "Delete non-fav sessions older than 7 days?" })] }), rows ? ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column' }, children: (0, jsx_runtime_1.jsx)(x_data_grid_1.DataGrid, { disableRowSelectionOnClick: true, columnHeaderHeight: 35, rowHeight: 25, hideFooter: rows.length < 100, slotProps: {
47
+ }, children: "Delete non-fav sessions older than 7 days?" })] }), rows ? ((0, jsx_runtime_1.jsx)(DataGridFlexContainer_1.default, { children: (0, jsx_runtime_1.jsx)(x_data_grid_1.DataGrid, { columnHeaderHeight: 35, rowHeight: 25, hideFooter: rows.length < 100, slotProps: {
46
48
  toolbar: {
47
49
  showQuickFilter: true,
48
50
  },
@@ -51,51 +53,43 @@ const SessionManager = (0, mobx_react_1.observer)(function ({ session, }) {
51
53
  field: 'fav',
52
54
  headerName: 'Fav',
53
55
  width: 20,
54
- renderCell: ({ row }) => {
55
- return ((0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: () => {
56
- if (row.fav) {
57
- session.unfavoriteSavedSession(row.id);
58
- }
59
- else {
60
- session.favoriteSavedSession(row.id);
61
- }
62
- }, children: row.fav ? (0, jsx_runtime_1.jsx)(Star_1.default, {}) : (0, jsx_runtime_1.jsx)(StarBorder_1.default, {}) }));
63
- },
56
+ renderCell: ({ row }) => ((0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: () => {
57
+ if (row.fav) {
58
+ session.unfavoriteSavedSession(row.id);
59
+ }
60
+ else {
61
+ session.favoriteSavedSession(row.id);
62
+ }
63
+ }, children: row.fav ? (0, jsx_runtime_1.jsx)(Star_1.default, {}) : (0, jsx_runtime_1.jsx)(StarBorder_1.default, {}) })),
64
64
  },
65
65
  {
66
66
  field: 'name',
67
67
  headerName: 'Name',
68
68
  editable: true,
69
69
  width: (0, util_1.measureGridWidth)(rows.map(r => r.name)),
70
- renderCell: ({ row }) => {
71
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Link, { href: "#", onClick: event => {
72
- event.preventDefault();
73
- session.activateSession(row.id);
74
- }, children: row.name }), session.id === row.id ? ' (current)' : ''] }));
75
- },
70
+ renderCell: ({ row }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Link, { href: "#", onClick: event => {
71
+ event.preventDefault();
72
+ session.activateSession(row.id);
73
+ }, children: row.name }), session.id === row.id ? ' (current)' : ''] })),
76
74
  },
77
75
  {
78
76
  headerName: 'Created at',
79
77
  field: 'createdAt',
80
- renderCell: ({ row }) => {
81
- return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { disableInteractive: true, slotProps: {
82
- transition: {
83
- timeout: 0,
84
- },
85
- }, title: row.createdAt.toLocaleString(), children: (0, jsx_runtime_1.jsx)("div", { children: (0, date_fns_1.formatDistanceToNow)(row.createdAt, {
86
- addSuffix: true,
87
- }) }) }));
88
- },
78
+ renderCell: ({ row }) => ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { disableInteractive: true, slotProps: {
79
+ transition: {
80
+ timeout: 0,
81
+ },
82
+ }, title: row.createdAt.toLocaleString(), children: (0, jsx_runtime_1.jsx)("div", { children: (0, date_fns_1.formatDistanceToNow)(row.createdAt, {
83
+ addSuffix: true,
84
+ }) }) })),
89
85
  },
90
86
  {
91
87
  field: 'delete',
92
88
  width: 10,
93
89
  headerName: 'Delete',
94
- renderCell: ({ row }) => {
95
- return ((0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: () => {
96
- session.deleteSavedSession(row.id);
97
- }, children: (0, jsx_runtime_1.jsx)(Delete_1.default, {}) }));
98
- },
90
+ renderCell: ({ row }) => ((0, jsx_runtime_1.jsx)(material_1.IconButton, { onClick: () => {
91
+ session.deleteSavedSession(row.id);
92
+ }, children: (0, jsx_runtime_1.jsx)(Delete_1.default, {}) })),
99
93
  },
100
94
  ] }) })) : ((0, jsx_runtime_1.jsx)("div", { children: "No sessions loaded" }))] }));
101
95
  });
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import DataGridFlexContainer from '@jbrowse/core/ui/DataGridFlexContainer';
2
3
  import { measureGridWidth, useLocalStorage } from '@jbrowse/core/util';
3
4
  import DeleteIcon from '@mui/icons-material/Delete';
4
5
  import StarIcon from '@mui/icons-material/Star';
@@ -27,17 +28,18 @@ const SessionManager = observer(function ({ session, }) {
27
28
  return (_jsxs("div", { children: [_jsxs("div", { className: classes.mb, children: [_jsx(FormControlLabel, { control: _jsx(Checkbox, { checked: showOnlyFavs, onChange: () => {
28
29
  setShowOnlyFavs(val => !val);
29
30
  } }), label: "Show only favorites?" }), _jsx(Button, { variant: "contained", onClick: () => {
30
- var _a;
31
31
  let i = 0;
32
- (_a = session.savedSessionMetadata) === null || _a === void 0 ? void 0 : _a.forEach(elt => {
33
- if (differenceInDays(+Date.now(), elt.createdAt) > 1 &&
34
- !elt.favorite) {
35
- session.deleteSavedSession(elt.id);
36
- i++;
32
+ if (session.savedSessionMetadata) {
33
+ for (const elt of session.savedSessionMetadata) {
34
+ if (differenceInDays(+Date.now(), elt.createdAt) > 1 &&
35
+ !elt.favorite) {
36
+ session.deleteSavedSession(elt.id);
37
+ i++;
38
+ }
37
39
  }
38
- });
40
+ }
39
41
  session.notify(`${i} sessions deleted`, 'info');
40
- }, children: "Delete non-fav sessions older than 7 days?" })] }), rows ? (_jsx("div", { style: { display: 'flex', flexDirection: 'column' }, children: _jsx(DataGrid, { disableRowSelectionOnClick: true, columnHeaderHeight: 35, rowHeight: 25, hideFooter: rows.length < 100, slotProps: {
42
+ }, children: "Delete non-fav sessions older than 7 days?" })] }), rows ? (_jsx(DataGridFlexContainer, { children: _jsx(DataGrid, { columnHeaderHeight: 35, rowHeight: 25, hideFooter: rows.length < 100, slotProps: {
41
43
  toolbar: {
42
44
  showQuickFilter: true,
43
45
  },
@@ -46,51 +48,43 @@ const SessionManager = observer(function ({ session, }) {
46
48
  field: 'fav',
47
49
  headerName: 'Fav',
48
50
  width: 20,
49
- renderCell: ({ row }) => {
50
- return (_jsx(IconButton, { onClick: () => {
51
- if (row.fav) {
52
- session.unfavoriteSavedSession(row.id);
53
- }
54
- else {
55
- session.favoriteSavedSession(row.id);
56
- }
57
- }, children: row.fav ? _jsx(StarIcon, {}) : _jsx(StarBorderIcon, {}) }));
58
- },
51
+ renderCell: ({ row }) => (_jsx(IconButton, { onClick: () => {
52
+ if (row.fav) {
53
+ session.unfavoriteSavedSession(row.id);
54
+ }
55
+ else {
56
+ session.favoriteSavedSession(row.id);
57
+ }
58
+ }, children: row.fav ? _jsx(StarIcon, {}) : _jsx(StarBorderIcon, {}) })),
59
59
  },
60
60
  {
61
61
  field: 'name',
62
62
  headerName: 'Name',
63
63
  editable: true,
64
64
  width: measureGridWidth(rows.map(r => r.name)),
65
- renderCell: ({ row }) => {
66
- return (_jsxs(_Fragment, { children: [_jsx(Link, { href: "#", onClick: event => {
67
- event.preventDefault();
68
- session.activateSession(row.id);
69
- }, children: row.name }), session.id === row.id ? ' (current)' : ''] }));
70
- },
65
+ renderCell: ({ row }) => (_jsxs(_Fragment, { children: [_jsx(Link, { href: "#", onClick: event => {
66
+ event.preventDefault();
67
+ session.activateSession(row.id);
68
+ }, children: row.name }), session.id === row.id ? ' (current)' : ''] })),
71
69
  },
72
70
  {
73
71
  headerName: 'Created at',
74
72
  field: 'createdAt',
75
- renderCell: ({ row }) => {
76
- return (_jsx(Tooltip, { disableInteractive: true, slotProps: {
77
- transition: {
78
- timeout: 0,
79
- },
80
- }, title: row.createdAt.toLocaleString(), children: _jsx("div", { children: formatDistanceToNow(row.createdAt, {
81
- addSuffix: true,
82
- }) }) }));
83
- },
73
+ renderCell: ({ row }) => (_jsx(Tooltip, { disableInteractive: true, slotProps: {
74
+ transition: {
75
+ timeout: 0,
76
+ },
77
+ }, title: row.createdAt.toLocaleString(), children: _jsx("div", { children: formatDistanceToNow(row.createdAt, {
78
+ addSuffix: true,
79
+ }) }) })),
84
80
  },
85
81
  {
86
82
  field: 'delete',
87
83
  width: 10,
88
84
  headerName: 'Delete',
89
- renderCell: ({ row }) => {
90
- return (_jsx(IconButton, { onClick: () => {
91
- session.deleteSavedSession(row.id);
92
- }, children: _jsx(DeleteIcon, {}) }));
93
- },
85
+ renderCell: ({ row }) => (_jsx(IconButton, { onClick: () => {
86
+ session.deleteSavedSession(row.id);
87
+ }, children: _jsx(DeleteIcon, {}) })),
94
88
  },
95
89
  ] }) })) : (_jsx("div", { children: "No sessions loaded" }))] }));
96
90
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-menus",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "JBrowse 2 basic menus",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -36,9 +36,9 @@
36
36
  "clean": "rimraf dist esm *.tsbuildinfo"
37
37
  },
38
38
  "dependencies": {
39
- "@jbrowse/core": "^3.1.0",
40
- "@mui/icons-material": "^6.0.0",
41
- "@mui/material": "^6.0.0",
39
+ "@jbrowse/core": "^3.3.0",
40
+ "@mui/icons-material": "^7.0.0",
41
+ "@mui/material": "^7.0.0",
42
42
  "date-fns": "^4.1.0",
43
43
  "mobx": "^6.0.0",
44
44
  "mobx-react": "^9.0.0",
@@ -57,5 +57,5 @@
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "91492049ddea0aed90eb24d3c066c2d9f5a6b189"
60
+ "gitHead": "0bb64d8cc7ecdd167515308b31eec3d9acbc59e4"
61
61
  }