Skip to content

Commit

Permalink
Merge pull request #6678 from ivanov/move-contextual-help
Browse files Browse the repository at this point in the history
move contextual help to the help menu
  • Loading branch information
ian-r-rose committed Jun 21, 2019
2 parents 2618a9a + e9dbacc commit f4829a7
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 20 deletions.
1 change: 1 addition & 0 deletions packages/help-extension/package.json
Expand Up @@ -39,6 +39,7 @@
"@jupyterlab/application": "^1.0.0-alpha.13",
"@jupyterlab/apputils": "^1.0.0-alpha.13",
"@jupyterlab/coreutils": "^3.0.0-alpha.13",
"@jupyterlab/inspector": "^1.0.0-alpha.13",
"@jupyterlab/mainmenu": "^1.0.0-alpha.13",
"@jupyterlab/services": "^4.0.0-alpha.13",
"@phosphor/widgets": "^1.8.0",
Expand Down
14 changes: 12 additions & 2 deletions packages/help-extension/src/index.tsx
Expand Up @@ -18,6 +18,8 @@ import {

import { PageConfig, URLExt } from '@jupyterlab/coreutils';

import { IInspector } from '@jupyterlab/inspector';

import { IMainMenu } from '@jupyterlab/mainmenu';

import { KernelMessage } from '@jupyterlab/services';
Expand Down Expand Up @@ -89,7 +91,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
activate,
id: '@jupyterlab/help-extension:plugin',
requires: [IMainMenu],
optional: [ICommandPalette, ILayoutRestorer],
optional: [ICommandPalette, ILayoutRestorer, IInspector],
autoStart: true
};

