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

The statusbar strikes back #5577

Merged
merged 13 commits into from Nov 3, 2018
5 changes: 5 additions & 0 deletions docs/scripts/graph-dependencies.js
Expand Up @@ -38,6 +38,11 @@ packages.forEach(function(packagePath) {
return;
}

// Don't include the metapackage.
if (data.name === '@jupyterlab/metapackage') {
return;
}

// Construct a URL to the package on GitHub.
var Url = url.resolve(baseUrl, 'packages/' + path.basename(packagePath));

Expand Down
411 changes: 228 additions & 183 deletions docs/source/developer/dependency-graph.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 12 additions & 8 deletions packages/codemirror-extension/src/index.ts
Expand Up @@ -83,14 +83,18 @@ export const editorSyntaxStatus: JupyterLabPlugin<void> = {
>).content.editor;
}
});
statusBar.registerStatusItem('editor-syntax-item', item, {
align: 'left',
rank: 0,
isActive: () =>
app.shell.currentWidget &&
tracker.currentWidget &&
app.shell.currentWidget === tracker.currentWidget
});
statusBar.registerStatusItem(
'@jupyterlab/codemirror-extension:editor-syntax-status',
{
item,
align: 'left',
rank: 0,
isActive: () =>
app.shell.currentWidget &&
tracker.currentWidget &&
app.shell.currentWidget === tracker.currentWidget
}
);
}
};

Expand Down
3 changes: 1 addition & 2 deletions packages/csvviewer-extension/package.json
Expand Up @@ -35,8 +35,7 @@
"@jupyterlab/csvviewer": "^0.19.1",
"@jupyterlab/docregistry": "^0.19.1",
"@jupyterlab/mainmenu": "^0.8.1",
"@phosphor/datagrid": "^0.1.6",
"@phosphor/widgets": "^1.6.0"
"@phosphor/datagrid": "^0.1.6"
},
"devDependencies": {
"rimraf": "~2.6.2",
Expand Down
34 changes: 21 additions & 13 deletions packages/docmanager-extension/src/index.ts
Expand Up @@ -179,13 +179,17 @@ export const savingStatusPlugin: JupyterLabPlugin<void> = {
() => (item.model!.widget = app.shell.currentWidget)
);

statusBar.registerStatusItem('saving-status', item, {
align: 'middle',
isActive: () => {
return true;
},
stateChanged: item.model!.stateChanged
});
statusBar.registerStatusItem(
'@jupyterlab.docmanager-extension:saving-status',
{
item,
align: 'middle',
isActive: () => {
return true;
},
activeStateChanged: item.model!.stateChanged
}
);
}
};

Expand All @@ -209,13 +213,17 @@ export const pathStatusPlugin: JupyterLabPlugin<void> = {
item.model!.widget = app.shell.currentWidget;
});

statusBar.registerStatusItem('path-status', item, {
align: 'right',
rank: 0,
isActive: () => {
return true;
statusBar.registerStatusItem(
'@jupyterlab/docmanager-extension:path-status',
{
item,
align: 'right',
rank: 0,
isActive: () => {
return true;
}
}
});
);
}
};

