Procházet zdrojové kódy

Make ILabShell optional in status bar plugin.

Afshin Darian před 6 roky
rodič
revize
fb4394a794

+ 1 - 1
packages/application/src/shell.ts

@@ -518,7 +518,7 @@ export class LabShell extends Widget implements JupyterClient.Shell {
       case 'top':
         return this.addToTopArea(widget, options);
       case 'bottom':
-        return this.addToTopArea(widget, options);
+        return this.addToBottomArea(widget, options);
       default:
         throw new Error(`Invalid area: ${area}`);
     }

+ 11 - 8
packages/statusbar-extension/src/index.ts

@@ -50,18 +50,21 @@ const statusBar: JupyterLabPlugin<IStatusBar> = {
   id: STATUSBAR_PLUGIN_ID,
   provides: IStatusBar,
   autoStart: true,
-  activate: (app: JupyterClient, shell: ILabShell) => {
+  activate: (app: JupyterClient, labShell: ILabShell | null) => {
     const statusBar = new StatusBar();
     statusBar.id = 'jp-main-statusbar';
-    shell.addToBottomArea(statusBar);
-    // Trigger a refresh of active status items if
-    // the application layout is modified.
-    shell.layoutModified.connect(() => {
-      statusBar.update();
-    });
+    app.shell.add(statusBar, 'bottom');
+
+    // If available, connect to the shell's layout modified signal.
+    if (labShell) {
+      labShell.layoutModified.connect(() => {
+        statusBar.update();
+      });
+    }
+
     return statusBar;
   },
-  requires: [ILabShell]
+  optional: [ILabShell]
 };
 
 /**

+ 4 - 8
packages/tabmanager-extension/src/index.ts

@@ -27,7 +27,6 @@ const plugin: JupyterLabPlugin<void> = {
     const { shell } = app;
     const tabs = new TabBar<Widget>({ orientation: 'vertical' });
     const header = document.createElement('header');
-    let debouncer: number;
 
     restorer.add(tabs, 'tab-manager');
     tabs.id = 'tab-manager';
@@ -39,13 +38,10 @@ const plugin: JupyterLabPlugin<void> = {
 
     app.restored.then(() => {
       const populate = () => {
-        window.clearTimeout(debouncer);
-        debouncer = window.setTimeout(() => {
-          tabs.clearTabs();
-          each(shell.widgets('main'), widget => {
-            tabs.addTab(widget.title);
-          });
-        }, 0);
+        tabs.clearTabs();
+        each(shell.widgets('main'), widget => {
+          tabs.addTab(widget.title);
+        });
       };
 
       // Connect signal handlers.