|
@@ -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;
|
|
|
}
|