Expand All @@ -109,7 +111,8 @@ function activate(
app: JupyterFrontEnd,
mainMenu: IMainMenu,
palette: ICommandPalette | null,
restorer: ILayoutRestorer | null
restorer: ILayoutRestorer | null,
inspector: IInspector | null
): void {
let counter = 0;
const category = 'Help';
Expand Down Expand Up @@ -157,6 +160,13 @@ function activate(
command => ({ command })
);
helpMenu.addGroup(labGroup, 0);

// Contextual help in its own group
const contextualHelpGroup = [inspector ? 'inspector:open' : null].map(
command => ({ command })
);
helpMenu.addGroup(contextualHelpGroup, 0);

const resourcesGroup = RESOURCES.map(args => ({
args,
command: CommandIDs.open
Expand Down
1 change: 1 addition & 0 deletions packages/help-extension/style/index.css
Expand Up @@ -6,6 +6,7 @@
/* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
@import url('~@phosphor/widgets/style/index.css');
@import url('~@jupyterlab/apputils/style/index.css');
@import url('~@jupyterlab/inspector/style/index.css');
@import url('~@jupyterlab/mainmenu/style/index.css');

@import url('./base.css');
3 changes: 3 additions & 0 deletions packages/help-extension/tsconfig.json
Expand Up @@ -15,6 +15,9 @@
{
"path": "../coreutils"
},
{
"path": "../inspector"
},
{
"path": "../mainmenu"
},
Expand Down
9 changes: 4 additions & 5 deletions packages/inspector-extension/src/index.ts
Expand Up @@ -50,8 +50,7 @@ const inspector: JupyterFrontEndPlugin<IInspector> = {
): IInspector => {
const { commands, shell } = app;
const command = CommandIDs.open;
const label = 'Open Contextual Help';
const title = 'Contextual Help';
const label = 'Contextual Help';
const namespace = 'inspector';
const tracker = new WidgetTracker<MainAreaWidget<InspectorPanel>>({
namespace
Expand All @@ -63,7 +62,7 @@ const inspector: JupyterFrontEndPlugin<IInspector> = {
if (!inspector || inspector.isDisposed) {
inspector = new MainAreaWidget({ content: new InspectorPanel() });
inspector.id = 'jp-inspector';
inspector.title.label = title;
inspector.title.label = label;
void tracker.add(inspector);
source = source && !source.isDisposed ? source : null;
inspector.content.source = source;
Expand All @@ -83,15 +82,15 @@ const inspector: JupyterFrontEndPlugin<IInspector> = {
inspector.isDisposed ||
!inspector.isAttached ||
!inspector.isVisible,
label: args => (args.isLauncher ? title : label),
label,
iconClass: args =>
args.isLauncher ? 'jp-MaterialIcon jp-InspectorIcon' : '',
execute: () => openInspector()
});

// Add command to UI where possible.
if (palette) {
palette.addItem({ command, category: title });
palette.addItem({ command, category: label });
}
if (launcher) {
launcher.add({ command, args: { isLauncher: true } });
Expand Down
1 change: 0 additions & 1 deletion packages/mainmenu-extension/package.json
Expand Up @@ -39,7 +39,6 @@
"@jupyterlab/application": "^1.0.0-alpha.13",
"@jupyterlab/apputils": "^1.0.0-alpha.13",
"@jupyterlab/coreutils": "^3.0.0-alpha.13",
"@jupyterlab/inspector": "^1.0.0-alpha.13",
"@jupyterlab/mainmenu": "^1.0.0-alpha.13",
"@jupyterlab/services": "^4.0.0-alpha.13",
"@phosphor/algorithm": "^1.1.3",
Expand Down
13 changes: 4 additions & 9 deletions packages/mainmenu-extension/src/index.ts
Expand Up @@ -18,8 +18,6 @@ import { ICommandPalette, showDialog, Dialog } from '@jupyterlab/apputils';

import { PageConfig, URLExt } from '@jupyterlab/coreutils';

import { IInspector } from '@jupyterlab/inspector';

import {
IMainMenu,
IMenuExtender,
Expand Down Expand Up @@ -117,13 +115,12 @@ export namespace CommandIDs {
const plugin: JupyterFrontEndPlugin<IMainMenu> = {
id: '@jupyterlab/mainmenu-extension:plugin',
requires: [ICommandPalette, IRouter],
optional: [IInspector, ILabShell],
optional: [ILabShell],
provides: IMainMenu,
activate: (
app: JupyterFrontEnd,
palette: ICommandPalette,
router: IRouter,
inspector: IInspector | null,
labShell: ILabShell | null
): IMainMenu => {
const { commands } = app;
Expand All @@ -142,7 +139,7 @@ const plugin: JupyterFrontEndPlugin<IMainMenu> = {

// Create the application menus.
createEditMenu(app, menu.editMenu);
createFileMenu(app, menu.fileMenu, router, inspector);
createFileMenu(app, menu.fileMenu, router);
createKernelMenu(app, menu.kernelMenu);
createRunMenu(app, menu.runMenu);
createSettingsMenu(app, menu.settingsMenu);
Expand Down Expand Up @@ -292,8 +289,7 @@ export function createEditMenu(app: JupyterFrontEnd, menu: EditMenu): void {
export function createFileMenu(
app: JupyterFrontEnd,
menu: FileMenu,
router: IRouter,
inspector: IInspector | null
router: IRouter
): void {
const commands = menu.menu.commands;

Expand Down Expand Up @@ -413,8 +409,7 @@ export function createFileMenu(

const newViewGroup = [
{ command: 'docmanager:clone' },
{ command: CommandIDs.createConsole },
inspector ? { command: 'inspector:open' } : null
{ command: CommandIDs.createConsole }
].filter(item => !!item);

// Add the close group
Expand Down
3 changes: 0 additions & 3 deletions packages/mainmenu-extension/tsconfig.json
Expand Up @@ -15,9 +15,6 @@
{
"path": "../coreutils"
},
{
"path": "../inspector"
},
{
"path": "../mainmenu"
},
Expand Down

0 comments on commit f4829a7

Please sign in to comment.