Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

WIP Adds left and right widgets area #275

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
796bce7
Adds left and right widgets
JasonWeill Nov 2, 2021
7888e4e
WIP: Changes to add widgets to left and right areas
JasonWeill Nov 2, 2021
2ac2cc1
Adds element to contain left, main, and right panels; adds yarn error…
JasonWeill Nov 3, 2021
179a1fb
WIP: Reinstates layout to good appearance
JasonWeill Nov 3, 2021
cb16a75
Adds main element which should be relatively positioned
JasonWeill Nov 3, 2021
8aa196c
Re-enables left and right panels
JasonWeill Nov 3, 2021
63f9452
Adds dummy widget to left panel, adds menu item to show/hide left panel
JasonWeill Nov 4, 2021
931a93c
Adds functioning left panel with dummy widget
JasonWeill Nov 5, 2021
5bb84d0
Adds functioning left panel with dummy widget
JasonWeill Nov 5, 2021
f466b80
Merge branch 'jupyterlab:main' into left-right-widgets
JasonWeill Nov 5, 2021
91aed44
Merge branch 'left-right-widgets' of github.com:jweill-aws/retrolab i…
JasonWeill Nov 5, 2021
f1ac7a2
Adds isEmpty function, enables menu items based on it
JasonWeill Nov 5, 2021
510351b
Adds new tests for isEmpty, removes dummy widget from ctor
JasonWeill Nov 5, 2021
89c4c95
Adds toc-extension to package.json
JasonWeill Nov 8, 2021
b238723
Incorporates toc and toc-extension
JasonWeill Nov 8, 2021
ddcad1c
Merge branch 'main' of https://github.com/jupyterlab/retrolab into le…
JasonWeill Nov 8, 2021
fefec09
Package versions revised
JasonWeill Nov 9, 2021
bb59da0
Updates dependencies
JasonWeill Nov 9, 2021
65a515d
Reverts widgets version to 1.23.0 in application
JasonWeill Nov 9, 2021
b842b5b
Downgrades widget versions from 1.30.0 to 1.23.0
JasonWeill Nov 9, 2021
87386dc
Downgrade widgets version in application-extension
JasonWeill Nov 9, 2021
a9a0a26
Downgrades coreutils
JasonWeill Nov 9, 2021
c4e4424
Adds polyfill for webpack usage, other changes to facilitate building
JasonWeill Nov 10, 2021
9fe6886
Reverts some unnecessary upgrades
JasonWeill Nov 10, 2021
828e49d
Updates dependencies per @jtpio
JasonWeill Nov 11, 2021
2910774
Merge branch 'jupyterlab:main' into left-right-widgets-nocopy
JasonWeill Nov 11, 2021
9e356c1
Merge branch 'left-right-widgets-nocopy' of github.com:jweill-aws/ret…
JasonWeill Nov 11, 2021
50c9402
Removes 'util' from webpack config, as it appears no longer needed
JasonWeill Nov 11, 2021
e637ade
Updates webpack config to remove util dependency
JasonWeill Nov 11, 2021
9dc5eff
Update app/package.json per @jtpio
JasonWeill Nov 11, 2021
08dff68
Only shows the Show Left/Right Sidebar menu options on the 'notebooks…
JasonWeill Nov 11, 2021
756f34f
Reinstates old layout for pages without side panels
JasonWeill Nov 11, 2021
d0f47f9
Minor refactoring
JasonWeill Nov 11, 2021
6822ff9
Fixes tests
JasonWeill Nov 12, 2021
4fa5da0
Updates tests to test logic about left/right panels being unavailable
JasonWeill Nov 12, 2021
104cbb4
Merge changes from main
JasonWeill Nov 15, 2021
bf8656a
Merge branch 'jupyterlab-main' into left-right-widgets-nocopy
JasonWeill Nov 15, 2021
11f4107
Merge pull request #2 from jupyterlab/main
JasonWeill Nov 16, 2021
6ea1ea7
Updates dependencies
JasonWeill Nov 17, 2021
13cfee1
WIP: Adds cascading menu for widgets (not updated when widget added)
JasonWeill Nov 19, 2021
0e414ac
Refactors, adds right sidebar code
JasonWeill Nov 19, 2021
cf68741
Merge branch 'jupyterlab:main' into left-right-widgets-nocopy
JasonWeill Nov 29, 2021
1301213
Merge branch 'left-right-widgets-nocopy' of github.com:jweill-aws/ret…
JasonWeill Nov 29, 2021
05e4d3d
Merge branch 'jupyterlab:main' into left-right-widgets-nocopy
JasonWeill Dec 3, 2021
2dc667d
Waits for app.restored before populating list; fixes logic error in i…
JasonWeill Dec 10, 2021
86a6d44
Merge branch 'main' of https://github.com/jupyterlab/retrolab into ju…
JasonWeill Dec 22, 2021
aa6e9ce
Merge branch 'jupyterlab-main-2' into left-right-widgets-nocopy
JasonWeill Dec 22, 2021
83fd06d
Merge branch 'main' of https://github.com/jupyterlab/retrolab into ju…
JasonWeill Feb 2, 2022
b1a9c21
Remove toc-extension
JasonWeill Feb 2, 2022
ec60338
Merge branch 'jupyterlab-main' into left-right-widgets-nocopy
JasonWeill Feb 2, 2022
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ node_modules/
.ipynb_checkpoints
*.tsbuildinfo

