Added Edit Notebook Metadata Option (#6402) (#7099)

* Added Edit Notebook Metadata Option (#6402)

Edit Notebook Metadata plugin added under Edit Menu for functionality similar to classic-notebook.
Clicking on the option under the menu opens up the Notebook Tools widget in the right sidebar and expands the Additional Tools (which contains the Notebook Metadata editor) collapsible section (default: collapsed).

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added Edit Notebook Metadata Option (#6402)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Prettier Code for passing Test Lint check

* Prettier Code for passing Test Lint check

* adding the edit-notebook-metadata entry via schema

adding the menu entry via the settings defined in the schema folder dropping the dependency on IMainMenu in the plugin

* adding the edit-notebook-metadata entry via schema

adding the menu entry via the settings defined in the schema folder dropping the dependency on IMainMenu in the plugin

* adding the edit-notebook-metadata entry via schema

* adding the edit-notebook-metadata entry via schema

* adding the edit-notebook-metadata entry via schema

* fix menu item

* Add to the command palette

* Update Playwright Snapshots

* Update Playwright Snapshots

* fix snapshots

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Tuloup <jeremy.tuloup@gmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Dilip-Jain 2 years ago committed by GitHub
parent 1d0a402bcc
commit 2d717f5896
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,28 @@
{
"title": "Jupyter Notebook Menu Entries",
"description": "Jupyter Notebook Menu Entries",
"jupyter.lab.menus": {
"main": [
{
"id": "jp-mainmenu-edit",
"items": [
{
"type": "separator",
"rank": 8.5
},
{
"command": "notebook:edit-metadata",
"rank": 8.5
},
{
"type": "separator",
"rank": 8.5
}
]
}
]
},
"properties": {},
"additionalProperties": false,
"type": "object"
}

@ -10,6 +10,7 @@ import {
ISessionContext,
DOMUtils,
IToolbarWidgetRegistry,
ICommandPalette,
} from '@jupyterlab/apputils';
import { Cell, CodeCell } from '@jupyterlab/cells';
@ -63,6 +64,16 @@ const KERNEL_STATUS_FADE_OUT_CLASS = 'jp-NotebookKernelStatus-fade';
*/
const SCROLLED_OUTPUTS_CLASS = 'jp-mod-outputsScrolled';
/**
* The command IDs used by the notebook plugins.
*/
namespace CommandIDs {
/**
* A command to open right sidebar for Editing Notebook Metadata
*/
export const openEditNotebookMetadata = 'notebook:edit-metadata';
}
/**
* A plugin for the checkpoint indicator
*/
@ -491,12 +502,71 @@ const trusted: JupyterFrontEndPlugin<void> = {
},
};
/**
* Add a command to open right sidebar for Editing Notebook Metadata when clicking on "Edit Notebook Metadata" under Edit menu
*/
const editNotebookMetadata: JupyterFrontEndPlugin<void> = {
id: '@jupyter-notebook/notebook-extension:edit-notebook-metadata',
description:
'Add a command to open right sidebar for Editing Notebook Metadata when clicking on "Edit Notebook Metadata" under Edit menu',
autoStart: true,
optional: [ICommandPalette, ITranslator, INotebookTools],
activate: (
app: JupyterFrontEnd,
palette: ICommandPalette | null,
translator: ITranslator | null,
notebookTools: INotebookTools | null
) => {
const { commands } = app;
translator = translator ?? nullTranslator;
const trans = translator.load('notebook');
commands.addCommand(CommandIDs.openEditNotebookMetadata, {
label: trans.__('Edit Notebook Metadata'),
execute: async () => {
const command = 'application:toggle-panel';
const args = {
side: 'right',
title: 'Show Notebook Tools',
id: 'notebook-tools',
};
// Check if Show Notebook Tools (Right Sidebar) is open (expanded)
if (!commands.isToggled(command, args)) {
await commands.execute(command, args).then((_) => {
// For expanding the 'Advanced Tools' section (default: collapsed)
if (notebookTools) {
const tools = (notebookTools?.layout as any).widgets;
tools.forEach((tool: any) => {
if (
tool.widget.title.label === trans.__('Advanced Tools') &&
tool.collapsed
) {
tool.toggle();
}
});
}
});
}
},
});
if (palette) {
palette.addItem({
command: CommandIDs.openEditNotebookMetadata,
category: 'Notebook Operations',
});
}
},
};
/**
* Export the plugins as default.
*/
const plugins: JupyterFrontEndPlugin<any>[] = [
checkpoints,
closeTab,
editNotebookMetadata,
kernelLogo,
kernelStatus,
notebookToolsWidget,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Loading…
Cancel
Save