Browse Source

IAddOptions are superfluous if layout restoration is purview of ApplicationShell.

Afshin Darian 8 years ago
parent
commit
ae6d982947

+ 2 - 2
src/about/plugin.ts

@@ -25,8 +25,8 @@ import {
  * The about page extension.
  */
 const plugin: JupyterLabPlugin<void> = {
+  activate,
   id: 'jupyter.extensions.about',
-  activate: activateAbout,
   autoStart: true,
   requires: [ICommandPalette, IInstanceRestorer]
 };
@@ -38,7 +38,7 @@ const plugin: JupyterLabPlugin<void> = {
 export default plugin;
 
 
-function activateAbout(app: JupyterLab, palette: ICommandPalette, restorer: IInstanceRestorer): void {
+function activate(app: JupyterLab, palette: ICommandPalette, restorer: IInstanceRestorer): void {
   const namespace = 'about-jupyterlab';
   const model = new AboutModel();
   const command = `${namespace}:show`;

+ 4 - 17
src/common/instancetracker.ts

@@ -152,7 +152,7 @@ class InstanceTracker<T extends Widget> implements IInstanceTracker<T>, IDisposa
    *
    * @param widget - The widget being added.
    */
-  add(widget: T, options: IInstanceRestorer.IAddOptions = { area: 'main' }): void {
+  add(widget: T): void {
     if (this._widgets.has(widget)) {
       console.warn(`${widget.id} already exists in the tracker.`);
       return;
@@ -169,15 +169,12 @@ class InstanceTracker<T extends Widget> implements IInstanceTracker<T>, IDisposa
       if (widgetName) {
         let name = `${this.namespace}:${widgetName}`;
         let data = this._restore.args(widget);
-        let metadata = options;
 
         Private.nameProperty.set(widget, name);
-        Private.metadataProperty.set(widget, metadata);
-
-        state.save(name, { data, metadata });
+        state.save(name, { data });
 
         if (restorer) {
-          restorer.add(widget, name, options);
+          restorer.add(widget, name);
         }
       }
     }
@@ -337,9 +334,7 @@ class InstanceTracker<T extends Widget> implements IInstanceTracker<T>, IDisposa
 
     if (newName) {
       let data = this._restore.args(widget);
-      let metadata = Private.metadataProperty.get(widget);
-
-      state.save(newName, { data, metadata });
+      state.save(newName, { data });
     }
   }
 
@@ -446,14 +441,6 @@ namespace Private {
     value: false
   });
 
-  /**
-   * An attached property for a widget's restore metadata in the state database.
-   */
-  export
-  const metadataProperty = new AttachedProperty<Widget, IInstanceRestorer.IAddOptions>({
-    name: 'metadata'
-  });
-
   /**
    * An attached property for a widget's ID in the state database.
    */

+ 1 - 1
src/help/plugin.ts

@@ -151,7 +151,7 @@ function activateHelpHandler(app: JupyterLab, mainMenu: IMainMenu, palette: ICom
     iframe.id = `${namespace}`;
     iframe.url = url;
     // Add the iframe to the instance tracker.
-    tracker.add(iframe, { area: 'right' });
+    tracker.add(iframe);
 
     // If the help widget visibility changes, update the tracker.
     installMessageHook(iframe, (iframe: IFrame, msg: Message) => {

+ 2 - 17
src/instancerestorer/instancerestorer.ts

@@ -35,10 +35,6 @@ import {
   Token
 } from 'phosphor/lib/core/token';
 
-import {
-  ApplicationShell
-} from '../application/shell';
-
 import {
   InstanceTracker
 } from '../common/instancetracker';
@@ -70,7 +66,7 @@ interface IInstanceRestorer {
   /**
    * Add a widget to be tracked by the instance restorer.
    */
-  add(widget: Widget, name: string, options?: IInstanceRestorer.IAddOptions): void;
+  add(widget: Widget, name: string): void;
 
   /**
    * Restore the widgets of a particular instance tracker.
@@ -88,17 +84,6 @@ interface IInstanceRestorer {
  */
 export
 namespace IInstanceRestorer {
-  /**
-   * Configuration options for adding a widget to an instance restorer.
-   */
-  export
-  interface IAddOptions extends JSONObject {
-    /**
-     * The area in the application shell where a given widget will be restored.
-     */
-    area: ApplicationShell.Area;
-  }
-
   /**
    * The state restoration configuration options.
    */
@@ -208,7 +193,7 @@ class InstanceRestorer implements IInstanceRestorer {
   /**
    * Add a widget to be tracked by the instance restorer.
    */
-  add(widget: Widget, name: string, options: IInstanceRestorer.IAddOptions = { area: 'main' }): void {
+  add(widget: Widget, name: string): void {
     Private.nameProperty.set(widget, name);
     this._widgets.set(name, widget);
     widget.disposed.connect(() => { this._widgets.delete(name); });

+ 13 - 19
src/mainmenu/plugin.ts

@@ -31,7 +31,19 @@ const JUPYTER_ICON_CLASS = 'jp-JupyterIcon';
 const plugin: JupyterLabPlugin<IMainMenu> = {
   id: 'jupyter.services.main-menu',
   provides: IMainMenu,
-  activate: activateMainMenu
+  activate: (app: JupyterLab): IMainMenu => {
+    let menu = new MainMenu({ keymap: app.keymap });
+    menu.id = 'jp-MainMenu';
+
+    let logo = new Widget();
+    logo.node.className = `${PORTRAIT_ICON_CLASS} ${JUPYTER_ICON_CLASS}`;
+    logo.id = 'jp-MainLogo';
+
+    app.shell.addToTopArea(logo);
+    app.shell.addToTopArea(menu);
+
+    return menu;
+  }
 };
 
 
@@ -39,21 +51,3 @@ const plugin: JupyterLabPlugin<IMainMenu> = {
  * Export the plugin as default.
  */
 export default plugin;
-
-
-/**
- * Activate the main menu extension.
- */
-function activateMainMenu(app: JupyterLab): IMainMenu {
-  let menu = new MainMenu({ keymap: app.keymap });
-  menu.id = 'jp-MainMenu';
-
-  let logo = new Widget();
-  logo.node.className = `${PORTRAIT_ICON_CLASS} ${JUPYTER_ICON_CLASS}`;
-  logo.id = 'jp-MainLogo';
-
-  app.shell.addToTopArea(logo);
-  app.shell.addToTopArea(menu);
-
-  return menu;
-}