Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Edit Notebook Metadata Option (#6402) #7099

Merged
merged 21 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a4077bb
Added Edit Notebook Metadata Option (#6402)
Dilip-Jain Oct 9, 2023
b2e380a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 9, 2023
c597c36
Added Edit Notebook Metadata Option (#6402)
Dilip-Jain Oct 9, 2023
0691f87
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 9, 2023
1fd2872
Merge branch 'jupyter:main' into edit-notebook-metadata
Dilip-Jain Oct 14, 2023
657313c
Prettier Code for passing Test Lint check
Dilip-Jain Oct 14, 2023
ab1fd64
Prettier Code for passing Test Lint check
Dilip-Jain Oct 14, 2023
e6600a9
Merge branch 'main' into edit-notebook-metadata
jtpio Dec 22, 2023
ac9beab
Merge branch 'main' into edit-notebook-metadata
jtpio Jan 2, 2024
d7061c2
Merge branch 'jupyter:main' into edit-notebook-metadata
Dilip-Jain Feb 4, 2024
5916885
adding the edit-notebook-metadata entry via schema
Dilip-Jain Feb 4, 2024
a5519f3
adding the edit-notebook-metadata entry via schema
Dilip-Jain Feb 4, 2024
4efdd7d
adding the edit-notebook-metadata entry via schema
Dilip-Jain Feb 4, 2024
a2b8be8
adding the edit-notebook-metadata entry via schema
Dilip-Jain Feb 4, 2024
73188df
adding the edit-notebook-metadata entry via schema
Dilip-Jain Feb 4, 2024
f9091c5
Merge branch 'main' into edit-notebook-metadata
jtpio Feb 7, 2024
dcbc9ad
fix menu item
jtpio Feb 7, 2024
7a3db32
Add to the command palette
jtpio Feb 7, 2024
405b732
Update Playwright Snapshots
github-actions[bot] Feb 7, 2024
e73e9a4
Update Playwright Snapshots
github-actions[bot] Feb 7, 2024
b699a33
fix snapshots
jtpio Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/notebook-extension/schema/menus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"title": "Jupyter Notebook Menu Entries",
"description": "Jupyter Notebook Menu Entries",
"jupyter.lab.menus": {
"main": [
{
"command": "notebook:edit-metadata",
"rank": 0
}
]
},
"properties": {},
"additionalProperties": false,
"type": "object"
}
61 changes: 61 additions & 0 deletions packages/notebook-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ 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 {
export const openEditNotebookMetadata = 'notebook:edit-metadata';
}

/**
* A plugin for the checkpoint indicator
*/
Expand Down Expand Up @@ -491,12 +498,66 @@ 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',
Dilip-Jain marked this conversation as resolved.
Show resolved Hide resolved
description:
'Add a command to open right sidebar for Editing Notebook Metadata when clicking on "Edit Notebook Metadata" under Edit menu',
autoStart: true,
optional: [ITranslator, INotebookTools],
activate: (
app: JupyterFrontEnd,
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') &&
Dilip-Jain marked this conversation as resolved.
Show resolved Hide resolved
tool.collapsed
) {
tool.toggle();
}
});
}
});
}
},
});

// Add `Edit Notebook Metadata` option to Edit menu
// menu.editMenu.addItem({ type: 'command', command: CommandIDs.openEditNotebookMetadata, rank: 40 });
},
};

/**
* Export the plugins as default.
*/
const plugins: JupyterFrontEndPlugin<any>[] = [
checkpoints,
closeTab,
editNotebookMetadata,
kernelLogo,
kernelStatus,
notebookToolsWidget,
Expand Down
Loading