Skip to content

Commit

Permalink
Build navigator on top of @lumino/application
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Nov 11, 2020
1 parent 7de5f8f commit fdef18b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 106 deletions.
3 changes: 2 additions & 1 deletion packages/navigator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"watch": "npm-run-all --parallel watch:ts watch:webpack"
},
"dependencies": {
"@jupyterlab/application": "^2.0.0",
"@jupyterlab/apputils": "^2.0.0",
"@jupyterlab/mainmenu": "^2.0.0",
"@jupyterlab/theme-light-extension": "^2.0.0",
"@jupyterlab/ui-components": "^2.0.0",
"@lumino/application": "^1.11.0",
"@lumino/widgets": "^1.13.2",
"@mamba-org/common": "^1.0.0",
"es6-promise": "~4.2.8",
Expand All @@ -43,6 +43,7 @@
"react-dom": "~16.9.0"
},
"devDependencies": {
"@jupyterlab/buildutils": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^2.25.0",
"@typescript-eslint/parser": "^2.25.0",
"css-loader": "~3.2.0",
Expand Down
59 changes: 13 additions & 46 deletions packages/navigator/src/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import {
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';

import { PageConfig } from '@jupyterlab/coreutils';
import { Application, IPlugin } from '@lumino/application';

import { IGatorShell, GatorShell } from './shell';

/**
* The type for all JupyterFrontEnd application plugins.
*
* @typeparam T - The type that the plugin `provides` upon being activated.
*/
export type GatorFrontEndPlugin<T> = IPlugin<Gator, T>;

/**
* Gator is the main application class. It is instantiated once and shared.
*/
export class Gator extends JupyterFrontEnd<IGatorShell> {
export class Gator extends Application<IGatorShell> {
/**
* Construct a new App object.
*
* @param options The instantiation options for an Gator application.
*/
constructor(options: Gator.IOptions = { shell: new GatorShell() }) {
constructor(
options: Application.IOptions<IGatorShell> = { shell: new GatorShell() }
) {
super({
shell: options.shell
});
Expand All @@ -37,38 +41,6 @@ export class Gator extends JupyterFrontEnd<IGatorShell> {
*/
readonly version = 'unknown';

/**
* The JupyterLab application paths dictionary.
*/
get paths(): JupyterFrontEnd.IPaths {
return {
urls: {
base: PageConfig.getOption('baseUrl'),
notFound: PageConfig.getOption('notFoundUrl'),
app: PageConfig.getOption('appUrl'),
static: PageConfig.getOption('staticUrl'),
settings: PageConfig.getOption('settingsUrl'),
themes: PageConfig.getOption('themesUrl'),
tree: PageConfig.getOption('treeUrl'),
workspaces: PageConfig.getOption('workspacesUrl'),
hubHost: PageConfig.getOption('hubHost') || undefined,
hubPrefix: PageConfig.getOption('hubPrefix') || undefined,
hubUser: PageConfig.getOption('hubUser') || undefined,
hubServerName: PageConfig.getOption('hubServerName') || undefined
},
directories: {
appSettings: PageConfig.getOption('appSettingsDir'),
schemas: PageConfig.getOption('schemasDir'),
static: PageConfig.getOption('staticDir'),
templates: PageConfig.getOption('templatesDir'),
themes: PageConfig.getOption('themesDir'),
userSettings: PageConfig.getOption('userSettingsDir'),
serverRoot: PageConfig.getOption('serverRoot'),
workspaces: PageConfig.getOption('workspacesDir')
}
};
}

/**
* Register plugins from a plugin module.
*
Expand Down Expand Up @@ -108,11 +80,6 @@ export class Gator extends JupyterFrontEnd<IGatorShell> {
* A namespace for Gator statics.
*/
export namespace Gator {
/**
* The instantiation options for an Gator application.
*/
export type IOptions = JupyterFrontEnd.IOptions<IGatorShell>;

/**
* The interface for a module that exports a plugin or plugins as
* the default value.
Expand All @@ -121,6 +88,6 @@ export namespace Gator {
/**
* The default export.
*/
default: JupyterFrontEndPlugin<any> | JupyterFrontEndPlugin<any>[];
default: IPlugin<Gator, any> | IPlugin<Gator, any>[];
}
}
4 changes: 1 addition & 3 deletions packages/navigator/src/app/shell.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { JupyterFrontEnd } from '@jupyterlab/application';

import { classes, DockPanelSvg, LabIcon } from '@jupyterlab/ui-components';

import { IIterator, iter, toArray } from '@lumino/algorithm';
Expand All @@ -21,7 +19,7 @@ export namespace IGatorShell {
/**
* The application shell.
*/
export class GatorShell extends Widget implements JupyterFrontEnd.IShell {
export class GatorShell extends Widget {
constructor() {
super();
this.id = 'main';
Expand Down
6 changes: 1 addition & 5 deletions packages/navigator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ import '../style/index.css';
*/
async function main(): Promise<void> {
const app = new Gator();
const mods = [
require('./plugins/paths'),
require('./plugins/navigator'),
require('./plugins/top')
];
const mods = [require('./plugins/navigator'), require('./plugins/top')];

app.registerPluginModules(mods);

Expand Down
16 changes: 3 additions & 13 deletions packages/navigator/src/plugins/navigator/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import {
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { DOMUtils, MainAreaWidget } from '@jupyterlab/apputils';
import {
CondaEnvironments,
Expand All @@ -10,21 +6,15 @@ import {
CONDA_WIDGET_CLASS
} from '@mamba-org/common';
import { INotification } from 'jupyterlab_toastify';

/**
* The command ids used by the main navigator plugin.
*/
export namespace CommandIDs {
export const open = '@mamba-org/navigator:open';
}
import { Gator, GatorFrontEndPlugin } from '../../app/app';

/**
* The main navigator plugin.
*/
const plugin: JupyterFrontEndPlugin<void> = {
const plugin: GatorFrontEndPlugin<void> = {
id: '@mamba-org/navigator:main',
autoStart: true,
activate: (app: JupyterFrontEnd): void => {
activate: (app: Gator): void => {
const model = new CondaEnvironments();

// Request listing available package as quickly as possible
Expand Down
22 changes: 0 additions & 22 deletions packages/navigator/src/plugins/paths/index.ts

This file was deleted.

21 changes: 6 additions & 15 deletions packages/navigator/src/plugins/top/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import {
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';

import { showDialog, Dialog } from '@jupyterlab/apputils';

import { Dialog, showDialog } from '@jupyterlab/apputils';
import { Widget } from '@lumino/widgets';

import * as React from 'react';
import { Gator, GatorFrontEndPlugin } from '../../app/app';
import { mambaIcon } from '../../icons';
import { MainMenu } from './menu';

import { IMainMenu } from './tokens';

import { mambaIcon } from '../../icons';

import * as React from 'react';

/**
* The command IDs used by the top plugin.
*/
Expand All @@ -25,11 +16,11 @@ namespace CommandIDs {
/**
* The main menu plugin.
*/
const plugin: JupyterFrontEndPlugin<IMainMenu> = {
const plugin: GatorFrontEndPlugin<IMainMenu> = {
id: '@mamba-org/navigator:menu',
autoStart: true,
provides: IMainMenu,
activate: (app: JupyterFrontEnd): IMainMenu => {
activate: (app: Gator): IMainMenu => {
const logo = new Widget();
mambaIcon.element({
container: logo.node,
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2315,7 +2315,7 @@
resolved "https://registry.yarnpkg.com/@lumino/algorithm/-/algorithm-1.3.3.tgz#fdf4daa407a1ce6f233e173add6a2dda0c99eef4"
integrity sha512-I2BkssbOSLq3rDjgAC3fzf/zAIwkRUnAh60MO0lYcaFdSGyI15w4K3gwZHGIO0p9cKEiNHLXKEODGmOjMLOQ3g==

"@lumino/application@^1.8.4":
"@lumino/application@^1.11.0", "@lumino/application@^1.8.4":
version "1.11.0"
resolved "https://registry.yarnpkg.com/@lumino/application/-/application-1.11.0.tgz#25b859cf7910b0021c9396dffee523df99025647"
integrity sha512-kHizRpmzEyCWKIyX1th4S4bCyKJKdauBCLRmftHudNV5+l8g48bCB8xTHI+ILQ4WNziaYEwFFioLSxRr4/ih8w==
Expand Down

0 comments on commit fdef18b

Please sign in to comment.