diff --git a/packages/application-extension/schema/menus.json b/packages/application-extension/schema/menus.json index 2ad34edc14..84fc396842 100644 --- a/packages/application-extension/schema/menus.json +++ b/packages/application-extension/schema/menus.json @@ -10,6 +10,10 @@ "command": "application:rename", "rank": 4.5 }, + { + "command": "application:duplicate", + "rank": 4.8 + }, { "command": "notebook:trust", "rank": 20 diff --git a/packages/application-extension/src/index.ts b/packages/application-extension/src/index.ts index cd0ddd62a5..514f7d8da0 100644 --- a/packages/application-extension/src/index.ts +++ b/packages/application-extension/src/index.ts @@ -83,6 +83,11 @@ const JUPYTERLAB_DOCMANAGER_PLUGIN_ID = * The command IDs used by the application plugin. */ namespace CommandIDs { + /** + * Duplicate the current document and open the new document + */ + export const duplicate = 'application:duplicate'; + /** * Handle local links */ @@ -615,6 +620,20 @@ const title: JupyterFrontEndPlugin = { return !!(currentWidget && docManager.contextForWidget(currentWidget)); }; + commands.addCommand(CommandIDs.duplicate, { + label: () => trans.__('Duplicate'), + isEnabled, + execute: async () => { + if (!isEnabled()) { + return; + } + + // Duplicate the file, and open the new file. + const result = await docManager.duplicate(current.context.path); + await commands.execute('docmanager:open', { path: result.path }); + }, + }); + commands.addCommand(CommandIDs.rename, { label: () => trans.__('Renameā€¦'), isEnabled, diff --git a/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-chromium-linux.png b/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-chromium-linux.png index 171f93690e..34fe51769f 100644 Binary files a/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-chromium-linux.png and b/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-chromium-linux.png differ diff --git a/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-firefox-linux.png b/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-firefox-linux.png index e88b5b8dc7..8bfc3cecce 100644 Binary files a/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-firefox-linux.png and b/ui-tests/test/menus.spec.ts-snapshots/opened-menu-file-firefox-linux.png differ