@jupyter-notebook/lab-extension 7.0.0-beta.2 → 7.0.0-beta.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.
package/lib/index.js CHANGED
@@ -7,7 +7,7 @@ import { INotebookTracker } from '@jupyterlab/notebook';
7
7
  import { ITranslator } from '@jupyterlab/translation';
8
8
  import { Menu, MenuBar } from '@lumino/widgets';
9
9
  import { INotebookShell } from '@jupyter-notebook/application';
10
- import { caretDownIcon } from '@jupyterlab/ui-components';
10
+ import { caretDownIcon, CommandToolbarButton, launchIcon, } from '@jupyterlab/ui-components';
11
11
  /**
12
12
  * The command IDs used by the application plugin.
13
13
  */
@@ -25,6 +25,10 @@ var CommandIDs;
25
25
  * Open in JupyterLab
26
26
  */
27
27
  CommandIDs.openLab = 'jupyter-notebook:open-lab';
28
+ /**
29
+ * Open in NbClassic
30
+ */
31
+ CommandIDs.openNbClassic = 'jupyter-notebook:open-nbclassic';
28
32
  })(CommandIDs || (CommandIDs = {}));
29
33
  /**
30
34
  * A plugin to add custom toolbar items to the notebook page
@@ -43,19 +47,41 @@ const interfaceSwitcher = {
43
47
  const { commands, shell } = app;
44
48
  const baseUrl = PageConfig.getBaseUrl();
45
49
  const trans = translator.load('notebook');
46
- const overflowOptions = {
47
- overflowMenuOptions: { isVisible: false },
48
- };
49
- const menubar = new MenuBar(overflowOptions);
50
+ const nbClassicEnabled = PageConfig.getOption('nbclassic_enabled') === 'true';
50
51
  const switcher = new Menu({ commands });
51
- switcher.title.label = trans.__('Open in...');
52
- switcher.title.icon = caretDownIcon;
53
- menubar.addMenu(switcher);
52
+ const switcherOptions = [];
53
+ if (!notebookShell) {
54
+ switcherOptions.push({
55
+ command: CommandIDs.openNotebook,
56
+ commandLabel: trans.__('Notebook'),
57
+ commandDescription: trans.__('Open in %1', 'Jupyter Notebook'),
58
+ buttonLabel: 'openNotebook',
59
+ urlPrefix: `${baseUrl}tree/`,
60
+ });
61
+ }
62
+ if (!labShell) {
63
+ switcherOptions.push({
64
+ command: CommandIDs.openLab,
65
+ commandLabel: trans.__('JupyterLab'),
66
+ commandDescription: trans.__('Open in %1', 'JupyterLab'),
67
+ buttonLabel: 'openLab',
68
+ urlPrefix: `${baseUrl}doc/tree/`,
69
+ });
70
+ }
71
+ if (nbClassicEnabled) {
72
+ switcherOptions.push({
73
+ command: CommandIDs.openNbClassic,
74
+ commandLabel: trans.__('NbClassic'),
75
+ commandDescription: trans.__('Open in %1', 'NbClassic'),
76
+ buttonLabel: 'openNbClassic',
77
+ urlPrefix: `${baseUrl}nbclassic/notebooks/`,
78
+ });
79
+ }
54
80
  const isEnabled = () => {
55
81
  return (notebookTracker.currentWidget !== null &&
56
82
  notebookTracker.currentWidget === shell.currentWidget);
57
83
  };
58
- const addInterface = (option) => {
84
+ const addSwitcherCommand = (option) => {
59
85
  const { command, commandLabel, commandDescription, urlPrefix } = option;
60
86
  const execute = () => {
61
87
  const current = notebookTracker.currentWidget;
@@ -83,33 +109,42 @@ const interfaceSwitcher = {
83
109
  args: { isPalette: true },
84
110
  });
85
111
  }
86
- switcher.addItem({ command });
87
112
  };
88
- if (!notebookShell) {
89
- addInterface({
90
- command: CommandIDs.openNotebook,
91
- commandLabel: trans.__('Notebook'),
92
- commandDescription: trans.__('Open in %1', 'Jupyter Notebook'),
93
- buttonLabel: 'openNotebook',
94
- urlPrefix: `${baseUrl}tree/`,
95
- });
96
- }
97
- if (!labShell) {
98
- addInterface({
99
- command: CommandIDs.openLab,
100
- commandLabel: trans.__('JupyterLab'),
101
- commandDescription: trans.__('Open in %1', 'JupyterLab'),
102
- buttonLabel: 'openLab',
103
- urlPrefix: `${baseUrl}doc/tree/`,
104
- });
113
+ switcherOptions.forEach((option) => {
114
+ const { command } = option;
115
+ addSwitcherCommand(option);
116
+ switcher.addItem({ command });
117
+ });
118
+ let toolbarFactory;
119
+ if (switcherOptions.length === 1) {
120
+ toolbarFactory = (panel) => {
121
+ const toolbarButton = new CommandToolbarButton({
122
+ commands,
123
+ id: switcherOptions[0].command,
124
+ label: switcherOptions[0].commandLabel,
125
+ icon: launchIcon,
126
+ });
127
+ toolbarButton.addClass('jp-nb-interface-switcher-button');
128
+ return toolbarButton;
129
+ };
105
130
  }
106
- if (toolbarRegistry) {
107
- toolbarRegistry.addFactory('Notebook', 'interfaceSwitcher', (panel) => {
131
+ else {
132
+ const overflowOptions = {
133
+ overflowMenuOptions: { isVisible: false },
134
+ };
135
+ const menubar = new MenuBar(overflowOptions);
136
+ switcher.title.label = trans.__('Open in...');
137
+ switcher.title.icon = caretDownIcon;
138
+ menubar.addMenu(switcher);
139
+ toolbarFactory = (panel) => {
108
140
  const menubar = new MenuBar(overflowOptions);
109
141
  menubar.addMenu(switcher);
110
142
  menubar.addClass('jp-InterfaceSwitcher');
111
143
  return menubar;
112
- });
144
+ };
145
+ }
146
+ if (toolbarRegistry) {
147
+ toolbarRegistry.addFactory('Notebook', 'interfaceSwitcher', toolbarFactory);
113
148
  }
114
149
  },
115
150
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/lab-extension",
3
- "version": "7.0.0-beta.2",
3
+ "version": "7.0.0-beta.4",
4
4
  "description": "Jupyter Notebook - Lab Extension",
5
5
  "homepage": "https://github.com/jupyter/notebook",
6
6
  "bugs": {
@@ -43,19 +43,19 @@
43
43
  "watch:src": "tsc -w"
44
44
  },
45
45
  "dependencies": {
46
- "@jupyter-notebook/application": "^7.0.0-beta.2",
47
- "@jupyterlab/application": "^4.0.0-rc.1",
48
- "@jupyterlab/apputils": "^4.0.0-rc.1",
49
- "@jupyterlab/coreutils": "^6.0.0-rc.1",
50
- "@jupyterlab/docregistry": "^4.0.0-rc.1",
51
- "@jupyterlab/notebook": "^4.0.0-rc.1",
52
- "@jupyterlab/translation": "^4.0.0-rc.1",
53
- "@jupyterlab/ui-components": "^4.0.0-rc.1",
46
+ "@jupyter-notebook/application": "^7.0.0-beta.4",
47
+ "@jupyterlab/application": "^4.0.1",
48
+ "@jupyterlab/apputils": "^4.1.1",
49
+ "@jupyterlab/coreutils": "^6.0.1",
50
+ "@jupyterlab/docregistry": "^4.0.1",
51
+ "@jupyterlab/notebook": "^4.0.1",
52
+ "@jupyterlab/translation": "^4.0.1",
53
+ "@jupyterlab/ui-components": "^4.0.1",
54
54
  "@lumino/commands": "^2.1.1",
55
55
  "@lumino/disposable": "^2.1.1"
56
56
  },
57
57
  "devDependencies": {
58
- "@jupyterlab/builder": "^4.0.0-rc.1",
58
+ "@jupyterlab/builder": "^4.0.1",
59
59
  "rimraf": "^3.0.2",
60
60
  "typescript": "~5.0.2"
61
61
  },
@@ -22,6 +22,13 @@
22
22
  "args": {
23
23
  "isMenu": true
24
24
  }
25
+ },
26
+ {
27
+ "command": "jupyter-notebook:open-nbclassic",
28
+ "rank": 10,
29
+ "args": {
30
+ "isMenu": true
31
+ }
25
32
  }
26
33
  ]
27
34
  }