Skip to content

Commit

Permalink
JupyterLab 3 bug fix (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Apr 23, 2024
1 parent 274bd16 commit e6e3198
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
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;
}
}
}
}
Expand Down

0 comments on commit e6e3198

Please sign in to comment.