Skip to content

Commit d204fb2

Browse files
committed
Build navigator on top of @lumino/application
1 parent eb05db7 commit d204fb2

File tree

12 files changed

+34
-174
lines changed

12 files changed

+34
-174
lines changed

packages/navigator/.eslintrc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
const eslintBase = require('../../eslint-base');
22

3-
module.exports = eslintBase;
3+
module.exports = {
4+
...eslintBase,
5+
parserOptions: {
6+
project: 'tsconfig.json',
7+
sourceType: 'module'
8+
}
9+
};

packages/navigator/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +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",
35-
"@jupyterlab/buildutils": "^2.0.0",
3634
"@jupyterlab/mainmenu": "^2.0.0",
3735
"@jupyterlab/theme-light-extension": "^2.0.0",
3836
"@jupyterlab/ui-components": "^2.0.0",
37+
"@lumino/application": "^1.11.0",
3938
"@lumino/widgets": "^1.13.2",
4039
"@mamba-org/common": "^1.0.0",
4140
"es6-promise": "~4.2.8",
@@ -44,6 +43,7 @@
4443
"react-dom": "~16.9.0"
4544
},
4645
"devDependencies": {
46+
"@jupyterlab/buildutils": "^2.0.0",
4747
"@typescript-eslint/eslint-plugin": "^2.25.0",
4848
"@typescript-eslint/parser": "^2.25.0",
4949
"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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,11 @@ 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

2420
await app.start();
25-
await app.restored;
2621
}
2722

2823
window.addEventListener('load', main);

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

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
1-
import {
2-
JupyterFrontEnd,
3-
JupyterFrontEndPlugin
4-
} from '@jupyterlab/application';
51
import { DOMUtils, MainAreaWidget } from '@jupyterlab/apputils';
6-
import { Widget } from '@lumino/widgets';
72
import {
83
CondaEnvironments,
94
CondaEnvWidget,
105
condaIcon,
116
CONDA_WIDGET_CLASS
127
} from '@mamba-org/common';
138
import { INotification } from 'jupyterlab_toastify';
14-
import { mambaIcon } from '../../icons';
15-
import { IMainMenu } from '../top/tokens';
16-
17-
/**
18-
* The command ids used by the main navigator plugin.
19-
*/
20-
export namespace CommandIDs {
21-
export const open = '@mamba-org/navigator:open';
22-
}
9+
import { Gator, GatorFrontEndPlugin } from '../../app/app';
2310

2411
/**
2512
* The main navigator plugin.
2613
*/
27-
const plugin: JupyterFrontEndPlugin<void> = {
14+
const plugin: GatorFrontEndPlugin<void> = {
2815
id: '@mamba-org/navigator:main',
2916
autoStart: true,
30-
optional: [IMainMenu],
31-
activate: (app: JupyterFrontEnd, menu: IMainMenu | null): void => {
32-
const { commands } = app;
33-
17+
activate: (app: Gator): void => {
3418
const model = new CondaEnvironments();
3519

3620
// Request listing available package as quickly as possible
@@ -44,27 +28,6 @@ const plugin: JupyterFrontEndPlugin<void> = {
4428
content.title.icon = condaIcon;
4529
const widget = new MainAreaWidget({ content });
4630
app.shell.add(widget, 'main');
47-
48-
commands.addCommand(CommandIDs.open, {
49-
label: 'Open',
50-
execute: () => {
51-
const widget = new Widget();
52-
mambaIcon.element({
53-
container: widget.node,
54-
elementPosition: 'center',
55-
margin: '5px 5px 5px 5px',
56-
height: 'auto',
57-
width: 'auto'
58-
});
59-
widget.id = DOMUtils.createDomID();
60-
widget.title.label = 'Mamba Logo';
61-
app.shell.add(widget, 'main');
62-
}
63-
});
64-
65-
if (menu) {
66-
menu.fileMenu.addGroup([{ command: CommandIDs.open }]);
67-
}
6831
}
6932
};
7033

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

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

packages/navigator/src/plugins/top/file.ts

Lines changed: 0 additions & 19 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,

packages/navigator/src/plugins/top/menu.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { CommandRegistry } from '@lumino/commands';
44

55
import { MenuBar } from '@lumino/widgets';
66

7-
import { FileMenu } from './file';
8-
97
import { HelpMenu } from './help';
108

119
import { IMainMenu } from './tokens';
@@ -22,28 +20,18 @@ export class MainMenu extends MenuBar implements IMainMenu {
2220
constructor(options: MainMenu.IOptions) {
2321
super();
2422
const { commands } = options;
25-
this._fileMenu = new FileMenu({ commands });
2623
this._helpMenu = new HelpMenu({ commands });
2724

28-
this.addMenu(this._fileMenu.menu);
2925
this.addMenu(this._helpMenu.menu);
3026
}
3127

32-
/**
33-
* Get the file menu.
34-
*/
35-
get fileMenu(): IJupyterLabMenu {
36-
return this._fileMenu;
37-
}
38-
3928
/**
4029
* Get the help menu.
4130
*/
4231
get helpMenu(): IJupyterLabMenu {
4332
return this._helpMenu;
4433
}
4534

46-
private _fileMenu: FileMenu;
4735
private _helpMenu: HelpMenu;
4836
}
4937

0 commit comments

Comments
 (0)