Skip to content

Commit c8dd2f0

Browse files
committed
temp patch for the logconsole-extension
1 parent b33691a commit c8dd2f0

File tree

4 files changed

+102
-2
lines changed

4 files changed

+102
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ ui-tests/playwright-report
136136
ui-tests/.yarn/*
137137
ui-tests/.pnp.*
138138

139+
# keep potential upstream patches
140+
!.yarn/patches
141+
139142
# generated html
140143
notebook/templates/*.html
141144

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
diff --git a/lib/index.js b/lib/index.js
2+
index bbafe18540f26d4939ab94c6537bd42b88824a0e..f3056c125a53d0795cdc890a98ab70be1f64eb9d 100644
3+
--- a/lib/index.js
4+
+++ b/lib/index.js
5+
@@ -6,6 +6,7 @@
6+
*/
7+
import { ILabShell, ILayoutRestorer } from '@jupyterlab/application';
8+
import { ICommandPalette, MainAreaWidget, WidgetTracker } from '@jupyterlab/apputils';
9+
+import { DocumentWidget } from '@jupyterlab/docregistry';
10+
import { ILoggerRegistry, LogConsolePanel, LoggerRegistry } from '@jupyterlab/logconsole';
11+
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
12+
import { ISettingRegistry } from '@jupyterlab/settingregistry';
13+
@@ -34,14 +35,20 @@ const logConsolePlugin = {
14+
id: LOG_CONSOLE_PLUGIN_ID,
15+
description: 'Provides the logger registry.',
16+
provides: ILoggerRegistry,
17+
- requires: [ILabShell, IRenderMimeRegistry, ITranslator],
18+
- optional: [ICommandPalette, ILayoutRestorer, ISettingRegistry, IStatusBar],
19+
+ requires: [IRenderMimeRegistry, ITranslator],
20+
+ optional: [
21+
+ ILabShell,
22+
+ ICommandPalette,
23+
+ ILayoutRestorer,
24+
+ ISettingRegistry,
25+
+ IStatusBar
26+
+ ],
27+
autoStart: true
28+
};
29+
/**
30+
* Activate the Log Console extension.
31+
*/
32+
-function activateLogConsole(app, labShell, rendermime, translator, palette, restorer, settingRegistry, statusBar) {
33+
+function activateLogConsole(app, rendermime, translator, labShell, palette, restorer, settingRegistry, statusBar) {
34+
const trans = translator.load('jupyterlab');
35+
let logConsoleWidget = null;
36+
let logConsolePanel = null;
37+
@@ -75,10 +82,21 @@ function activateLogConsole(app, labShell, rendermime, translator, palette, rest
38+
},
39+
translator
40+
});
41+
+ const getCurrentWidgetPath = () => {
42+
+ const currentWidget = app.shell.currentWidget;
43+
+ if (labShell === null || labShell === void 0 ? void 0 : labShell.currentPath) {
44+
+ return labShell.currentPath;
45+
+ }
46+
+ // For other shells, set the source to the current widget path
47+
+ if (currentWidget && currentWidget instanceof DocumentWidget) {
48+
+ return currentWidget.context.path;
49+
+ }
50+
+ return null;
51+
+ };
52+
const createLogConsoleWidget = (options = {}) => {
53+
var _a, _b;
54+
logConsolePanel = new LogConsolePanel(loggerRegistry, translator);
55+
- logConsolePanel.source = (_b = (_a = options.source) !== null && _a !== void 0 ? _a : labShell.currentPath) !== null && _b !== void 0 ? _b : null;
56+
+ logConsolePanel.source = (_b = (_a = options.source) !== null && _a !== void 0 ? _a : getCurrentWidgetPath()) !== null && _b !== void 0 ? _b : null;
57+
logConsoleWidget = new MainAreaWidget({ content: logConsolePanel });
58+
logConsoleWidget.addClass('jp-LogConsole');
59+
logConsoleWidget.title.closable = true;
60+
@@ -194,8 +212,13 @@ function activateLogConsole(app, labShell, rendermime, translator, palette, rest
61+
var _a;
62+
// Set source only after app is restored in order to allow restorer to
63+
// restore previous source first, which may set the renderer
64+
- labShell.currentPathChanged.connect((_, { newValue }) => setSource(newValue));
65+
- setSource((_a = labShell.currentPath) !== null && _a !== void 0 ? _a : null);
66+
+ if (labShell) {
67+
+ labShell.currentPathChanged.connect((_, { newValue }) => setSource(newValue));
68+
+ setSource((_a = labShell.currentPath) !== null && _a !== void 0 ? _a : null);
69+
+ }
70+
+ else {
71+
+ setSource(getCurrentWidgetPath());
72+
+ }
73+
});
74+
if (settingRegistry) {
75+
const updateSettings = (settings) => {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"resolutions": {
4949
"@types/react": "^18.0.26",
5050
"react": "^18.2.0",
51-
"yjs": "^13.5.40"
51+
"yjs": "^13.5.40",
52+
"@jupyterlab/logconsole-extension@~4.4.0-rc.0": "patch:@jupyterlab/logconsole-extension@npm%3A4.4.0-rc.0#./.yarn/patches/@jupyterlab-logconsole-extension-npm-4.4.0-rc.0-23754c6f79.patch"
5253
},
5354
"devDependencies": {
5455
"@jupyterlab/buildutils": "~4.4.0-rc.0",

yarn.lock

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3832,7 +3832,7 @@ __metadata:
38323832
languageName: node
38333833
linkType: hard
38343834

3835-
"@jupyterlab/logconsole-extension@npm:~4.4.0-rc.0":
3835+
"@jupyterlab/logconsole-extension@npm:4.4.0-rc.0":
38363836
version: 4.4.0-rc.0
38373837
resolution: "@jupyterlab/logconsole-extension@npm:4.4.0-rc.0"
38383838
dependencies:
@@ -3853,6 +3853,27 @@ __metadata:
38533853
languageName: node
38543854
linkType: hard
38553855

3856+
"@jupyterlab/logconsole-extension@patch:@jupyterlab/logconsole-extension@npm%3A4.4.0-rc.0#./.yarn/patches/@jupyterlab-logconsole-extension-npm-4.4.0-rc.0-23754c6f79.patch::locator=%40jupyter-notebook%2Froot%40workspace%3A.":
3857+
version: 4.4.0-rc.0
3858+
resolution: "@jupyterlab/logconsole-extension@patch:@jupyterlab/logconsole-extension@npm%3A4.4.0-rc.0#./.yarn/patches/@jupyterlab-logconsole-extension-npm-4.4.0-rc.0-23754c6f79.patch::version=4.4.0-rc.0&hash=a8b986&locator=%40jupyter-notebook%2Froot%40workspace%3A."
3859+
dependencies:
3860+
"@jupyterlab/application": ^4.4.0-rc.0
3861+
"@jupyterlab/apputils": ^4.5.0-rc.0
3862+
"@jupyterlab/coreutils": ^6.4.0-rc.0
3863+
"@jupyterlab/logconsole": ^4.4.0-rc.0
3864+
"@jupyterlab/rendermime": ^4.4.0-rc.0
3865+
"@jupyterlab/settingregistry": ^4.4.0-rc.0
3866+
"@jupyterlab/statusbar": ^4.4.0-rc.0
3867+
"@jupyterlab/translation": ^4.4.0-rc.0
3868+
"@jupyterlab/ui-components": ^4.4.0-rc.0
3869+
"@lumino/coreutils": ^2.2.0
3870+
"@lumino/signaling": ^2.1.3
3871+
"@lumino/widgets": ^2.6.0
3872+
react: ^18.2.0
3873+
checksum: fa193ddc42dcf1216340f8bb407c858d7853279b5d0651324c25ee503765fced9f692e64914d24e0e3772044ef4bbde2ad342cbb1ded42a52161277173f45909
3874+
languageName: node
3875+
linkType: hard
3876+
38563877
"@jupyterlab/logconsole@npm:^4.4.0-rc.0":
38573878
version: 4.4.0-rc.0
38583879
resolution: "@jupyterlab/logconsole@npm:4.4.0-rc.0"

0 commit comments

Comments
 (0)