Skip to content

Commit

Permalink
refactor: Move jupytext menu into Filemenu
Browse files Browse the repository at this point in the history
* See [discussion](#1178 (comment))

Signed-off-by: mahendrapaipuri <[email protected]>
  • Loading branch information
mahendrapaipuri authored and mwouts committed Dec 2, 2023
1 parent 87f8060 commit 91d2bf1
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions jupyterlab/packages/jupyterlab-jupytext-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,35 +138,25 @@ const extension: JupyterFrontEndPlugin<void> = {
// Unpack necessary components
const { commands, serviceManager, docRegistry } = app;

// Initialise Jupytext menu and add it to main menu
const jupytextMenu = new Menu({ commands: app.commands });
mainmenu.addMenu(jupytextMenu, true, { rank: 40 });
jupytextMenu.id = 'jp-mainmenu-jupytext-menu';
jupytextMenu.title.label = trans.__('Jupytext');

// Initialise Jupytext create notebook submenu and add it to File menu
const jupytextCreateMenu = new Menu({ commands: app.commands });
jupytextCreateMenu.id = 'jp-mainmenu-jupytext-new-menu';
jupytextCreateMenu.title.label = trans.__('New Text Notebook');
mainmenu.fileMenu.addItem({
rank: 0.98,
rank: 0.97,
type: 'submenu',
submenu: jupytextCreateMenu,
});

// Initialise Jupytext pair notebook submenu and add it to Jupytext menu
const jupytextPairMenu = new Menu({ commands: app.commands });
jupytextPairMenu.id = 'jp-mainmenu-jupytext-pair-menu';
jupytextPairMenu.title.label = trans.__('Pair Notebook');
jupytextMenu.addItem({
// Initialise Jupytext menu and add it to main menu
const jupytextMenu = new Menu({ commands: app.commands });
mainmenu.fileMenu.addItem({
rank: 0.98,
type: 'submenu',
submenu: jupytextPairMenu,
});

// Add a separator
jupytextMenu.addItem({
type: 'separator',
submenu: jupytextMenu,
});
jupytextMenu.id = 'jp-mainmenu-jupytext-menu';
jupytextMenu.title.label = trans.__('Jupytext');

// Get all Jupytext formats
let rank = 0;
Expand Down Expand Up @@ -223,7 +213,7 @@ const extension: JupyterFrontEndPlugin<void> = {
category: 'Jupytext',
});
// Add to jupytext pair menu
jupytextPairMenu.addItem({
jupytextMenu.addItem({
command: command,
});
if (fileType.separator) {
Expand All @@ -236,7 +226,7 @@ const extension: JupyterFrontEndPlugin<void> = {

// Add separators in jupytext pair menu
separatorIndex.map((index, idx) => {
jupytextPairMenu.insertItem(index + idx + 1, {
jupytextMenu.insertItem(index + idx + 1, {
type: 'separator',
});
});
Expand Down Expand Up @@ -273,6 +263,9 @@ const extension: JupyterFrontEndPlugin<void> = {
jupytextMenu.addItem({
command: CommandIDs.metadata,
});
jupytextMenu.addItem({
type: 'separator',
});

// Register Jupytext FAQ command
commands.addCommand(CommandIDs.faq, {
Expand Down

0 comments on commit 91d2bf1

Please sign in to comment.