Skip to content

Commit 3674afe

Browse files
authored
Merge pull request #6496 from brichet/feature/tree_token
Add token on tree widget
2 parents c6faa5c + 9ac98a6 commit 3674afe

File tree

16 files changed

+169
-21
lines changed

16 files changed

+169
-21
lines changed

app/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@jupyter-notebook/help-extension": "~7.0.0-alpha.5",
2020
"@jupyter-notebook/notebook-extension": "~7.0.0-alpha.5",
2121
"@jupyter-notebook/terminal-extension": "~7.0.0-alpha.5",
22+
"@jupyter-notebook/tree": "~7.0.0-alpha.5",
2223
"@jupyter-notebook/tree-extension": "~7.0.0-alpha.5",
2324
"@jupyter-notebook/ui-components": "~7.0.0-alpha.5",
2425
"@jupyterlab/application": "~4.0.0-alpha.10",
@@ -104,6 +105,7 @@
104105
"@jupyter-notebook/help-extension": "^7.0.0-alpha.5",
105106
"@jupyter-notebook/notebook-extension": "^7.0.0-alpha.5",
106107
"@jupyter-notebook/terminal-extension": "^7.0.0-alpha.5",
108+
"@jupyter-notebook/tree": "^7.0.0-alpha.5",
107109
"@jupyter-notebook/tree-extension": "^7.0.0-alpha.5",
108110
"@jupyter-notebook/ui-components": "^7.0.0-alpha.5",
109111
"@jupyterlab/application-extension": "^4.0.0-alpha.10",
@@ -194,6 +196,7 @@
194196
"@jupyterlab/user-extension"
195197
],
196198
"singletonPackages": [
199+
"@jupyter-notebook/tree",
197200
"@jupyterlab/application",
198201
"@jupyterlab/apputils",
199202
"@jupyterlab/cell-toolbar",

packages/_metapackage/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@jupyter-notebook/lab-extension": "file:../lab-extension",
3030
"@jupyter-notebook/notebook-extension": "file:../notebook-extension",
3131
"@jupyter-notebook/terminal-extension": "file:../terminal-extension",
32+
"@jupyter-notebook/tree": "file:../tree",
3233
"@jupyter-notebook/tree-extension": "file:../tree-extension",
3334
"@jupyter-notebook/ui-components": "file:../ui-components"
3435
},

packages/_metapackage/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ import '@jupyter-notebook/help-extension';
77
import '@jupyter-notebook/lab-extension';
88
import '@jupyter-notebook/notebook-extension';
99
import '@jupyter-notebook/terminal-extension';
10+
import '@jupyter-notebook/tree';
1011
import '@jupyter-notebook/tree-extension';
1112
import '@jupyter-notebook/ui-components';

