Skip to content

Commit

Permalink
Merge pull request #3033 from jtpio/optional-tracker
Browse files Browse the repository at this point in the history
Make INotebookTracker optional in the manager plugin
  • Loading branch information
jasongrout authored Feb 17, 2021
2 parents ef45312 + 9f97b00 commit 08093b0
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions jupyterlab_widgets/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export function registerWidgetManager(
*/
const plugin: JupyterFrontEndPlugin<base.IJupyterWidgetRegistry> = {
id: '@jupyter-widgets/jupyterlab-manager:plugin',
requires: [INotebookTracker, IRenderMimeRegistry, ISettingRegistry],
optional: [IMainMenu, ILoggerRegistry],
requires: [IRenderMimeRegistry, ISettingRegistry],
optional: [INotebookTracker, IMainMenu, ILoggerRegistry],
provides: base.IJupyterWidgetRegistry,
activate: activateWidgetExtension,
autoStart: true
Expand All @@ -176,9 +176,9 @@ function updateSettings(settings: ISettingRegistry.ISettings) {
*/
function activateWidgetExtension(
app: JupyterFrontEnd,
tracker: INotebookTracker,
rendermime: IRenderMimeRegistry,
settingRegistry: ISettingRegistry,
tracker: INotebookTracker | null,
menu: IMainMenu | null,
loggerRegistry: ILoggerRegistry | null): base.IJupyterWidgetRegistry {

Expand Down Expand Up @@ -228,30 +228,32 @@ function activateWidgetExtension(
0
);

tracker.forEach(panel => {
registerWidgetManager(
panel.context,
panel.content.rendermime,
chain(
widgetRenderers(panel.content),
outputViews(app, panel.context.path)
)
);

bindUnhandledIOPubMessageSignal(panel);
});
tracker.widgetAdded.connect((sender, panel) => {
registerWidgetManager(
panel.context,
panel.content.rendermime,
chain(
widgetRenderers(panel.content),
outputViews(app, panel.context.path)
)
);

bindUnhandledIOPubMessageSignal(panel);
});
if (tracker) {
tracker.forEach(panel => {
registerWidgetManager(
panel.context,
panel.content.rendermime,
chain(
widgetRenderers(panel.content),
outputViews(app, panel.context.path)
)
);

bindUnhandledIOPubMessageSignal(panel);
});
tracker.widgetAdded.connect((sender, panel) => {
registerWidgetManager(
panel.context,
panel.content.rendermime,
chain(
widgetRenderers(panel.content),
outputViews(app, panel.context.path)
)
);

bindUnhandledIOPubMessageSignal(panel);
});
}

// Add a command for creating a new Markdown file.
commands.addCommand('@jupyter-widgets/jupyterlab-manager:saveWidgetState', {
Expand Down

0 comments on commit 08093b0

Please sign in to comment.