Add commands to open tree and running

This commit is contained in:
Jeremy Tuloup 2020-12-08 22:24:08 +01:00
parent 0fcce28d16
commit d1e0510777

View File

@ -44,19 +44,17 @@ namespace CommandIDs {
* Toggle the Zen mode
*/
export const toggleZen = 'application:toggle-zen';
}
/**
* A plugin to dispose the Tabs menu
*/
const noTabsMenu: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab-classic/application-extension:no-tabs-menu',
requires: [IMainMenu],
autoStart: true,
activate: (app: JupyterFrontEnd, menu: IMainMenu) => {
menu.tabsMenu.dispose();
}
};
/**
* Open the tree page.
*/
export const openTree = 'application:open-tree';
/**
* Open the runnning page.
*/
export const openRunning = 'application:open-running';
}
/**
* The logo plugin.
@ -83,6 +81,60 @@ const logo: JupyterFrontEndPlugin<void> = {
}
};
/**
* A plugin to dispose the Tabs menu
*/
const noTabsMenu: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab-classic/application-extension:no-tabs-menu',
requires: [IMainMenu],
autoStart: true,
activate: (app: JupyterFrontEnd, menu: IMainMenu) => {
menu.tabsMenu.dispose();
}
};
/**
* Add commands to open the tree and running pages.
*/
const pages: JupyterFrontEndPlugin<void> = {
id: '@jupyterlab-classic/application-extension:pages',
autoStart: true,
optional: [ICommandPalette, IMainMenu],
activate: (
app: JupyterFrontEnd,
palette: ICommandPalette,
menu: IMainMenu
): void => {
const baseUrl = PageConfig.getBaseUrl();
app.commands.addCommand(CommandIDs.openTree, {
label: 'Open the File Browser',
execute: (args: any) => {
window.open(`${baseUrl}classic/tree`);
}
});
app.commands.addCommand(CommandIDs.openRunning, {
label: 'Open the Running Sessions',
execute: (args: any) => {
window.open(`${baseUrl}classic/running`);
}
});
if (palette) {
palette.addItem({ command: CommandIDs.openTree, category: 'View' });
palette.addItem({ command: CommandIDs.openRunning, category: 'View' });
}
if (menu) {
menu.viewMenu.addGroup(
[{ command: CommandIDs.openTree }, { command: CommandIDs.openRunning }],
0
);
}
}
};
/**
* The default paths for a JupyterLab Classic app.
*/
@ -275,6 +327,7 @@ const zen: JupyterFrontEndPlugin<void> = {
const plugins: JupyterFrontEndPlugin<any>[] = [
logo,
noTabsMenu,
pages,
paths,
router,
sessionDialogs,