*/yarn-error.log

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python

Expand Down
144 changes: 143 additions & 1 deletion packages/application-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { PromiseDelegate } from '@lumino/coreutils';

import { DisposableDelegate, DisposableSet } from '@lumino/disposable';

import { Widget } from '@lumino/widgets';
import { Menu, Widget } from '@lumino/widgets';

/**
* The default notebook factory.
Expand Down Expand Up @@ -70,6 +70,11 @@ namespace CommandIDs {
*/
export const toggleTop = 'application:toggle-top';

/**
* Toggle sidebar visibility
*/
export const togglePanel = 'application:toggle-panel';

/**
* Toggle the Zen mode
*/
Expand All @@ -96,6 +101,13 @@ namespace CommandIDs {
export const resolveTree = 'application:resolve-tree';
}

/**
* Are the left and right panels available on the current page?
*/
const sidePanelsEnabled: () => boolean = () => {
return PageConfig.getOption('retroPage') === 'notebooks';
};

/**
* Check if the application is dirty before closing the browser tab.
*/
Expand Down Expand Up @@ -581,6 +593,135 @@ const topVisibility: JupyterFrontEndPlugin<void> = {
autoStart: true
};

/**
* Plugin to toggle the left or right sidebar's visibility.
*/
const sidebarVisibility: JupyterFrontEndPlugin<void> = {
id: '@retrolab/application-extension:sidebar',
requires: [IRetroShell, ITranslator],
optional: [IMainMenu, ISettingRegistry],
activate: (
app: JupyterFrontEnd<JupyterFrontEnd.IShell>,
retroShell: IRetroShell,
translator: ITranslator,
menu: IMainMenu | null,
settingRegistry: ISettingRegistry | null
) => {
if (!sidePanelsEnabled()) {
return;
}

const trans = translator.load('retrolab');

/* Arguments for togglePanel command:
* side, left or right area
* title, widget title to show in the menu
* id, widget ID to activate in the sidebar
*/
app.commands.addCommand(CommandIDs.togglePanel, {
label: args => args['title'] as string,
caption: args => {
// We do not substitute the parameter into the string because the parameter is not
// localized (e.g., it is always 'left') even though the string is localized.
if (args['side'] === 'left') {
return trans.__(
'Show %1 in the left sidebar',
args['title'] as string
);
} else if (args['side'] === 'right') {
return trans.__(
'Show %1 in the right sidebar',
args['title'] as string
);
}
return trans.__('Show %1 in the sidebar', args['title'] as string);
},
execute: args => {
switch (args['side'] as string) {
case 'left':
if (retroShell.leftCollapsed) {
retroShell.activateById(args['id'] as string);
retroShell.expandLeft();
} else {
retroShell.collapseLeft();
if (retroShell.currentWidget) {
retroShell.activateById(retroShell.currentWidget.id);
}
}
break;
case 'right':
if (retroShell.rightCollapsed) {
retroShell.activateById(args['id'] as string);
retroShell.expandRight();
} else {
retroShell.collapseRight();
if (retroShell.currentWidget) {
retroShell.activateById(retroShell.currentWidget.id);
}
}
break;
}
},
isToggled: args => {
if (retroShell.leftCollapsed) {
return false;
}
const currentWidget = retroShell.leftHandler.current;
if (!currentWidget) {
return false;
}

return currentWidget.id === (args['id'] as string);
}
});

const leftSidebarMenu = new Menu({ commands: app.commands });
leftSidebarMenu.title.label = trans.__('Show Left Sidebar');

const rightSidebarMenu = new Menu({ commands: app.commands });
rightSidebarMenu.title.label = trans.__('Show Right Sidebar');

app.restored.then(() => {
const leftWidgets = retroShell.widgetsList('left');
leftWidgets.forEach(widget => {
leftSidebarMenu.addItem({
command: CommandIDs.togglePanel,
args: {
side: 'left',
title: widget.title.caption,
id: widget.id
}
});
});

const rightWidgets = retroShell.widgetsList('right');
rightWidgets.forEach(widget => {
rightSidebarMenu.addItem({
command: CommandIDs.togglePanel,
args: {
side: 'right',
title: widget.title.caption,
id: widget.id
}
});
});

const menuItemsToAdd: Menu.IItemOptions[] = [];
if (leftWidgets.length > 0) {
menuItemsToAdd.push({ type: 'submenu', submenu: leftSidebarMenu });
}
if (rightWidgets.length > 0) {
menuItemsToAdd.push({ type: 'submenu', submenu: rightSidebarMenu });
}

if (menu && menuItemsToAdd) {
menu.viewMenu.addGroup(menuItemsToAdd, 2);
}
});
},
autoStart: true
};

/**
* The default tree route resolver plugin.
*/
Expand Down Expand Up @@ -740,6 +881,7 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
router,
sessionDialogs,
shell,
sidebarVisibility,
spacer,
status,
tabTitle,
Expand Down
Loading