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
Changes from all 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
28 changes: 28 additions & 0 deletions packages/notebook-extension/schema/edit-notebook-metadata.json
Original file line number Diff line number Diff line change
@@ -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"
}
70 changes: 70 additions & 0 deletions packages/notebook-extension/src/index.ts
Original file line number Diff line number Diff line change
@@ -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',
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: [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') &&
Dilip-Jain marked this conversation as resolved.
Show resolved Hide resolved
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,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading