From 4b587b7cda5bd5f19ea85cf337c3058509a29323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Collonval?= Date: Mon, 15 May 2023 10:36:41 +0200 Subject: [PATCH] Fix injecting user menu bar in top bar. (#149) * Fix injecting user menu bar in top bar. * Automatic application of license header --------- Co-authored-by: github-actions[bot] --- .../collaboration-extension/src/collaboration.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/collaboration-extension/src/collaboration.ts b/packages/collaboration-extension/src/collaboration.ts index be92a37c..70935bf0 100644 --- a/packages/collaboration-extension/src/collaboration.ts +++ b/packages/collaboration-extension/src/collaboration.ts @@ -9,7 +9,7 @@ import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; -import { DOMUtils } from '@jupyterlab/apputils'; +import { DOMUtils, IToolbarWidgetRegistry } from '@jupyterlab/apputils'; import { EditorExtensionRegistry, IEditorExtensionRegistry @@ -54,12 +54,15 @@ export const userMenuPlugin: JupyterFrontEndPlugin = { * Jupyter plugin adding the IUserMenu to the menu bar if collaborative flag enabled. */ export const menuBarPlugin: JupyterFrontEndPlugin = { - 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 => { - const { shell } = app; + requires: [IUserMenu, IToolbarWidgetRegistry], + activate: async ( + app: JupyterFrontEnd, + menu: IUserMenu, + toolbarRegistry: IToolbarWidgetRegistry + ): Promise => { const { user } = app.serviceManager; const menuBar = new MenuBar({ @@ -72,7 +75,8 @@ export const menuBarPlugin: JupyterFrontEndPlugin = { 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); } };