@jupyter-notebook/lab-extension 7.0.0-beta.3 → 7.0.0-rc.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.
- package/lib/index.js +65 -30
- package/package.json +10 -10
- package/schema/interface-switcher.json +7 -0
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
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
107
|
-
|
|
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-
|
|
3
|
+
"version": "7.0.0-rc.0",
|
|
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-
|
|
47
|
-
"@jupyterlab/application": "^4.0.
|
|
48
|
-
"@jupyterlab/apputils": "^4.
|
|
49
|
-
"@jupyterlab/coreutils": "^6.0.
|
|
50
|
-
"@jupyterlab/docregistry": "^4.0.
|
|
51
|
-
"@jupyterlab/notebook": "^4.0.
|
|
52
|
-
"@jupyterlab/translation": "^4.0.
|
|
53
|
-
"@jupyterlab/ui-components": "^4.0.
|
|
46
|
+
"@jupyter-notebook/application": "^7.0.0-rc.0",
|
|
47
|
+
"@jupyterlab/application": "^4.0.2",
|
|
48
|
+
"@jupyterlab/apputils": "^4.1.2",
|
|
49
|
+
"@jupyterlab/coreutils": "^6.0.2",
|
|
50
|
+
"@jupyterlab/docregistry": "^4.0.2",
|
|
51
|
+
"@jupyterlab/notebook": "^4.0.2",
|
|
52
|
+
"@jupyterlab/translation": "^4.0.2",
|
|
53
|
+
"@jupyterlab/ui-components": "^4.0.2",
|
|
54
54
|
"@lumino/commands": "^2.1.1",
|
|
55
55
|
"@lumino/disposable": "^2.1.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@jupyterlab/builder": "^4.0.
|
|
58
|
+
"@jupyterlab/builder": "^4.0.2",
|
|
59
59
|
"rimraf": "^3.0.2",
|
|
60
60
|
"typescript": "~5.0.2"
|
|
61
61
|
},
|