Skip to content

Commit

Permalink
Add a sourceChanged signal and use it to notify of command changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Oct 17, 2019
1 parent 2afb2ae commit 177f20f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/logconsole-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@jupyterlab/notebook": "^2.0.0-alpha.1",
"@jupyterlab/rendermime": "^2.0.0-alpha.1",
"@jupyterlab/statusbar": "^2.0.0-alpha.1",
"@phosphor/messaging": "^1.3.0",
"@phosphor/signaling": "^1.3.0",
"@phosphor/widgets": "^1.9.0",
"react": "~16.8.4"
Expand Down
8 changes: 6 additions & 2 deletions packages/logconsole-extension/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,13 @@ function activateLogConsole(
return true;
});

logConsolePanel.sourceChanged.connect(() => {
app.commands.notifyCommandChanged();
});

logConsoleWidget.disposed.connect(() => {
logConsoleWidget = null;
app.commands.notifyCommandChanged();
status.model.flashEnabled = flashEnabled;
});

Expand All @@ -499,6 +504,7 @@ function activateLogConsole(
});

logConsoleWidget.update();
app.commands.notifyCommandChanged();
};

app.commands.addCommand(CommandIDs.open, {
Expand All @@ -516,8 +522,6 @@ function activateLogConsole(
}
});

// TODO: call app.commands.notifyCommandChanged() when enabled status
// changes
app.commands.addCommand(CommandIDs.addTimestamp, {
label: 'Add Timestamp',
execute: () => {
Expand Down
13 changes: 11 additions & 2 deletions packages/logconsole/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,21 @@ export class LogConsolePanel extends StackedPanel {
/**
* The log source displayed
*/
get source(): string {
get source(): string | null {
return this._source;
}
set source(name: string) {
set source(name: string | null) {
this._source = name;
this._showOutputFromSource(this._source);
this._handlePlaceholder();
this._sourceChanged.emit(name);
}

/**
* Signal for source changes
*/
get sourceChanged(): ISignal<this, string | null> {
return this._sourceChanged;
}

private _handlePlaceholder() {
Expand Down Expand Up @@ -554,6 +562,7 @@ export class LogConsolePanel extends StackedPanel {
private _loggerRegistry: ILoggerRegistry;
private _outputAreas = new Map<string, LogConsoleOutputArea>();
private _source: string | null = null;
private _sourceChanged = new Signal<this, string | null>(this);
private _entryLimit: number = DEFAULT_LOG_ENTRY_LIMIT;
private _scrollTimer: number = null;
private _placeholder: Widget;
Expand Down

0 comments on commit 177f20f

Please sign in to comment.