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

Feature: add terminal to context-menu #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/application-extension/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ const mainCommands: JupyterFrontEndPlugin<void> = {
}
});

// Fixme by Bingqi_Ji
// Fixme by cius
// commands.addCommand(CommandIDs.toggleMode, {
// label: trans.__('Simple Interface'),
// isToggled: () => labShell.mode === 'single-document',
Expand Down
5 changes: 5 additions & 0 deletions packages/filebrowser-extension/schema/browser.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
"selector": ".jp-DirListing-content",
"rank": 4
},
{
"command": "filebrowser:create-main-terminal",
"selector": ".jp-DirListing-content",
"rank": 4
},
{
"type": "separator",
"selector": ".jp-DirListing-item[data-isdir]",
Expand Down
27 changes: 25 additions & 2 deletions packages/filebrowser-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
FileBrowser,
FileUploadStatus,
FilterFileBrowserModel,
IFileBrowserFactory
IFileBrowserFactory,
} from '@jupyterlab/filebrowser';
import { Launcher } from '@jupyterlab/launcher';
import { Contents } from '@jupyterlab/services';
Expand All @@ -51,11 +51,13 @@ import {
newFolderIcon,
pasteIcon,
stopIcon,
terminalIcon,
textEditorIcon
} from '@jupyterlab/ui-components';
import { find, IIterator, map, reduce, toArray } from '@lumino/algorithm';
import { CommandRegistry } from '@lumino/commands';
import { ContextMenu } from '@lumino/widgets';
import { Terminal } from "@jupyterlab/terminal";

/**
* The command IDs used by the file browser plugin.
Expand All @@ -68,6 +70,8 @@ namespace CommandIDs {
// For main browser only.
export const createLauncher = 'filebrowser:create-main-launcher';

export const createTerminal = 'filebrowser:create-main-terminal';

export const cut = 'filebrowser:cut';

export const del = 'filebrowser:delete';
Expand Down Expand Up @@ -1027,6 +1031,12 @@ function addCommands(
label: trans.__('New Text File')
});

commands.addCommand(CommandIDs.createTerminal, {
execute: () => Private.createTerminal(commands, browser),
icon: terminalIcon.bindprops({ stylesheet: 'menuItem' }),
label: trans.__('New Terminal')
});

commands.addCommand(CommandIDs.createNewMarkdownFile, {
execute: () => {
const widget = tracker.currentWidget;
Expand Down Expand Up @@ -1186,6 +1196,19 @@ namespace Private {
});
}

export function createTerminal(
commands: CommandRegistry,
browser: FileBrowser
): Promise<MainAreaWidget<Terminal>> {
const { model } = browser;

return commands
.execute('terminal:create-new', { cwd: model.path })
.then((terminal: MainAreaWidget<Terminal>) => {
return terminal;
});
}

/**
* Get browser object given file path.
*/
Expand Down Expand Up @@ -1299,7 +1322,7 @@ namespace Private {
const plugins: JupyterFrontEndPlugin<any>[] = [
factory,
browser,
// shareFile,
shareFile,
fileUploadStatus,
// downloadPlugin,
browserWidget,
Expand Down
1 change: 0 additions & 1 deletion packages/notebook-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,6 @@ function activateNotebookHandler(
''
);
}
console.log(args);
if (args['isContextMenu']) {
return trans.__('New Notebook');
}
Expand Down