Skip to content

Commit fdef18b

Browse files
committed
Build navigator on top of @lumino/application
1 parent 7de5f8f commit fdef18b

File tree

8 files changed

+27
-106
lines changed

8 files changed

+27
-106
lines changed

packages/navigator/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
"watch": "npm-run-all --parallel watch:ts watch:webpack"
3131
},
3232
"dependencies": {
33-
"@jupyterlab/application": "^2.0.0",
3433
"@jupyterlab/apputils": "^2.0.0",
3534
"@jupyterlab/mainmenu": "^2.0.0",
3635
"@jupyterlab/theme-light-extension": "^2.0.0",
3736
"@jupyterlab/ui-components": "^2.0.0",
37+
"@lumino/application": "^1.11.0",
3838
"@lumino/widgets": "^1.13.2",
3939
"@mamba-org/common": "^1.0.0",
4040
"es6-promise": "~4.2.8",
@@ -43,6 +43,7 @@
4343
"react-dom": "~16.9.0"
4444
},
4545
"devDependencies": {
46+
"@jupyterlab/buildutils": "^2.0.0",
4647
"@typescript-eslint/eslint-plugin": "^2.25.0",
4748
"@typescript-eslint/parser": "^2.25.0",
4849
"css-loader": "~3.2.0",

packages/navigator/src/app/app.ts

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
import {
2-
JupyterFrontEnd,
3-
JupyterFrontEndPlugin
4-
} from '@jupyterlab/application';
5-
6-
import { PageConfig } from '@jupyterlab/coreutils';
1+
import { Application, IPlugin } from '@lumino/application';
72

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

5+
/**
6+
* The type for all JupyterFrontEnd application plugins.
7+
*
8+
* @typeparam T - The type that the plugin `provides` upon being activated.
9+
*/
10+
export type GatorFrontEndPlugin<T> = IPlugin<Gator, T>;
11+
1012
/**
1113
* Gator is the main application class. It is instantiated once and shared.
1214
*/
13-
export class Gator extends JupyterFrontEnd<IGatorShell> {
15+
export class Gator extends Application<IGatorShell> {
1416
/**
1517
* Construct a new App object.
1618
*
1719
* @param options The instantiation options for an Gator application.
1820
*/
19-
constructor(options: Gator.IOptions = { shell: new GatorShell() }) {
21+
constructor(
22+
options: Application.IOptions<IGatorShell> = { shell: new GatorShell() }
23+
) {
2024
super({
2125
shell: options.shell
2226
});
@@ -37,38 +41,6 @@ export class Gator extends JupyterFrontEnd<IGatorShell> {
3741
*/
3842
readonly version = 'unknown';
3943

40-
/**
41-
* The JupyterLab application paths dictionary.
42-
*/
43-
get paths(): JupyterFrontEnd.IPaths {
44-
return {
45-
urls: {
46-
base: PageConfig.getOption('baseUrl'),
47-
notFound: PageConfig.getOption('notFoundUrl'),
48-
app: PageConfig.getOption('appUrl'),
49-
static: PageConfig.getOption('staticUrl'),
50-
settings: PageConfig.getOption('settingsUrl'),
51-
themes: PageConfig.getOption('themesUrl'),
52-
tree: PageConfig.getOption('treeUrl'),
53-
workspaces: PageConfig.getOption('workspacesUrl'),
54-
hubHost: PageConfig.getOption('hubHost') || undefined,
55-
hubPrefix: PageConfig.getOption('hubPrefix') || undefined,
56-
hubUser: PageConfig.getOption('hubUser') || undefined,
57-
hubServerName: PageConfig.getOption('hubServerName') || undefined
58-
},
59-
directories: {
60-
appSettings: PageConfig.getOption('appSettingsDir'),
61-
schemas: PageConfig.getOption('schemasDir'),
62-
static: PageConfig.getOption('staticDir'),
63-
templates: PageConfig.getOption('templatesDir'),
64-
themes: PageConfig.getOption('themesDir'),
65-
userSettings: PageConfig.getOption('userSettingsDir'),
66-
serverRoot: PageConfig.getOption('serverRoot'),
67-
workspaces: PageConfig.getOption('workspacesDir')
68-
}
69-
};
70-
}
71-
7244
/**
7345
* Register plugins from a plugin module.
7446
*
@@ -108,11 +80,6 @@ export class Gator extends JupyterFrontEnd<IGatorShell> {
10880
* A namespace for Gator statics.
10981
*/
11082
export namespace Gator {
111-
/**
112-
* The instantiation options for an Gator application.
113-
*/
114-
export type IOptions = JupyterFrontEnd.IOptions<IGatorShell>;
115-
11683
/**
11784
* The interface for a module that exports a plugin or plugins as
11885
* the default value.
@@ -121,6 +88,6 @@ export namespace Gator {
12188
/**
12289
* The default export.
12390
*/
124-
default: JupyterFrontEndPlugin<any> | JupyterFrontEndPlugin<any>[];
91+
default: IPlugin<Gator, any> | IPlugin<Gator, any>[];
12592
}
12693
}

packages/navigator/src/app/shell.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { JupyterFrontEnd } from '@jupyterlab/application';
2-
31
import { classes, DockPanelSvg, LabIcon } from '@jupyterlab/ui-components';
42

53
import { IIterator, iter, toArray } from '@lumino/algorithm';
@@ -21,7 +19,7 @@ export namespace IGatorShell {
2119
/**
2220
* The application shell.
2321
*/
24-
export class GatorShell extends Widget implements JupyterFrontEnd.IShell {
22+
export class GatorShell extends Widget {
2523
constructor() {
2624
super();
2725
this.id = 'main';

packages/navigator/src/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import '../style/index.css';
1313
*/
1414
async function main(): Promise<void> {
1515
const app = new Gator();
16-
const mods = [
17-
require('./plugins/paths'),
18-
require('./plugins/navigator'),
19-
require('./plugins/top')
20-
];
16+
const mods = [require('./plugins/navigator'), require('./plugins/top')];
2117

2218
app.registerPluginModules(mods);
2319

packages/navigator/src/plugins/navigator/index.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import {
2-
JupyterFrontEnd,
3-
JupyterFrontEndPlugin
4-
} from '@jupyterlab/application';
51
import { DOMUtils, MainAreaWidget } from '@jupyterlab/apputils';
62
import {
73
CondaEnvironments,
@@ -10,21 +6,15 @@ import {
106
CONDA_WIDGET_CLASS
117
} from '@mamba-org/common';
128
import { INotification } from 'jupyterlab_toastify';
13-
14-
/**
15-
* The command ids used by the main navigator plugin.
16-
*/
17-
export namespace CommandIDs {
18-
export const open = '@mamba-org/navigator:open';
19-
}
9+
import { Gator, GatorFrontEndPlugin } from '../../app/app';
2010

2111
/**
2212
* The main navigator plugin.
2313
*/
24-
const plugin: JupyterFrontEndPlugin<void> = {
14+
const plugin: GatorFrontEndPlugin<void> = {
2515
id: '@mamba-org/navigator:main',
2616
autoStart: true,
27-
activate: (app: JupyterFrontEnd): void => {
17+
activate: (app: Gator): void => {
2818
const model = new CondaEnvironments();
2919

3020
// Request listing available package as quickly as possible

packages/navigator/src/plugins/paths/index.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/navigator/src/plugins/top/index.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
import {
2-
JupyterFrontEnd,
3-
JupyterFrontEndPlugin
4-
} from '@jupyterlab/application';
5-
6-
import { showDialog, Dialog } from '@jupyterlab/apputils';
7-
1+
import { Dialog, showDialog } from '@jupyterlab/apputils';
82
import { Widget } from '@lumino/widgets';
9-
3+
import * as React from 'react';
4+
import { Gator, GatorFrontEndPlugin } from '../../app/app';
5+
import { mambaIcon } from '../../icons';
106
import { MainMenu } from './menu';
11-
127
import { IMainMenu } from './tokens';
138

14-
import { mambaIcon } from '../../icons';
15-
16-
import * as React from 'react';
17-
189
/**
1910
* The command IDs used by the top plugin.
2011
*/
@@ -25,11 +16,11 @@ namespace CommandIDs {
2516
/**
2617
* The main menu plugin.
2718
*/
28-
const plugin: JupyterFrontEndPlugin<IMainMenu> = {
19+
const plugin: GatorFrontEndPlugin<IMainMenu> = {
2920
id: '@mamba-org/navigator:menu',
3021
autoStart: true,
3122
provides: IMainMenu,
32-
activate: (app: JupyterFrontEnd): IMainMenu => {
23+
activate: (app: Gator): IMainMenu => {
3324
const logo = new Widget();
3425
mambaIcon.element({
3526
container: logo.node,

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2315,7 +2315,7 @@
23152315
resolved "https://registry.yarnpkg.com/@lumino/algorithm/-/algorithm-1.3.3.tgz#fdf4daa407a1ce6f233e173add6a2dda0c99eef4"
23162316
integrity sha512-I2BkssbOSLq3rDjgAC3fzf/zAIwkRUnAh60MO0lYcaFdSGyI15w4K3gwZHGIO0p9cKEiNHLXKEODGmOjMLOQ3g==
23172317

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

0 commit comments

Comments
 (0)