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

add ability to toggle status bar visibility #5990

Merged
merged 3 commits into from Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/statusbar-extension/package.json
Expand Up @@ -37,8 +37,10 @@
"@jupyterlab/apputils": "^1.0.0-alpha.3",
"@jupyterlab/cells": "^1.0.0-alpha.3",
"@jupyterlab/console": "^1.0.0-alpha.3",
"@jupyterlab/coreutils": "^3.0.0-alpha.3",
"@jupyterlab/docregistry": "^1.0.0-alpha.3",
"@jupyterlab/fileeditor": "^1.0.0-alpha.3",
"@jupyterlab/mainmenu": "^1.0.0-alpha.3",
"@jupyterlab/notebook": "^1.0.0-alpha.4",
"@jupyterlab/statusbar": "^1.0.0-alpha.3",
"@phosphor/widgets": "^1.6.0"
Expand Down
6 changes: 6 additions & 0 deletions packages/statusbar-extension/schema/plugin.json
Expand Up @@ -21,6 +21,12 @@
"memory-usage-item",
"saving-status-item"
]
},
"visible": {
"type": "boolean",
"title": "Status Bar Visibility",
"description": "Whether to show status bar at launch",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's any time, so I would delete "at launch"

"default": true
}
},
"additionalProperties": false,
Expand Down
50 changes: 48 additions & 2 deletions packages/statusbar-extension/src/index.ts
Expand Up @@ -7,7 +7,7 @@ import {
JupyterFrontEndPlugin
} from '@jupyterlab/application';

import { IClientSession } from '@jupyterlab/apputils';
import { IClientSession, ICommandPalette } from '@jupyterlab/apputils';

import { Cell, CodeCell } from '@jupyterlab/cells';

Expand Down Expand Up @@ -36,6 +36,10 @@ import {
StatusBar
} from '@jupyterlab/statusbar';

import { ISettingRegistry } from '@jupyterlab/coreutils';

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

import { Title, Widget } from '@phosphor/widgets';

export const STATUSBAR_PLUGIN_ID = '@jupyterlab/statusbar-extension:plugin';
Expand All @@ -46,8 +50,15 @@ export const STATUSBAR_PLUGIN_ID = '@jupyterlab/statusbar-extension:plugin';
const statusBar: JupyterFrontEndPlugin<IStatusBar> = {
id: STATUSBAR_PLUGIN_ID,
provides: IStatusBar,
requires: [ISettingRegistry, IMainMenu, ICommandPalette],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the menu optional, and maybe even the command palette? Like in the apputils-extension/src/index.ts with the themesPaletteMenu extension? We're trying to make more things optional so plugins work in more contexts.

autoStart: true,
activate: (app: JupyterFrontEnd, labShell: ILabShell | null) => {
activate: (
app: JupyterFrontEnd,
settingRegistry: ISettingRegistry,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ever since #5845 we have been trying to make the core plugins less interdependent by making a lot of these tokens optional. Can you move ISettingRegistry, IMainMenu, and ICommandPalette to the optional list, and then check for them before using them in the activate function?

mainMenu: IMainMenu,
palette: ICommandPalette,
labShell: ILabShell | null
) => {
const statusBar = new StatusBar();
statusBar.id = 'jp-main-statusbar';
app.shell.add(statusBar, 'bottom');
Expand All @@ -59,6 +70,41 @@ const statusBar: JupyterFrontEndPlugin<IStatusBar> = {
});
}

const category: string = 'Main Area';
const command: string = 'toggle-jp-main-statusbar';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our convention for command IDs has been to use something like 'plugin:action', so can we make this 'statusbar:toggle'?


app.commands.addCommand(command, {
label: 'Show Status Bar',
execute: (args: any) => {
statusBar.setHidden(statusBar.isVisible);
settingRegistry.set(
STATUSBAR_PLUGIN_ID,
'visible',
statusBar.isVisible
);
},
isToggled: () => statusBar.isVisible
});

palette.addItem({ command, category });
mainMenu.viewMenu.addGroup([{ command }], 1);

const updateSettings = (settings: ISettingRegistry.ISettings): void => {
const visible = settings.get('visible').composite as boolean;
statusBar.setHidden(!visible);
};

Promise.all([settingRegistry.load(STATUSBAR_PLUGIN_ID), app.restored])
.then(([settings]) => {
updateSettings(settings);
settings.changed.connect(settings => {
updateSettings(settings);
});
})
.catch((reason: Error) => {
console.error(reason.message);
});

return statusBar;
},
optional: [ILabShell]
Expand Down
6 changes: 6 additions & 0 deletions packages/statusbar-extension/tsconfig.json
Expand Up @@ -18,12 +18,18 @@
{
"path": "../console"
},
{
"path": "../coreutils"
},
{
"path": "../docregistry"
},
{
"path": "../fileeditor"
},
{
"path": "../mainmenu"
},
{
"path": "../notebook"
},
Expand Down