Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add token on tree widget #6496

Merged
merged 5 commits into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@jupyter-notebook/help-extension": "~7.0.0-alpha.5",
"@jupyter-notebook/notebook-extension": "~7.0.0-alpha.5",
"@jupyter-notebook/terminal-extension": "~7.0.0-alpha.5",
"@jupyter-notebook/tree": "~7.0.0-alpha.5",
"@jupyter-notebook/tree-extension": "~7.0.0-alpha.5",
"@jupyter-notebook/ui-components": "~7.0.0-alpha.5",
"@jupyterlab/application": "~4.0.0-alpha.10",
Expand Down Expand Up @@ -104,6 +105,7 @@
"@jupyter-notebook/help-extension": "^7.0.0-alpha.5",
"@jupyter-notebook/notebook-extension": "^7.0.0-alpha.5",
"@jupyter-notebook/terminal-extension": "^7.0.0-alpha.5",
"@jupyter-notebook/tree": "^7.0.0-alpha.5",
"@jupyter-notebook/tree-extension": "^7.0.0-alpha.5",
"@jupyter-notebook/ui-components": "^7.0.0-alpha.5",
"@jupyterlab/application-extension": "^4.0.0-alpha.10",
Expand Down Expand Up @@ -194,6 +196,7 @@
"@jupyterlab/user-extension"
],
"singletonPackages": [
"@jupyter-notebook/tree",
"@jupyterlab/application",
"@jupyterlab/apputils",
"@jupyterlab/cell-toolbar",
Expand Down
1 change: 1 addition & 0 deletions packages/_metapackage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@jupyter-notebook/lab-extension": "file:../lab-extension",
"@jupyter-notebook/notebook-extension": "file:../notebook-extension",
"@jupyter-notebook/terminal-extension": "file:../terminal-extension",
"@jupyter-notebook/tree": "file:../tree",
"@jupyter-notebook/tree-extension": "file:../tree-extension",
"@jupyter-notebook/ui-components": "file:../ui-components"
},
Expand Down
1 change: 1 addition & 0 deletions packages/_metapackage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import '@jupyter-notebook/help-extension';
import '@jupyter-notebook/lab-extension';
import '@jupyter-notebook/notebook-extension';
import '@jupyter-notebook/terminal-extension';
import '@jupyter-notebook/tree';
import '@jupyter-notebook/tree-extension';
import '@jupyter-notebook/ui-components';
1 change: 1 addition & 0 deletions packages/tree-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
},
"dependencies": {
"@jupyter-notebook/application": "^7.0.0-alpha.5",
"@jupyter-notebook/tree": "^7.0.0-alpha.5",
"@jupyterlab/application": "^4.0.0-alpha.10",
"@jupyterlab/apputils": "^4.0.0-alpha.10",
"@jupyterlab/coreutils": "^6.0.0-alpha.10",
Expand Down
37 changes: 18 additions & 19 deletions packages/tree-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import { ITranslator } from '@jupyterlab/translation';
import {
caretDownIcon,
folderIcon,
runningIcon,
TabBarSvg
runningIcon
} from '@jupyterlab/ui-components';

import { Menu, MenuBar, TabPanel } from '@lumino/widgets';
import { Menu, MenuBar } from '@lumino/widgets';

import { NotebookTreeWidget, INotebookTree } from '@jupyter-notebook/tree';

/**
* The file browser factory.
Expand Down Expand Up @@ -94,9 +95,9 @@ const createNew: JupyterFrontEndPlugin<void> = {
};

/**
* A plugin to add the file browser widget to an ILabShell
* A plugin to add the file browser widget to an INotebookShell
*/
const browserWidget: JupyterFrontEndPlugin<void> = {
const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
id: '@jupyter-notebook/tree-extension:widget',
requires: [
IFileBrowserFactory,
Expand All @@ -106,20 +107,16 @@ const browserWidget: JupyterFrontEndPlugin<void> = {
],
optional: [IRunningSessionManagers],
autoStart: true,
provides: INotebookTree,
activate: (
app: JupyterFrontEnd,
factory: IFileBrowserFactory,
translator: ITranslator,
settingRegistry: ISettingRegistry,
toolbarRegistry: IToolbarWidgetRegistry,
manager: IRunningSessionManagers | null
): void => {
const tabPanel = new TabPanel({
tabPlacement: 'top',
tabsMovable: true,
renderer: TabBarSvg.defaultRenderer
});
tabPanel.addClass('jp-TreePanel');
): INotebookTree => {
const nbTreeWidget = new NotebookTreeWidget();

const trans = translator.load('notebook');

Expand All @@ -129,8 +126,8 @@ const browserWidget: JupyterFrontEndPlugin<void> = {
browser.node.setAttribute('aria-label', trans.__('File Browser Section'));
browser.title.icon = folderIcon;

tabPanel.addWidget(browser);
tabPanel.tabBar.addTab(browser.title);
nbTreeWidget.addWidget(browser);
nbTreeWidget.tabBar.addTab(browser.title);

// Toolbar
toolbarRegistry.addFactory(
Expand All @@ -150,7 +147,7 @@ const browserWidget: JupyterFrontEndPlugin<void> = {
toolbarRegistry,
settingRegistry,
FILE_BROWSER_FACTORY,
browserWidget.id,
notebookTreeWidget.id,
translator
)
);
Expand All @@ -160,8 +157,8 @@ const browserWidget: JupyterFrontEndPlugin<void> = {
running.id = 'jp-running-sessions';
running.title.label = trans.__('Running');
running.title.icon = runningIcon;
tabPanel.addWidget(running);
tabPanel.tabBar.addTab(running.title);
nbTreeWidget.addWidget(running);
nbTreeWidget.tabBar.addTab(running.title);
}

// show checkboxes by default if there is no user setting override
Expand All @@ -177,12 +174,14 @@ const browserWidget: JupyterFrontEndPlugin<void> = {
console.error(reason.message);
});

app.shell.add(tabPanel, 'main', { rank: 100 });
app.shell.add(nbTreeWidget, 'main', { rank: 100 });

return nbTreeWidget;
}
};

/**
* Export the plugins as default.
*/
const plugins: JupyterFrontEndPlugin<any>[] = [createNew, browserWidget];
const plugins: JupyterFrontEndPlugin<any>[] = [createNew, notebookTreeWidget];
export default plugins;
2 changes: 1 addition & 1 deletion packages/tree-extension/style/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@import url('~@jupyterlab/filebrowser/style/index.css');

@import url('./base.css');
@import url('~@jupyter-notebook/tree/style/index.css');
2 changes: 1 addition & 1 deletion packages/tree-extension/style/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import '@jupyterlab/filebrowser/style/index.js';

import './base.css';
import '@jupyter-notebook/tree/style/index.js';
66 changes: 66 additions & 0 deletions packages/tree/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"name": "@jupyter-notebook/tree",
"version": "7.0.0-alpha.5",
"description": "Jupyter Notebook - Tree",
"homepage": "https://github.com/jupyter/notebook",
"bugs": {
"url": "https://github.com/jupyter/notebook/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/jupyter/notebook.git"
},
"license": "BSD-3-Clause",
"author": "Project Jupyter",
"sideEffects": [
"style/**/*.css",
"style/index.js"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"style": "style/index.css",
"directories": {
"lib": "lib/"
},
"files": [
"lib/*.d.ts",
"lib/*.js.map",
"lib/*.js",
"schema/*.json",
"style/**/*.css",
"style/index.js"
],
"scripts": {
"build": "tsc -b",
"build:prod": "tsc -b",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
"docs": "typedoc src",
"prepublishOnly": "npm run build",
"watch": "tsc -b --watch"
},
"dependencies": {
"@jupyter-notebook/application": "^7.0.0-alpha.5",
"@jupyterlab/application": "^4.0.0-alpha.10",
"@jupyterlab/apputils": "^4.0.0-alpha.10",
"@jupyterlab/coreutils": "^6.0.0-alpha.10",
"@jupyterlab/docmanager": "^4.0.0-alpha.10",
"@jupyterlab/filebrowser": "^4.0.0-alpha.10",
"@jupyterlab/mainmenu": "^4.0.0-alpha.10",
"@jupyterlab/services": "^7.0.0-alpha.10",
"@jupyterlab/settingregistry": "^4.0.0-alpha.10",
"@jupyterlab/statedb": "^4.0.0-alpha.10",
"@jupyterlab/translation": "^4.0.0-alpha.10",
"@jupyterlab/ui-components": "^4.0.0-alpha.25",
"@lumino/algorithm": "^1.9.1",
"@lumino/commands": "^1.20.0",
"@lumino/widgets": "^1.32.0"
},
"devDependencies": {
"rimraf": "~3.0.0",
"typescript": "~4.6.3"
},
"publishConfig": {
"access": "public"
},
"styleModule": "style/index.js"
}
2 changes: 2 additions & 0 deletions packages/tree/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './notebook-tree';
export * from './token';
22 changes: 22 additions & 0 deletions packages/tree/src/notebook-tree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { TabBarSvg } from '@jupyterlab/ui-components';

import { TabPanel } from '@lumino/widgets';

import { INotebookTree } from './token';

/**
* The widget added in main area of the tree view.
*/
export class NotebookTreeWidget extends TabPanel implements INotebookTree {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a docstring to the class and constructor for consistency with the rest of the code base?

/**
* Constructor of the NotebookTreeWidget.
*/
constructor() {
super({
tabPlacement: 'top',
tabsMovable: true,
renderer: TabBarSvg.defaultRenderer
});
this.addClass('jp-TreePanel');
}
}
14 changes: 14 additions & 0 deletions packages/tree/src/token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Token } from '@lumino/coreutils';
import { TabPanel } from '@lumino/widgets';

/**
* The INotebookTree interface.
*/
export interface INotebookTree extends TabPanel {}

/**
* The INotebookTree token.
*/
export const INotebookTree = new Token<INotebookTree>(
'@jupyter-notebook/tree:INotebookTree'
);
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/tree/style/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import url('~@jupyterlab/filebrowser/style/index.css');

@import url('./base.css');
3 changes: 3 additions & 0 deletions packages/tree/style/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import '@jupyterlab/filebrowser/style/index.js';

import './base.css';
13 changes: 13 additions & 0 deletions packages/tree/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfigbase",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/**/*"],
"references": [
{
"path": "../application"
}
]
}
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,26 @@
"@lumino/algorithm" "^1.9.1"

