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

JupyterLab 3 bug fix #98

Merged
merged 3 commits into from
Apr 23, 2024
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
4 changes: 2 additions & 2 deletions beakerx_widgets/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beakerx/beakerx-widgets",
"version": "2.4.2",
"version": "2.4.3",
"description": "BeakerX: Beaker EasyForms, Magics, Plots and Spark Extension for Jupyter Lab 2.x",
"homepage": "http://beakerx.com/",
"keywords": [
Expand Down Expand Up @@ -39,7 +39,7 @@
"prettier:fix": "prettier --check src/**/*.{ts,js} --write"
},
"devDependencies": {
"@jupyterlab/builder": "^4",
"@jupyterlab/builder": "^3 || ^4",
"@types/big.js": "^4.0.5",
"@types/chai": "^4.2.11",
"@types/d3": "^5.7.2",
Expand Down
21 changes: 17 additions & 4 deletions beakerx_widgets/js/src/lab/plugin/gistPublish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Cell, CodeCell } from '@jupyterlab/cells';
import { CommandRegistry } from '@lumino/commands';
import { GistPublisher, GistPublisherUtils } from '../../../plots/publisher';
import { AccessTokenProvider } from '../AccessTokenProvider';
import { Widget } from '@lumino/widgets';

export function registerGistPublishFeature(panel: NotebookPanel, commands: CommandRegistry, showPublication: boolean) {
if (showPublication) {
Expand Down Expand Up @@ -48,10 +49,22 @@ function addActionButton(panel: NotebookPanel, commands: CommandRegistry): void
}

function removeActionButton(panel: NotebookPanel): void {
for (const widget of panel.toolbar.layout) {
if (widget instanceof ToolbarButton && widget.id == 'bx-publishButton') {
panel.toolbar.layout.removeWidget(widget);
break;
try {
for (const widget of panel.toolbar.layout) {
if (widget instanceof ToolbarButton && widget.id == 'bx-publishButton') {
panel.toolbar.layout.removeWidget(widget);
break;
}
}
} catch(e) {
// @ts-ignore JupyterLab 3 support
const iter = panel.toolbar.layout.iter();
let widget: Widget;
while ((widget = iter.next())) {
if (widget instanceof ToolbarButton && widget.id == 'bx-publishButton') {
panel.toolbar.layout.removeWidget(widget);
break;
}
}
}
Comment on lines +59 to 69
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the reason for this patch that direct iteration over toolbar layouts not supported in JupyterLab 3?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, iterators have changed slightly from lumino v1 to lumino v2.

}
Expand Down
Loading