Skip to content

Commit

Permalink
Merge pull request #963 from jtpio/optional-notebook-tracker
Browse files Browse the repository at this point in the history
Make `INotebookTracker` optional
  • Loading branch information
jtpio authored Sep 15, 2021
2 parents aa79d9c + 85227d3 commit 5bc146e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/jupyterlab-preview/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,17 @@ class VoilaRenderButton
const extension: JupyterFrontEndPlugin<IVoilaPreviewTracker> = {
id: '@voila-dashboards/jupyterlab-preview:plugin',
autoStart: true,
requires: [INotebookTracker],
optional: [ICommandPalette, ILayoutRestorer, IMainMenu, ISettingRegistry],
optional: [
INotebookTracker,
ICommandPalette,
ILayoutRestorer,
IMainMenu,
ISettingRegistry
],
provides: IVoilaPreviewTracker,
activate: (
app: JupyterFrontEnd,
notebooks: INotebookTracker,
notebooks: INotebookTracker | null,
palette: ICommandPalette | null,
restorer: ILayoutRestorer | null,
menu: IMainMenu | null,
Expand All @@ -114,7 +119,7 @@ const extension: JupyterFrontEndPlugin<IVoilaPreviewTracker> = {
}

function getCurrent(args: ReadonlyPartialJSONObject): NotebookPanel | null {
const widget = notebooks.currentWidget;
const widget = notebooks?.currentWidget ?? null;
const activate = args['activate'] !== false;

if (activate && widget) {
Expand All @@ -126,8 +131,8 @@ const extension: JupyterFrontEndPlugin<IVoilaPreviewTracker> = {

function isEnabled(): boolean {
return (
notebooks.currentWidget !== null &&
notebooks.currentWidget === app.shell.currentWidget
notebooks?.currentWidget !== null &&
notebooks?.currentWidget === app.shell.currentWidget
);
}

Expand Down

0 comments on commit 5bc146e

Please sign in to comment.