"@jupyter-notebook/tree-extension@file:packages/tree-extension":
version "7.0.0-alpha.5"
dependencies:
"@jupyter-notebook/application" "^7.0.0-alpha.5"
"@jupyter-notebook/tree" "^7.0.0-alpha.5"
"@jupyterlab/application" "^4.0.0-alpha.10"
"@jupyterlab/apputils" "^4.0.0-alpha.10"
"@jupyterlab/coreutils" "^6.0.0-alpha.10"
"@jupyterlab/docmanager" "^4.0.0-alpha.10"
"@jupyterlab/filebrowser" "^4.0.0-alpha.10"
"@jupyterlab/mainmenu" "^4.0.0-alpha.10"
"@jupyterlab/services" "^7.0.0-alpha.10"
"@jupyterlab/settingregistry" "^4.0.0-alpha.10"
"@jupyterlab/statedb" "^4.0.0-alpha.10"
"@jupyterlab/translation" "^4.0.0-alpha.10"
"@jupyterlab/ui-components" "^4.0.0-alpha.25"
"@lumino/algorithm" "^1.9.1"
"@lumino/commands" "^1.20.0"
"@lumino/widgets" "^1.32.0"

"@jupyter-notebook/tree@file:packages/tree":
version "7.0.0-alpha.5"
dependencies:
"@jupyter-notebook/application" "^7.0.0-alpha.5"
Expand Down