mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-09 03:50:45 +08:00
Add Launch RetroLab Tree to Help menu
This commit is contained in:
parent
fd73915a59
commit
3267b77fb9
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user