Expand Down
3 changes: 1 addition & 2 deletions packages/filebrowser-extension/package.json
Expand Up @@ -41,8 +41,7 @@
"@phosphor/algorithm": "^1.1.2",
"@phosphor/commands": "^1.6.1",
"@phosphor/messaging": "^1.2.2",
"@phosphor/widgets": "^1.6.0",
"react": "~16.4.2"
"@phosphor/widgets": "^1.6.0"
},
"devDependencies": {
"rimraf": "~2.6.2",
Expand Down
35 changes: 33 additions & 2 deletions packages/filebrowser-extension/src/index.ts
Expand Up @@ -22,15 +22,16 @@ import { IDocumentManager } from '@jupyterlab/docmanager';
import {
FileBrowserModel,
FileBrowser,
FileUploadStatus,
IFileBrowserFactory
} from '@jupyterlab/filebrowser';

import { fileUploadStatus } from './uploadstatus';

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

import { Contents } from '@jupyterlab/services';

import { IStatusBar } from '@jupyterlab/statusbar';

import { IIterator, map, reduce, toArray } from '@phosphor/algorithm';

import { CommandRegistry } from '@phosphor/commands';
Expand Down Expand Up @@ -125,6 +126,36 @@ const shareFile: JupyterLabPlugin<void> = {
autoStart: true
};

/**
* A plugin providing file upload status.
*/
export const fileUploadStatus: JupyterLabPlugin<void> = {
id: '@jupyterlab/filebrowser-extension:file-upload-status',
autoStart: true,
requires: [IStatusBar, IFileBrowserFactory],
activate: (
app: JupyterLab,
statusBar: IStatusBar,
browser: IFileBrowserFactory
) => {
const item = new FileUploadStatus({
tracker: browser.tracker
});

statusBar.registerStatusItem(
'@jupyterlab/filebrowser-extension:file-upload-status',
{
item,
align: 'middle',
isActive: () => {
return !!item.model && item.model.items.length > 0;
},
activeStateChanged: item.model.stateChanged
}
);
}
};

/**
* The file browser namespace token.
*/
Expand Down
4 changes: 3 additions & 1 deletion packages/filebrowser/package.json
Expand Up @@ -36,6 +36,7 @@
"@jupyterlab/docmanager": "^0.19.1",
"@jupyterlab/docregistry": "^0.19.1",
"@jupyterlab/services": "^3.2.1",
"@jupyterlab/statusbar": "^0.7.1",
"@phosphor/algorithm": "^1.1.2",
"@phosphor/commands": "^1.6.1",
"@phosphor/coreutils": "^1.3.0",
Expand All @@ -44,7 +45,8 @@
"@phosphor/dragdrop": "^1.3.0",
"@phosphor/messaging": "^1.2.2",
"@phosphor/signaling": "^1.2.2",
"@phosphor/widgets": "^1.6.0"
"@phosphor/widgets": "^1.6.0",
"react": "~16.4.2"
},
"devDependencies": {
"rimraf": "~2.6.2",
Expand Down
1 change: 1 addition & 0 deletions packages/filebrowser/src/index.ts
Expand Up @@ -9,3 +9,4 @@ export * from './factory';
export * from './listing';
export * from './model';
export * from './upload';
export * from './uploadstatus';
@@ -1,21 +1,18 @@
import React from 'react';
import { TextItem } from '@jupyterlab/statusbar';

import { JupyterLabPlugin, JupyterLab } from '@jupyterlab/application';
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
//

import {
IUploadModel,
FileBrowserModel,
IFileBrowserFactory,
FileBrowser
} from '@jupyterlab/filebrowser';
import { VDomRenderer, InstanceTracker, VDomModel } from '@jupyterlab/apputils';

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

import { ProgressBar } from '@jupyterlab/statusbar';
import { VDomRenderer, InstanceTracker, VDomModel } from '@jupyterlab/apputils';
import { GroupItem, ProgressBar, TextItem } from '@jupyterlab/statusbar';

import { ArrayExt } from '@phosphor/algorithm';
import { IStatusBar, GroupItem } from '@jupyterlab/statusbar';

import { IUploadModel, FileBrowserModel, FileBrowser } from '.';

import React from 'react';

/**
* Half-spacing between items in the overall status item.
Expand Down Expand Up @@ -49,7 +46,7 @@ namespace FileUploadComponent {
*/
export interface IProps {
/**
* The current upload fraction.
* The current upload percentage, from 0 to 100.
*/
upload: number;
}
Expand All @@ -63,16 +60,16 @@ const UPLOAD_COMPLETE_MESSAGE_MILLIS: number = 2000;
/**
* Status bar item to display file upload progress.
*/
class FileUpload extends VDomRenderer<FileUpload.Model> {
export class FileUploadStatus extends VDomRenderer<FileUploadStatus.Model> {
/**
* Construct a new FileUpload status item.
*/
constructor(opts: FileUpload.IOptions) {
constructor(opts: FileUploadStatus.IOptions) {
super();
this._tracker = opts.tracker;
this._tracker.currentChanged.connect(this._onBrowserChange);

this.model = new FileUpload.Model(
this.model = new FileUploadStatus.Model(
this._tracker.currentWidget && this._tracker.currentWidget.model
);
}
Expand Down Expand Up @@ -117,7 +114,7 @@ class FileUpload extends VDomRenderer<FileUpload.Model> {
/**
* A namespace for FileUpload class statics.
*/
namespace FileUpload {
export namespace FileUploadStatus {
/**
* The VDomModel for the FileUpload renderer.
*/
Expand Down Expand Up @@ -238,29 +235,3 @@ interface IFileUploadItem {
*/
complete: boolean;
}

/**
* A plugin providing file upload status.
*/
export const fileUploadStatus: JupyterLabPlugin<void> = {
id: '@jupyterlab/filebrowser-extension:file-upload-item',
autoStart: true,
requires: [IStatusBar, IFileBrowserFactory],
activate: (
app: JupyterLab,
statusBar: IStatusBar,
browser: IFileBrowserFactory
) => {
const item = new FileUpload({
tracker: browser.tracker
});

statusBar.registerStatusItem('file-upload-item', item, {
align: 'middle',
isActive: () => {
return !!item.model && item.model.items.length > 0;
},
stateChanged: item.model.stateChanged
});
}
};
3 changes: 3 additions & 0 deletions packages/filebrowser/tsconfig.json
Expand Up @@ -20,6 +20,9 @@
},
{
"path": "../services"
},
{
"path": "../statusbar"
}
]
}
23 changes: 14 additions & 9 deletions packages/fileeditor-extension/src/index.ts
Expand Up @@ -111,7 +111,7 @@ const plugin: JupyterLabPlugin<IEditorTracker> = {
* switch tabs vs spaces and tab widths for text editors.
*/
export const tabSpaceStatus: JupyterLabPlugin<void> = {
id: '@jupyterlab/fileeditor-extension:tab-space-item',
id: '@jupyterlab/fileeditor-extension:tab-space-status',
autoStart: true,
requires: [IStatusBar, IEditorTracker, ISettingRegistry],
activate: (
Expand Down Expand Up @@ -161,15 +161,20 @@ export const tabSpaceStatus: JupyterLabPlugin<void> = {
});

// Add the status item.
statusBar.registerStatusItem('tab-space-item', item, {
align: 'right',
rank: 1,
isActive: () => {
return (
app.shell.currentWidget && editorTracker.has(app.shell.currentWidget)
);
statusBar.registerStatusItem(
'@jupyterlab/fileeditor-extension:tab-space-status',
{
item,
align: 'right',
rank: 1,
isActive: () => {
return (
app.shell.currentWidget &&
editorTracker.has(app.shell.currentWidget)
);
}
}
});
);
}
};

Expand Down
27 changes: 16 additions & 11 deletions packages/notebook-extension/src/index.ts
Expand Up @@ -302,10 +302,11 @@ export const commandEditItem: JupyterLabPlugin<void> = {
// Keep the status item up-to-date with the current notebook.
tracker.currentChanged.connect(() => {
const current = tracker.currentWidget;
item.model.notebook = current.content;
item.model.notebook = current && current.content;
});

statusBar.registerStatusItem('command-edit-item', item, {
statusBar.registerStatusItem('@jupyterlab/notebook-extension:mode-status', {
item,
align: 'right',
rank: 4,
isActive: () =>
Expand Down Expand Up @@ -333,17 +334,21 @@ export const notebookTrustItem: JupyterLabPlugin<void> = {
// Keep the status item up-to-date with the current notebook.
tracker.currentChanged.connect(() => {
const current = tracker.currentWidget;
item.model.notebook = current.content;
item.model.notebook = current && current.content;
});

statusBar.registerStatusItem('notebook-trust-item', item, {
align: 'right',
rank: 3,
isActive: () =>
app.shell.currentWidget &&
tracker.currentWidget &&
app.shell.currentWidget === tracker.currentWidget
});
statusBar.registerStatusItem(
'@jupyterlab/notebook-extension:trust-status',
{
item,
align: 'right',
rank: 3,
isActive: () =>
app.shell.currentWidget &&
tracker.currentWidget &&
app.shell.currentWidget === tracker.currentWidget
}
);
}
};

Expand Down