Skip to content

Commit

Permalink
Move notebook-related status items to the notebook-extension package.
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-r-rose committed Oct 18, 2018
1 parent 7e18f46 commit ce5940f
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 42 deletions.
7 changes: 6 additions & 1 deletion packages/notebook-extension/package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/**
* Default item to display which notebook mode user is in.
*/
/**
* Part of Jupyterlab status bar defaults.
*/
import * as React from 'react';

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

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

import {
INotebookTracker,
Notebook,
Expand All @@ -17,11 +13,9 @@ import {

import { IStatusBar, TextItem, TextExt } from '@jupyterlab/statusbar';

import { VDomRenderer, VDomModel } from '@jupyterlab/apputils';
import { ISignal } from '@phosphor/signaling';

import { IDisposable } from '@phosphor/disposable';
import { Token } from '@phosphor/coreutils';
import { IStatusContext } from '../contexts';

// tslint:disable-next-line:variable-name
const CommandEditComponent = (
Expand All @@ -36,6 +30,9 @@ namespace CommandEditComponent {
}
}

/**
* StatusBar item to display which notebook mode user is in.
*/
class CommandEdit extends VDomRenderer<CommandEdit.Model>
implements ICommandEdit {
constructor(opts: CommandEdit.IOptions) {
Expand Down Expand Up @@ -158,15 +155,9 @@ export namespace ICommandEdit {
}
}

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

export const commandEditItem: JupyterLabPlugin<ICommandEdit> = {
export const commandEditItem: JupyterLabPlugin<void> = {
id: '@jupyterlab/statusbar:command-edit-item',
autoStart: true,
provides: ICommandEdit,
requires: [IStatusBar, INotebookTracker],
activate: (
app: JupyterLab,
Expand All @@ -180,9 +171,10 @@ export const commandEditItem: JupyterLabPlugin<ICommandEdit> = {
statusBar.registerStatusItem('command-edit-item', item, {
align: 'right',
rank: 4,
isActive: IStatusContext.delegateActive(app.shell, [{ tracker }])
isActive: () =>
app.shell.currentWidget &&
tracker.currentWidget &&
app.shell.currentWidget === tracker.currentWidget
});

return item;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@
import React from 'react';

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

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

import {
INotebookTracker,
NotebookPanel,
INotebookModel,
Notebook
} from '@jupyterlab/notebook';
import { toArray } from '@phosphor/algorithm';

import { Cell } from '@jupyterlab/cells';
import { VDomRenderer, VDomModel } from '@jupyterlab/apputils';

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

import { toArray } from '@phosphor/algorithm';

import { IDisposable } from '@phosphor/disposable';

import { ISignal } from '@phosphor/signaling';
import { Token } from '@phosphor/coreutils';
import { IconItem, IStatusBar } from '@jupyterlab/statusbar';
import { IStatusContext } from '../contexts';

export const cellStatus = (
prop: NotebookTrustComponent.IProps | NotebookTrust.Model
Expand Down Expand Up @@ -266,15 +271,9 @@ export namespace INotebookTrust {
}
}

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

export const notebookTrustItem: JupyterLabPlugin<INotebookTrust> = {
export const notebookTrustItem: JupyterLabPlugin<void> = {
id: '@jupyterlab/statusbar:trusted-notebook-item',
autoStart: true,
provides: INotebookTrust,
requires: [IStatusBar, INotebookTracker],
activate: (
app: JupyterLab,
Expand All @@ -286,9 +285,10 @@ export const notebookTrustItem: JupyterLabPlugin<INotebookTrust> = {
statusBar.registerStatusItem('notebook-trust-item', item, {
align: 'right',
rank: 3,
isActive: IStatusContext.delegateActive(app.shell, [{ tracker }])
isActive: () =>
app.shell.currentWidget &&
tracker.currentWidget &&
app.shell.currentWidget === tracker.currentWidget
});

return item;
}
};
3 changes: 3 additions & 0 deletions packages/notebook-extension/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
},
{
"path": "../services"
},
{
"path": "../statusbar"
}
]
}
2 changes: 0 additions & 2 deletions packages/statusbar-extension/src/defaults/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export * from './notebookTrust';
export * from './lineCol';
export * from './fileUpload';
export * from './kernelStatus';
export * from './commandEdit';
export * from './runningSessions';
export * from './filePath';
export * from './tabSpace';
Expand Down
4 changes: 0 additions & 4 deletions packages/statusbar-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import { IStatusBar, StatusBar } from '@jupyterlab/statusbar';
// Export default status bar items

import {
notebookTrustItem,
lineColItem,
fileUploadItem,
kernelStatusItem,
commandEditItem,
runningSessionsItem,
filePathItem,
tabSpaceItem,
Expand All @@ -38,10 +36,8 @@ const statusBar: JupyterLabPlugin<IStatusBar> = {
const plugins: JupyterLabPlugin<any>[] = [
statusBar,
lineColItem,
notebookTrustItem,
fileUploadItem,
kernelStatusItem,
commandEditItem,
runningSessionsItem,
filePathItem,
tabSpaceItem,
Expand Down

0 comments on commit ce5940f

Please sign in to comment.