Enable status bar for notebooks (#14817)

* enable status bar for notebooks

* add onCellExecutionStart event to notebook service

* fix test, change var name
This commit is contained in:
Lucy Zhang
2021-03-22 14:54:13 -07:00
committed by GitHub
parent 8fb54710fb
commit 780ca84f9a
5 changed files with 33 additions and 3 deletions

View File

@@ -289,6 +289,12 @@ export class NotebookServiceStub implements INotebookService {
navigateTo(notebookUri: URI, sectionId: string): void {
throw new Error('Method not implemented.');
}
get onCodeCellExecutionStart(): vsEvent.Event<void> {
throw new Error('Method not implemented.');
}
notifyCellExecutionStarted(): void {
throw new Error('Method not implemented.');
}
}
export class ClientSessionStub implements IClientSession {

View File

@@ -5,6 +5,7 @@
import { parseNumAsTimeString } from 'sql/platform/connection/common/utils';
import { QueryEditorInput } from 'sql/workbench/common/editor/query/queryEditorInput';
import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService';
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
import QueryRunner from 'sql/workbench/services/query/common/queryRunner';
import { IntervalTimer } from 'vs/base/common/async';
@@ -259,8 +260,9 @@ export class QueryResultSelectionSummaryStatusBarContribution extends Disposable
constructor(
@IStatusbarService private readonly statusbarService: IStatusbarService,
@IEditorService private editorService: IEditorService,
@IQueryModelService queryModelService: IQueryModelService
@IEditorService editorService: IEditorService,
@IQueryModelService queryModelService: IQueryModelService,
@INotebookService notebookService: INotebookService
) {
super();
this.statusItem = this._register(
@@ -274,6 +276,7 @@ export class QueryResultSelectionSummaryStatusBarContribution extends Disposable
);
this._register(editorService.onDidActiveEditorChange(() => { this.hide(); }, this));
this._register(queryModelService.onRunQueryStart(() => { this.hide(); }));
this._register(notebookService.onCodeCellExecutionStart(() => { this.hide(); }));
this._register(queryModelService.onCellSelectionChanged((data: string[]) => {
this.onCellSelectionChanged(data);
}));
@@ -289,7 +292,7 @@ export class QueryResultSelectionSummaryStatusBarContribution extends Disposable
private onCellSelectionChanged(data: string[]): void {
const numericValues = data?.filter(value => !Number.isNaN(Number(value))).map(value => Number(value));
if (numericValues?.length < 2 || !(this.editorService.activeEditor instanceof QueryEditorInput)) {
if (numericValues?.length < 2) {
this.hide();
return;
}

View File

@@ -531,6 +531,7 @@ export class CellModel extends Disposable implements ICellModel {
}, false);
this.setFuture(future as FutureInternal);
this.fireExecutionStateChanged();
this._notebookService?.notifyCellExecutionStarted();
// For now, await future completion. Later we should just track and handle cancellation based on model notifications
let result: nb.IExecuteReplyMsg = <nb.IExecuteReplyMsg><any>await future.done;
if (result && result.content) {
@@ -551,6 +552,7 @@ export class CellModel extends Disposable implements ICellModel {
let commandExecuted = this._commandService?.executeCommand(result.commandId, result.args);
// This will ensure that the run button turns into a stop button
this.fireExecutionStateChanged();
this._notebookService?.notifyCellExecutionStarted();
await commandExecuted;
// For save files, if we output a message after saving the file, the file becomes dirty again.
// Special casing this to avoid this particular issue.

View File

@@ -129,6 +129,16 @@ export interface INotebookService {
* @param isTrusted True if notebook is to be set to trusted, false otherwise.
*/
setTrusted(notebookUri: URI, isTrusted: boolean): Promise<boolean>;
/**
* Event that gets fired when a cell is executed.
*/
onCodeCellExecutionStart: Event<void>;
/**
* Fires the onCodeCellExecutionStart event.
*/
notifyCellExecutionStarted(): void;
}
export interface INotebookProvider {

View File

@@ -108,6 +108,7 @@ export class NotebookService extends Disposable implements INotebookService {
private _isRegistrationComplete = false;
private _trustedCacheQueue: URI[] = [];
private _unTrustedCacheQueue: URI[] = [];
private _onCodeCellExecutionStart: Emitter<void> = new Emitter<void>();
constructor(
@ILifecycleService lifecycleService: ILifecycleService,
@@ -639,4 +640,12 @@ export class NotebookService extends Disposable implements INotebookService {
return isTrusted;
}
get onCodeCellExecutionStart(): Event<void> {
return this._onCodeCellExecutionStart.event;
}
notifyCellExecutionStarted(): void {
this._onCodeCellExecutionStart.fire();
}
}