Add Launch RetroLab Tree to Help menu

This commit is contained in:
Dan Lester 2021-05-27 11:41:28 +01:00
parent fd73915a59
commit 3267b77fb9
No known key found for this signature in database
GPG Key ID: 6068782E870BC3B6

View File

@ -15,6 +15,8 @@ import { DocumentRegistry } from '@jupyterlab/docregistry';
import { IMainMenu } from '@jupyterlab/mainmenu';
import { ITranslator } from '@jupyterlab/translation';
import {
INotebookModel,
INotebookTracker,
@ -35,6 +37,7 @@ namespace CommandIDs {
* Toggle Top Bar visibility
*/
export const openRetro = 'retrolab:open';
export const launchRetroTree = 'retrolab:launchtree';
}
/**
@ -124,9 +127,45 @@ const openRetro: JupyterFrontEndPlugin<void> = {
}
};
/**
* A plugin to add a command to open the RetroLab Tree.
*/
const launchRetroTree: JupyterFrontEndPlugin<void> = {
id: '@retrolab/lab-extension:launch-retrotree',
autoStart: true,
requires: [ITranslator],
optional: [IMainMenu, ICommandPalette],
activate: (
app: JupyterFrontEnd,
translator: ITranslator,
menu: IMainMenu | null,
palette: ICommandPalette | null
): void => {
const { commands } = app;
const trans = translator.load('jupyterlab');
const category = trans.__('Help');
commands.addCommand(CommandIDs.launchRetroTree, {
label: trans.__('Launch RetroLab Tree'),
execute: () => {
window.open(PageConfig.getBaseUrl() + 'retro/tree');
}
});
if (menu) {
const helpMenu = menu.helpMenu;
helpMenu.addGroup([{ command: CommandIDs.launchRetroTree }], 1);
}
if (palette) {
palette.addItem({ command: CommandIDs.launchRetroTree, category });
}
}
};
/**
* Export the plugins as default.
*/
const plugins: JupyterFrontEndPlugin<any>[] = [openRetro];
const plugins: JupyterFrontEndPlugin<any>[] = [launchRetroTree, openRetro];
export default plugins;