Skip to content

Commit

Permalink
Merge pull request #5514 from ian-r-rose/refactor-statusbar
Browse files Browse the repository at this point in the history
[WIP] Refactor statusbar
  • Loading branch information
blink1073 committed Oct 20, 2018
2 parents d766470 + 3ec2fe3 commit 334136f
Show file tree
Hide file tree
Showing 52 changed files with 570 additions and 690 deletions.
2 changes: 2 additions & 0 deletions dev_mode/package.json
Expand Up @@ -66,6 +66,7 @@
"@jupyterlab/settingeditor": "^0.8.1",
"@jupyterlab/settingeditor-extension": "^0.14.1",
"@jupyterlab/shortcuts-extension": "^0.19.3",
"@jupyterlab/statusbar": "^0.7.1",
"@jupyterlab/statusbar-extension": "^0.5.0",
"@jupyterlab/tabmanager-extension": "^0.19.1",
"@jupyterlab/terminal": "^0.19.1",
Expand Down Expand Up @@ -279,6 +280,7 @@
"@jupyterlab/settingeditor": "../packages/settingeditor",
"@jupyterlab/settingeditor-extension": "../packages/settingeditor-extension",
"@jupyterlab/shortcuts-extension": "../packages/shortcuts-extension",
"@jupyterlab/statusbar": "../packages/statusbar",
"@jupyterlab/statusbar-extension": "../packages/statusbar-extension",
"@jupyterlab/tabmanager-extension": "../packages/tabmanager-extension",
"@jupyterlab/terminal": "../packages/terminal",
Expand Down
8 changes: 7 additions & 1 deletion packages/codemirror-extension/package.json
Expand Up @@ -32,14 +32,20 @@
},
"dependencies": {
"@jupyterlab/application": "^0.19.1",
"@jupyterlab/apputils": "^0.19.1",
"@jupyterlab/codeeditor": "^0.19.1",
"@jupyterlab/codemirror": "^0.19.1",
"@jupyterlab/coreutils": "^2.2.1",
"@jupyterlab/docregistry": "^0.19.1",
"@jupyterlab/fileeditor": "^0.19.1",
"@jupyterlab/mainmenu": "^0.8.1",
"@jupyterlab/statusbar": "^0.7.1",
"@phosphor/commands": "^1.6.1",
"@phosphor/coreutils": "^1.3.0",
"@phosphor/signaling": "^1.2.2",
"@phosphor/widgets": "^1.6.0",
"codemirror": "~5.39.0"
"codemirror": "~5.39.0",
"react": "~16.4.2"
},
"devDependencies": {
"rimraf": "~2.6.2",
Expand Down
8 changes: 7 additions & 1 deletion packages/codemirror-extension/src/index.ts
Expand Up @@ -19,6 +19,8 @@ import { IDocumentWidget } from '@jupyterlab/docregistry';

import { IEditorTracker, FileEditor } from '@jupyterlab/fileeditor';

import { editorSyntaxStatus } from './syntaxstatus';

/**
* The command IDs used by the codemirror plugin.
*/
Expand Down Expand Up @@ -58,7 +60,11 @@ const commands: JupyterLabPlugin<void> = {
/**
* Export the plugins as default.
*/
const plugins: JupyterLabPlugin<any>[] = [commands, services];
const plugins: JupyterLabPlugin<any>[] = [
commands,
services,
editorSyntaxStatus
];
export default plugins;

/**
Expand Down
@@ -1,28 +1,34 @@
/**
* Default item to change the language syntax highlighting of the file editor.
*/
/**
* Part of Jupyterlab status bar defaults.
*/
import React from 'react';

import { TextItem } from '../component';
import { ISignal } from '@phosphor/signaling';
import { Token } from '@phosphor/coreutils';
import { JupyterLabPlugin, JupyterLab } from '@jupyterlab/application';
import { IDefaultsManager } from './manager';
import { IEditorTracker, FileEditor } from '@jupyterlab/fileeditor';
import { IStatusContext } from '../contexts';

import { VDomRenderer, VDomModel } from '@jupyterlab/apputils';
import { IDocumentWidget, DocumentRegistry } from '@jupyterlab/docregistry';

import { CodeEditor } from '@jupyterlab/codeeditor';
import { Mode } from '@jupyterlab/codemirror';

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

import { IDocumentWidget, DocumentRegistry } from '@jupyterlab/docregistry';

import { IEditorTracker, FileEditor } from '@jupyterlab/fileeditor';

import {
IStatusBar,
interactiveItem,
Popup,
showPopup,
TextItem
} from '@jupyterlab/statusbar';

import { Mode } from '@jupyterlab/codemirror';

import { CommandRegistry } from '@phosphor/commands';

import { JSONObject } from '@phosphor/coreutils';

import { ISignal } from '@phosphor/signaling';

import { Menu } from '@phosphor/widgets';
import { showPopup, Popup } from '../component/hover';
import { interactiveItem } from '../style/statusBar';

namespace EditorSyntaxComponent {
export interface IProps {
Expand All @@ -38,6 +44,9 @@ const EditorSyntaxComponent = (
return <TextItem source={props.mode} onClick={props.handleClick} />;
};

/**
* StatusBar item to change the language syntax highlighting of the file editor.
*/
class EditorSyntax extends VDomRenderer<EditorSyntax.Model>
implements IEditorSyntax {
constructor(opts: EditorSyntax.IOptions) {
Expand Down Expand Up @@ -199,28 +208,23 @@ export namespace IEditorSyntax {
}
}

// tslint:disable-next-line:variable-name
export const IEditorSyntax = new Token<IEditorSyntax>(
'@jupyterlab/statusbar:IEditorSyntax'
);

export const editorSyntax: JupyterLabPlugin<IEditorSyntax> = {
id: '@jupyterlab/statusbar:editor-syntax-item',
export const editorSyntaxStatus: JupyterLabPlugin<void> = {
id: '@jupyterlab/codemirror-extension:editor-syntax-status',
autoStart: true,
provides: IEditorSyntax,
requires: [IDefaultsManager, IEditorTracker],
requires: [IStatusBar, IEditorTracker],
activate: (
app: JupyterLab,
manager: IDefaultsManager,
statusBar: IStatusBar,
tracker: IEditorTracker
) => {
let item = new EditorSyntax({ tracker, commands: app.commands });
manager.addDefaultStatus('editor-syntax-item', item, {
statusBar.registerStatusItem('editor-syntax-item', item, {
align: 'left',
priority: 0,
isActive: IStatusContext.delegateActive(app.shell, [{ tracker }])
rank: 0,
isActive: () =>
app.shell.currentWidget &&
tracker.currentWidget &&
app.shell.currentWidget === tracker.currentWidget
});

return item;
}
};
6 changes: 6 additions & 0 deletions packages/codemirror-extension/tsconfig.json
Expand Up @@ -9,6 +9,9 @@
{
"path": "../application"
},
{
"path": "../apputils"
},
{
"path": "../codeeditor"
},
Expand All @@ -26,6 +29,9 @@
},
{
"path": "../mainmenu"
},
{
"path": "../statusbar"
}
]
}
6 changes: 5 additions & 1 deletion packages/filebrowser-extension/package.json
Expand Up @@ -37,10 +37,14 @@
"@jupyterlab/filebrowser": "^0.19.3",
"@jupyterlab/launcher": "^0.19.1",
"@jupyterlab/services": "^3.2.1",
"@jupyterlab/statusbar": "^0.7.1",
"@phosphor/algorithm": "^1.1.2",
"@phosphor/commands": "^1.6.1",
"@phosphor/disposable": "^1.1.2",
"@phosphor/messaging": "^1.2.2",
"@phosphor/widgets": "^1.6.0"
"@phosphor/signaling": "^1.2.2",
"@phosphor/widgets": "^1.6.0",
"react": "~16.4.2"
},
"devDependencies": {
"rimraf": "~2.6.2",
Expand Down
9 changes: 8 additions & 1 deletion packages/filebrowser-extension/src/index.ts
Expand Up @@ -25,6 +25,8 @@ import {
IFileBrowserFactory
} from '@jupyterlab/filebrowser';

import { fileUploadStatus } from './uploadstatus';

import { Launcher } from '@jupyterlab/launcher';

import { Contents } from '@jupyterlab/services';
Expand Down Expand Up @@ -131,7 +133,12 @@ const namespace = 'filebrowser';
/**
* Export the plugins as default.
*/
const plugins: JupyterLabPlugin<any>[] = [factory, browser, shareFile];
const plugins: JupyterLabPlugin<any>[] = [
factory,
browser,
shareFile,
fileUploadStatus
];
export default plugins;

/**
Expand Down
@@ -1,11 +1,5 @@
/**
* Default item to display file upload progress.
*/
/**
* Part of Jupyterlab status bar defaults.
*/
import React from 'react';
import { TextItem } from '../component/text';
import { TextItem } from '@jupyterlab/statusbar';

import { JupyterLabPlugin, JupyterLab } from '@jupyterlab/application';

Expand All @@ -19,21 +13,20 @@ import {
import { IChangedArgs } from '@jupyterlab/coreutils';
import { ISignal } from '@phosphor/signaling';
import { IDisposable } from '@phosphor/disposable';
import { Token } from '@phosphor/coreutils';

import { ProgressBar } from '../component/progressBar';
import { ProgressBar } from '@jupyterlab/statusbar';
import { VDomRenderer, InstanceTracker, VDomModel } from '@jupyterlab/apputils';
import { ArrayExt } from '@phosphor/algorithm';
import { IDefaultsManager } from './manager';
import { GroupItem } from '../component/group';
import vars from '../style/variables';
import { IStatusBar, GroupItem } from '@jupyterlab/statusbar';

const HALF_SPACING = 4;

// tslint:disable-next-line:variable-name
const FileUploadComponent = (
props: FileUploadComponent.IProps
): React.ReactElement<FileUploadComponent.IProps> => {
return (
<GroupItem spacing={vars.textIconHalfSpacing}>
<GroupItem spacing={HALF_SPACING}>
<TextItem source={'Uploading'} />
<ProgressBar percentage={props.upload} />
</GroupItem>
Expand All @@ -48,6 +41,9 @@ namespace FileUploadComponent {

const UPLOAD_COMPLETE_MESSAGE_MILLIS: number = 2000;

/**
* Status bar item to display file upload progress.
*/
class FileUpload extends VDomRenderer<FileUpload.Model> implements IFileUpload {
constructor(opts: FileUpload.IOptions) {
super();
Expand Down Expand Up @@ -181,11 +177,6 @@ export interface IFileUpload extends IDisposable {
readonly modelChanged: ISignal<this, void>;
}

// tslint:disable-next-line:variable-name
export const IFileUpload = new Token<IFileUpload>(
'@jupyterlab/statusbar:IFileUpload'
);

export namespace IFileUpload {
export interface IModel {
readonly items: Array<IFileUpload.IItem>;
Expand All @@ -199,28 +190,25 @@ export namespace IFileUpload {
}
}

export const fileUploadItem: JupyterLabPlugin<IFileUpload> = {
id: '@jupyterlab/statusbar:file-upload-item',
export const fileUploadStatus: JupyterLabPlugin<void> = {
id: '@jupyterlab/filebrowser-extension:file-upload-item',
autoStart: true,
provides: IFileUpload,
requires: [IDefaultsManager, IFileBrowserFactory],
requires: [IStatusBar, IFileBrowserFactory],
activate: (
app: JupyterLab,
manager: IDefaultsManager,
statusBar: IStatusBar,
browser: IFileBrowserFactory
) => {
const item = new FileUpload({
tracker: browser.tracker
});

manager.addDefaultStatus('file-upload-item', item, {
statusBar.registerStatusItem('file-upload-item', item, {
align: 'middle',
isActive: () => {
return !!item.model && item.model.items.length > 0;
},
stateChanged: item.model!.stateChanged
});

return item;
}
};
3 changes: 3 additions & 0 deletions packages/filebrowser-extension/tsconfig.json
Expand Up @@ -26,6 +26,9 @@
},
{
"path": "../services"
},
{
"path": "../statusbar"
}
]
}
1 change: 1 addition & 0 deletions packages/metapackage/package.json
Expand Up @@ -84,6 +84,7 @@
"@jupyterlab/settingeditor": "^0.8.1",
"@jupyterlab/settingeditor-extension": "^0.14.1",
"@jupyterlab/shortcuts-extension": "^0.19.3",
"@jupyterlab/statusbar": "^0.7.1",
"@jupyterlab/statusbar-extension": "^0.5.0",
"@jupyterlab/tabmanager-extension": "^0.19.1",
"@jupyterlab/terminal": "^0.19.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/metapackage/tsconfig.json
Expand Up @@ -168,6 +168,9 @@
{
"path": "../shortcuts-extension"
},
{
"path": "../statusbar"
},
{
"path": "../statusbar-extension"
},
Expand Down
7 changes: 6 additions & 1 deletion packages/notebook-extension/package.json
Expand Up @@ -42,9 +42,14 @@
"@jupyterlab/notebook": "^0.19.2",
"@jupyterlab/rendermime": "^0.19.1",
"@jupyterlab/services": "^3.2.1",
"@jupyterlab/statusbar": "^0.7.1",
"@phosphor/algorithm": "^1.1.2",
"@phosphor/coreutils": "^1.3.0",
"@phosphor/disposable": "^1.1.2",
"@phosphor/messaging": "^1.2.2",
"@phosphor/widgets": "^1.6.0"
"@phosphor/signaling": "^1.2.2",
"@phosphor/widgets": "^1.6.0",
"react": "~16.4.2"
},
"devDependencies": {
"rimraf": "~2.6.2",
Expand Down
12 changes: 11 additions & 1 deletion packages/notebook-extension/src/index.ts
Expand Up @@ -63,6 +63,10 @@ import { Message, MessageLoop } from '@phosphor/messaging';

import { Menu } from '@phosphor/widgets';

import { commandEditItem } from './modestatus';

import { notebookTrustItem } from './truststatus';

/**
* The command IDs used by the notebook plugin.
*/
Expand Down Expand Up @@ -284,7 +288,13 @@ const tools: JupyterLabPlugin<ICellTools> = {
/**
* Export the plugins as default.
*/
const plugins: JupyterLabPlugin<any>[] = [factory, trackerPlugin, tools];
const plugins: JupyterLabPlugin<any>[] = [
factory,
trackerPlugin,
tools,
commandEditItem,
notebookTrustItem
];
export default plugins;

/**
Expand Down

0 comments on commit 334136f

Please sign in to comment.