Skip to content

Commit

Permalink
Fix JSON setting editor not opening issue (#6778) (#6795)
Browse files Browse the repository at this point in the history
  • Loading branch information
yumyumqing authored Mar 24, 2023
1 parent cc454bb commit 77e591a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
4 changes: 1 addition & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,7 @@
],
"@jupyter-notebook/tree-extension": true,
"@jupyterlab/running-extension": true,
"@jupyterlab/settingeditor-extension": [
"@jupyterlab/settingeditor-extension:form-ui"
]
"@jupyterlab/settingeditor-extension": true
},
"/notebooks": {
"@jupyterlab/celltags-extension": true,
Expand Down
33 changes: 23 additions & 10 deletions packages/tree-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import { ISettingRegistry } from '@jupyterlab/settingregistry';

import { IRunningSessionManagers, RunningSessions } from '@jupyterlab/running';

import { ISettingEditorTracker } from '@jupyterlab/settingeditor';
import {
IJSONSettingEditorTracker,
ISettingEditorTracker,
} from '@jupyterlab/settingeditor';

import { ITranslator } from '@jupyterlab/translation';

Expand Down Expand Up @@ -205,7 +208,11 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
ISettingRegistry,
IToolbarWidgetRegistry,
],
optional: [IRunningSessionManagers, ISettingEditorTracker],
optional: [
IRunningSessionManagers,
ISettingEditorTracker,
IJSONSettingEditorTracker,
],
autoStart: true,
provides: INotebookTree,
activate: (
Expand All @@ -215,7 +222,8 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {
settingRegistry: ISettingRegistry,
toolbarRegistry: IToolbarWidgetRegistry,
manager: IRunningSessionManagers | null,
settingEditorTracker: ISettingEditorTracker | null
settingEditorTracker: ISettingEditorTracker | null,
jsonSettingEditorTracker: IJSONSettingEditorTracker | null
): INotebookTree => {
const nbTreeWidget = new NotebookTreeWidget();

Expand Down Expand Up @@ -301,13 +309,18 @@ const notebookTreeWidget: JupyterFrontEndPlugin<INotebookTree> = {

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

if (settingEditorTracker) {
settingEditorTracker.widgetAdded.connect((_, editor) => {
nbTreeWidget.addWidget(editor);
nbTreeWidget.tabBar.addTab(editor.title);
nbTreeWidget.currentWidget = editor;
});
}
// add a separate tab for each setting editor
[settingEditorTracker, jsonSettingEditorTracker].forEach(
(editorTracker) => {
if (editorTracker) {
editorTracker.widgetAdded.connect((_, editor) => {
nbTreeWidget.addWidget(editor);
nbTreeWidget.tabBar.addTab(editor.title);
nbTreeWidget.currentWidget = editor;
});
}
}
);

return nbTreeWidget;
},
Expand Down

0 comments on commit 77e591a

Please sign in to comment.