Browse Source

Use activateMain() in plugins

Steven Silvester 8 years ago
parent
commit
d744f520ac
3 changed files with 6 additions and 37 deletions
  1. 2 12
      src/about/plugin.ts
  2. 2 12
      src/faq/plugin.ts
  3. 2 13
      src/landing/plugin.ts

+ 2 - 12
src/about/plugin.ts

@@ -1,10 +1,6 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import {
-  TabPanel
-} from 'phosphor/lib/ui/tabpanel';
-
 import {
   Widget
 } from 'phosphor/lib/ui/widget';
@@ -48,14 +44,8 @@ function activateAbout(app: JupyterLab, palette: ICommandPalette): void {
     execute: () => {
       if (!widget.isAttached) {
         app.shell.addToMainArea(widget);
-      }
-      let stack = widget.parent;
-      if (!stack) {
-        return;
-      }
-      let tabs = stack.parent;
-      if (tabs instanceof TabPanel) {
-        tabs.currentWidget = widget;
+      } else {
+        app.shell.activateMain(widget.id);
       }
     }
   });

+ 2 - 12
src/faq/plugin.ts

@@ -7,10 +7,6 @@ import {
   Message
 } from 'phosphor/lib/core/messaging';
 
-import {
-  TabPanel
-} from 'phosphor/lib/ui/tabpanel';
-
 import {
   Widget
 } from 'phosphor/lib/ui/widget';
@@ -336,14 +332,8 @@ function activateFAQ(app: JupyterLab, palette: ICommandPalette): void {
     execute: () => {
       if (!widget.isAttached) {
         app.shell.addToMainArea(widget);
-      }
-      let stack = widget.parent;
-      if (!stack) {
-        return;
-      }
-      let tabs = stack.parent;
-      if (tabs instanceof TabPanel) {
-        tabs.currentWidget = widget;
+      } else {
+        app.shell.activateMain(widget.id);
       }
     }
   });

+ 2 - 13
src/landing/plugin.ts

@@ -5,10 +5,6 @@ import {
   Widget
 } from 'phosphor/lib/ui/widget';
 
-import {
-  TabPanel
-} from 'phosphor/lib/ui/tabpanel';
-
 import {
   JupyterLab, JupyterLabPlugin
 } from '../application';
@@ -143,16 +139,9 @@ function activateLanding(app: JupyterLab, services: IServiceManager, pathTracker
     execute: () => {
       if (!widget.isAttached) {
         app.shell.addToMainArea(widget);
+      } else {
+        app.shell.activateMain(widget.id);
       }
-      let stack = widget.parent;
-      if (!stack) {
-        return;
-      }
-      let tabs = stack.parent;
-      if (tabs instanceof TabPanel) {
-        tabs.currentWidget = widget;
-      }
-      app.shell.activateMain(widget.id);
     }
   });