packages/tree-extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
},
4141
"dependencies": {
4242
"@jupyter-notebook/application": "^7.0.0-alpha.5",
43+
"@jupyter-notebook/tree": "^7.0.0-alpha.5",
4344
"@jupyterlab/application": "^4.0.0-alpha.10",
4445
"@jupyterlab/apputils": "^4.0.0-alpha.10",
4546
"@jupyterlab/coreutils": "^6.0.0-alpha.10",

packages/tree-extension/src/index.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ import { ITranslator } from '@jupyterlab/translation';
2727
import {
2828
caretDownIcon,
2929
folderIcon,
30-
runningIcon,
31-
TabBarSvg
30+
runningIcon
3231
} from '@jupyterlab/ui-components';
3332

34-
import { Menu, MenuBar, TabPanel } from '@lumino/widgets';
33+
import { Menu, MenuBar } from '@lumino/widgets';
34+
35+
import { NotebookTreeWidget, INotebookTree } from '@jupyter-notebook/tree';
3536

3637
/**
3738
* The file browser factory.
@@ -94,9 +95,9 @@ const createNew: JupyterFrontEndPlugin<void> = {
9495
};
9596

9697
/**
97-
* A plugin to add the file browser widget to an ILabShell
98+
* A plugin to add the file browser widget to an INotebookShell
9899
*/
99-
const browserWidget: JupyterFrontEndPlugin<void> = {
100+
const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
100101
id: '@jupyter-notebook/tree-extension:widget',
101102
requires: [
102103
IFileBrowserFactory,
@@ -106,20 +107,16 @@ const browserWidget: JupyterFrontEndPlugin<void> = {
106107
],
107108
optional: [IRunningSessionManagers],
108109
autoStart: true,
110+
provides: INotebookTree,
109111
activate: (
110112
app: JupyterFrontEnd,
111113
factory: IFileBrowserFactory,
112114
translator: ITranslator,
113115
settingRegistry: ISettingRegistry,
114116
toolbarRegistry: IToolbarWidgetRegistry,
115117
manager: IRunningSessionManagers | null
116-
): void => {
117-
const tabPanel = new TabPanel({
118-
tabPlacement: 'top',
119-
tabsMovable: true,
120-
renderer: TabBarSvg.defaultRenderer
121-
});
122-
tabPanel.addClass('jp-TreePanel');
118+
): INotebookTree => {
119+
const nbTreeWidget = new NotebookTreeWidget();
123120

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

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

132-
tabPanel.addWidget(browser);
133-
tabPanel.tabBar.addTab(browser.title);
129+
nbTreeWidget.addWidget(browser);
130+
nbTreeWidget.tabBar.addTab(browser.title);
134131

135132
// Toolbar
136133
toolbarRegistry.addFactory(
@@ -150,7 +147,7 @@ const browserWidget: JupyterFrontEndPlugin<void> = {
150147
toolbarRegistry,
151148
settingRegistry,
152149
FILE_BROWSER_FACTORY,
153-
browserWidget.id,
150+
notebookTreeWidget.id,
154151
translator
155152
)
156153
);
@@ -160,8 +157,8 @@ const browserWidget: JupyterFrontEndPlugin<void> = {
160157
running.id = 'jp-running-sessions';
161158
running.title.label = trans.__('Running');
162159
running.title.icon = runningIcon;
163-
tabPanel.addWidget(running);
164-
tabPanel.tabBar.addTab(running.title);
160+
nbTreeWidget.addWidget(running);
161+
nbTreeWidget.tabBar.addTab(running.title);
165162
}
166163

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

180-
app.shell.add(tabPanel, 'main', { rank: 100 });
177+
app.shell.add(nbTreeWidget, 'main', { rank: 100 });
178+
179+
return nbTreeWidget;
181180
}
182181
};
183182

184183
/**
185184
* Export the plugins as default.
186185
*/
187-
const plugins: JupyterFrontEndPlugin<any>[] = [createNew, browserWidget];
186+
const plugins: JupyterFrontEndPlugin<any>[] = [createNew, notebookTreeWidget];
188187
export default plugins;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@import url('~@jupyterlab/filebrowser/style/index.css');
22

3-
@import url('./base.css');
3+
@import url('~@jupyter-notebook/tree/style/index.css');
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import '@jupyterlab/filebrowser/style/index.js';
22

3-
import './base.css';
3+
import '@jupyter-notebook/tree/style/index.js';

packages/tree/package.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"name": "@jupyter-notebook/tree",
3+
"version": "7.0.0-alpha.5",
4+
"description": "Jupyter Notebook - Tree",
5+
"homepage": "https://github.com/jupyter/notebook",
6+
"bugs": {
7+
"url": "https://github.com/jupyter/notebook/issues"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/jupyter/notebook.git"
12+
},
13+
"license": "BSD-3-Clause",
14+
"author": "Project Jupyter",
15+
"sideEffects": [
16+
"style/**/*.css",
17+
"style/index.js"
18+
],
19+
"main": "lib/index.js",
20+
"types": "lib/index.d.ts",
21+
"style": "style/index.css",
22+
"directories": {
23+
"lib": "lib/"
24+
},
25+
"files": [
26+
"lib/*.d.ts",
27+
"lib/*.js.map",
28+
"lib/*.js",
29+
"schema/*.json",
30+
"style/**/*.css",
31+
"style/index.js"
32+
],
33+
"scripts": {
34+
"build": "tsc -b",
35+
"build:prod": "tsc -b",
36+
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
37+
"docs": "typedoc src",
38+
"prepublishOnly": "npm run build",
39+
"watch": "tsc -b --watch"
40+
},
41+
"dependencies": {
42+
"@jupyter-notebook/application": "^7.0.0-alpha.5",
43+
"@jupyterlab/application": "^4.0.0-alpha.10",
44+
"@jupyterlab/apputils": "^4.0.0-alpha.10",
45+
"@jupyterlab/coreutils": "^6.0.0-alpha.10",
46+
"@jupyterlab/docmanager": "^4.0.0-alpha.10",
47+
"@jupyterlab/filebrowser": "^4.0.0-alpha.10",
48+
"@jupyterlab/mainmenu": "^4.0.0-alpha.10",
49+
"@jupyterlab/services": "^7.0.0-alpha.10",
50+
"@jupyterlab/settingregistry": "^4.0.0-alpha.10",
51+
"@jupyterlab/statedb": "^4.0.0-alpha.10",
52+
"@jupyterlab/translation": "^4.0.0-alpha.10",
53+
"@jupyterlab/ui-components": "^4.0.0-alpha.25",
54+
"@lumino/algorithm": "^1.9.1",
55+
"@lumino/commands": "^1.20.0",
56+
"@lumino/widgets": "^1.32.0"
57+
},
58+
"devDependencies": {
59+
"rimraf": "~3.0.0",
60+
"typescript": "~4.6.3"
61+
},
62+
"publishConfig": {
63+
"access": "public"
64+
},
65+
"styleModule": "style/index.js"
66+
}

packages/tree/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './notebook-tree';
2+
export * from './token';

packages/tree/src/notebook-tree.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { TabBarSvg } from '@jupyterlab/ui-components';
2+
3+
import { TabPanel } from '@lumino/widgets';
4+
5+
import { INotebookTree } from './token';
6+
7+
/**
8+
* The widget added in main area of the tree view.
9+
*/
10+
export class NotebookTreeWidget extends TabPanel implements INotebookTree {
11+
/**
12+
* Constructor of the NotebookTreeWidget.
13+
*/
14+
constructor() {
15+
super({
16+
tabPlacement: 'top',
17+
tabsMovable: true,
18+
renderer: TabBarSvg.defaultRenderer
19+
});
20+
this.addClass('jp-TreePanel');
21+
}
22+
}

0 commit comments

Comments
 (0)