Notebook save functionality through button (#3340)

* 3268: Notebook save using button

* 3268: Misc change

* Handle promise while saving notebook

* Async await functions to run action
This commit is contained in:
Raj
2018-11-29 14:10:16 -08:00
committed by GitHub
parent 3ca72b7398
commit 1affc760e6
5 changed files with 40 additions and 4 deletions

View File

@@ -48,6 +48,28 @@ export class AddCellAction extends Action {
}
}
export class SaveNotebookAction extends Action {
private static readonly notebookSavedMsg = localize('notebookSavedMsg', 'Notebook saved successfully.');
private static readonly notebookFailedSaveMsg = localize('notebookFailedSaveMsg', 'Failed to save Notebook.');
constructor(
id: string, label: string, cssClass: string,
@INotificationService private _notificationService: INotificationService
) {
super(id, label, cssClass);
}
public async run(context: NotebookComponent): TPromise<boolean> {
const actions: INotificationActions = { primary: [] };
let saved = await context.save();
if (saved) {
this._notificationService.notify({ severity: Severity.Info, message: SaveNotebookAction.notebookSavedMsg, actions });
} else {
this._notificationService.error(SaveNotebookAction.notebookFailedSaveMsg);
}
return saved;
}
}
export interface IToggleableState {
baseClass?: string;
shouldToggleTooltip?: boolean;