Browse Source

Remove path tracker from landing extension.

Afshin Darian 8 years ago
parent
commit
dcfd8c5ec7

+ 4 - 16
packages/landing-extension/src/index.ts

@@ -10,13 +10,9 @@ import {
 } from '@jupyterlab/application';
 
 import {
-  ICommandPalette, ILayoutRestorer, InstanceTracker
+  ICommandLinker, ICommandPalette, ILayoutRestorer, InstanceTracker
 } from '@jupyterlab/apputils';
 
-import {
-  IPathTracker
-} from '@jupyterlab/filebrowser';
-
 import {
   LandingModel, LandingWidget
 } from './widget';
@@ -42,7 +38,7 @@ const LANDING_CLASS = 'jp-Landing';
 const plugin: JupyterLabPlugin<void> = {
   activate,
   id: 'jupyter.extensions.landing',
-  requires: [IPathTracker, ICommandPalette, IServiceManager, ILayoutRestorer],
+  requires: [ICommandLinker, ICommandPalette, IServiceManager, ILayoutRestorer],
   autoStart: true
 };
 
@@ -56,7 +52,7 @@ export default plugin;
 /**
  * Activate the landing plugin.
  */
-function activate(app: JupyterLab, pathTracker: IPathTracker, palette: ICommandPalette, services: IServiceManager, restorer: ILayoutRestorer): void {
+function activate(app: JupyterLab, linker: ICommandLinker, palette: ICommandPalette, services: IServiceManager, restorer: ILayoutRestorer): void {
   const { commands, shell } = app;
   const category = 'Help';
   const command = CommandIDs.open;
@@ -76,7 +72,7 @@ function activate(app: JupyterLab, pathTracker: IPathTracker, palette: ICommandP
   let widget: LandingWidget;
 
   function newWidget(): LandingWidget {
-    let widget = new LandingWidget(app);
+    let widget = new LandingWidget(linker);
     widget.model = model;
     widget.id = 'landing-jupyterlab';
     widget.title.label = 'Landing';
@@ -97,14 +93,6 @@ function activate(app: JupyterLab, pathTracker: IPathTracker, palette: ICommandP
     }
   });
 
-  pathTracker.pathChanged.connect(() => {
-    if (pathTracker.path.length) {
-      model.path = 'home > ' + pathTracker.path.replace('/', ' > ');
-    } else {
-      model.path = 'home';
-    }
-  });
-
   palette.addItem({ category, command });
 
   // Only create a landing page if there are no other tabs open.

+ 29 - 79
packages/landing-extension/src/widget.ts

@@ -10,11 +10,7 @@ import {
 } from '@phosphor/virtualdom';
 
 import {
-  JupyterLab
-} from '@jupyterlab/application';
-
-import {
-  VDomModel, VDomWidget
+  ICommandLinker, VDomModel, VDomWidget
 } from '@jupyterlab/apputils';
 
 
@@ -73,26 +69,6 @@ const LANDING_ICON_CLASS = 'jp-Landing-image';
  */
 const LANDING_TEXT_CLASS = 'jp-Landing-text';
 
-/**
- * The class name added to the current working directory.
- */
-const LANDING_CWD_CLASS = 'jp-Landing-cwd';
-
-/**
- * The class name added to Landing folder node.
- */
-const FOLDER_CLASS = 'jp-Landing-folder';
-
-/**
- * The class name added for the folder icon from default-theme.
- */
-const FOLDER_ICON_CLASS = 'jp-FolderIcon';
-
-/**
- * The class name added to the current working directory path.
- */
-const LANDING_PATH_CLASS = 'jp-Landing-path';
-
 /**
  * The list of preview messages.
  */
@@ -106,8 +82,7 @@ const previewMessages = [
 
 
 /**
- * LandingModel keeps track of the path to working directory and has text data,
- * which the LandingWidget will render.
+ * LandingModel holds text data which the LandingWidget will render.
  */
 export
 class LandingModel extends VDomModel {
@@ -135,35 +110,16 @@ class LandingModel extends VDomModel {
       Math.floor(Math.random() * previewMessages.length)
     ];
     this.headerText = 'Start a new activity';
-    this.activities =
-    [['Notebook', 'filebrowser:new-notebook'],
-     ['Code Console', 'console:create'],
-     ['Text Editor', 'filebrowser:new-text-file']];
+    this.activities = [
+      ['Notebook', 'filebrowser:new-notebook'],
+      ['Code Console', 'console:create'],
+      ['Text Editor', 'filebrowser:new-text-file']
+    ];
 
     if (terminalsAvailable) {
-      this.activities.push(
-        ['Terminal', 'terminal:create-new']
-      );
+      this.activities.push(['Terminal', 'terminal:create-new']);
     }
-    this._path = 'home';
-  }
-
-  /**
-   * Get the path of the current working directory.
-   */
-  get path(): string {
-    return this._path;
   }
-
-  /**
-   * Set the path of the current working directory.
-   */
-  set path(value: string) {
-    this._path = value;
-    this.stateChanged.emit(void 0);
-  }
-
-  private _path: string;
 }
 
 /**
@@ -174,9 +130,9 @@ class LandingWidget extends VDomWidget<LandingModel> {
   /**
    * Construct a new landing widget.
    */
-  constructor(app: JupyterLab) {
+  constructor(linker: ICommandLinker) {
     super();
-    this._app = app;
+    this._linker = linker;
   }
 
   /**
@@ -204,47 +160,41 @@ class LandingWidget extends VDomWidget<LandingModel> {
     for (let activityName of activites) {
       let imgName = activityName[0].replace(' ', '');
       let column =
-      h.div({className: LANDING_COLUMN_CLASS},
-        h.span({className: LANDING_ICON_CLASS + ` jp-Image${imgName}` ,
-                onclick: () => {
-                  this._app.commands.execute(activityName[1], void 0);
-                }}
-        ),
-        h.span({className: LANDING_TEXT_CLASS}, activityName[0])
+      h.div({ className: LANDING_COLUMN_CLASS },
+        h.span({
+          className: LANDING_ICON_CLASS + ` jp-Image${imgName}` ,
+          dataset: this._linker.populateVNodeDataset(activityName[1], null)
+        }),
+        h.span({ className: LANDING_TEXT_CLASS }, activityName[0])
       );
       activitiesList.push(column);
     }
 
-    let logo = h.span({className: JUPYTERLAB_ICON_CLASS + ' ' + LANDING_LOGO_CLASS});
-    let subtitle =
-    h.span({className: LANDING_SUBTITLE_CLASS},
+    let logo = h.span({
+      className: `${JUPYTERLAB_ICON_CLASS} ${LANDING_LOGO_CLASS}`
+    });
+    let subtitle = h.span(
+      {className: LANDING_SUBTITLE_CLASS},
       this.model.previewMessage
     );
-    let tour =
-    h.span({className: TOUR_ICON_CLASS,
-      onclick: () => {
-        this._app.commands.execute('about-jupyterlab:open', void 0);
-      }}
-    );
+    let tour = h.span({
+      className: TOUR_ICON_CLASS,
+      dataset: this._linker.populateVNodeDataset('about-jupyterlab:open', null)
+    });
     let header = h.span({
       className: LANDING_HEADER_CLASS
     }, this.model.headerText);
-    let body = h.div({className: LANDING_BODY_CLASS}, activitiesList);
+    let body = h.div({ className: LANDING_BODY_CLASS }, activitiesList);
 
-    let dialog = h.div({className: LANDING_DIALOG_CLASS},
+    let dialog = h.div({ className: LANDING_DIALOG_CLASS },
       logo,
       subtitle,
       tour,
       header,
-      body,
-      h.div({className: LANDING_CWD_CLASS},
-        h.span({className: FOLDER_ICON_CLASS + ' ' + FOLDER_CLASS}),
-        h.span({className: LANDING_PATH_CLASS}, this.model.path
-        )
-      )
+      body
     );
     return h.div({ className: LANDING_WRAPPER_CLASS }, dialog);
   }
 
-  private _app: JupyterLab;
+  private _linker: ICommandLinker;
 }

+ 0 - 27
packages/landing-extension/style/index.css

@@ -114,30 +114,3 @@
     background-position: top center;
     background-repeat: no-repeat;
 }
-
-.jp-Landing-folder {
-  margin-right: 0;
-  display: inline-block;
-  background-origin: content-box;
-  background-repeat: no-repeat;
-  clear: none;
-  height: 1em;
-  width: 1em;
-  line-height: 1em;
-}
-
-.jp-Landing-folder:empty:before {
-  content: "\00a0";
-}
-
-.jp-Landing-path {
-    padding-left: 8px;
-    color: var(--jp-ui-font-color2);
-}
-
-.jp-Landing-cwd {
-    float: left;
-    padding-top: 24px;
-    padding-left: 14px;
-    margin-right: auto;
-}