Skip to content

Commit dc14e27

Browse files
committed
Improve handling of optional notebook tracker
1 parent 3c4b8b5 commit dc14e27

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/lab-extension/src/index.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ const interfaceSwitcher: JupyterFrontEndPlugin<void> = {
6969
id: '@jupyter-notebook/lab-extension:interface-switcher',
7070
description: 'A plugin to add custom toolbar items to the notebook page.',
7171
autoStart: true,
72-
requires: [ITranslator, INotebookTracker],
72+
requires: [ITranslator],
7373
optional: [
74+
INotebookTracker,
7475
ICommandPalette,
7576
INotebookPathOpener,
7677
INotebookShell,
@@ -80,13 +81,18 @@ const interfaceSwitcher: JupyterFrontEndPlugin<void> = {
8081
activate: (
8182
app: JupyterFrontEnd,
8283
translator: ITranslator,
83-
notebookTracker: INotebookTracker,
84+
notebookTracker: INotebookTracker | null,
8485
palette: ICommandPalette | null,
8586
notebookPathOpener: INotebookPathOpener | null,
8687
notebookShell: INotebookShell | null,
8788
labShell: ILabShell | null,
8889
toolbarRegistry: IToolbarWidgetRegistry | null
8990
) => {
91+
if (!notebookTracker) {
92+
// bail if trying to use this plugin without a notebook tracker
93+
return;
94+
}
95+
9096
const { commands, shell } = app;
9197
const baseUrl = PageConfig.getBaseUrl();
9298
const trans = translator.load('notebook');

0 commit comments

Comments
 (0)