Skip to content

Commit

Permalink
Fix injecting user menu bar in top bar. (#149)
Browse files Browse the repository at this point in the history
* Fix injecting user menu bar in top bar.

* Automatic application of license header

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
fcollonval and github-actions[bot] authored May 15, 2023
1 parent d1d1140 commit 4b587b7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/collaboration-extension/src/collaboration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { DOMUtils } from '@jupyterlab/apputils';
import { DOMUtils, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
import {
EditorExtensionRegistry,
IEditorExtensionRegistry
Expand Down Expand Up @@ -54,12 +54,15 @@ export const userMenuPlugin: JupyterFrontEndPlugin<IUserMenu> = {
* Jupyter plugin adding the IUserMenu to the menu bar if collaborative flag enabled.
*/
export const menuBarPlugin: JupyterFrontEndPlugin<void> = {
id: '@jupyter/collaboration-extension:userMenuBar',
id: '@jupyter/collaboration-extension:user-menu-bar',
description: 'Add user menu to the interface.',
autoStart: true,
requires: [IUserMenu],
activate: async (app: JupyterFrontEnd, menu: IUserMenu): Promise<void> => {
const { shell } = app;
requires: [IUserMenu, IToolbarWidgetRegistry],
activate: async (
app: JupyterFrontEnd,
menu: IUserMenu,
toolbarRegistry: IToolbarWidgetRegistry
): Promise<void> => {
const { user } = app.serviceManager;

const menuBar = new MenuBar({
Expand All @@ -72,7 +75,8 @@ export const menuBarPlugin: JupyterFrontEndPlugin<void> = {
menuBar.id = 'jp-UserMenu';
user.userChanged.connect(() => menuBar.update());
menuBar.addMenu(menu as Menu);
shell.add(menuBar, 'top', { rank: 1000 });

toolbarRegistry.addFactory('TopBar', 'user-menu', () => menuBar);
}
};

Expand Down

0 comments on commit 4b587b7

Please sign in to comment.