mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 09:35:39 -05:00
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:
1
src/sql/parts/notebook/media/dark/save_inverse.svg
Normal file
1
src/sql/parts/notebook/media/dark/save_inverse.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><style>.cls-1{fill:#fff;}</style></defs><title>save_inverse</title><path class="cls-1" d="M14,1a1,1,0,0,1,.39.08,1,1,0,0,1,.53.53A1,1,0,0,1,15,2V15H2.79L1,13.2V2a1,1,0,0,1,.08-.39,1,1,0,0,1,.53-.53A1,1,0,0,1,2,1Zm0,1H13V8H3V2H2V12.79L3.2,14H4V10h7v4h3ZM4,7h8V2H4Zm6,4H5v3H6V12H7v2h3Z"/></svg>
|
||||
|
After Width: | Height: | Size: 391 B |
1
src/sql/parts/notebook/media/light/save.svg
Normal file
1
src/sql/parts/notebook/media/light/save.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><title>save</title><path d="M14,1a1,1,0,0,1,.39.08,1,1,0,0,1,.53.53A1,1,0,0,1,15,2V15H2.79L1,13.2V2a1,1,0,0,1,.08-.39,1,1,0,0,1,.53-.53A1,1,0,0,1,2,1Zm0,1H13V8H3V2H2V12.79L3.2,14H4V10h7v4h3ZM4,7h8V2H4Zm6,4H5v3H6V12H7v2h3Z"/></svg>
|
||||
|
After Width: | Height: | Size: 323 B |
@@ -31,7 +31,7 @@ import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { KernelsDropdown, AttachToDropdown, AddCellAction, TrustedAction } from 'sql/parts/notebook/notebookActions';
|
||||
import { KernelsDropdown, AttachToDropdown, AddCellAction, TrustedAction, SaveNotebookAction } from 'sql/parts/notebook/notebookActions';
|
||||
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
|
||||
|
||||
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
|
||||
@@ -252,15 +252,18 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
|
||||
this._trustedAction = this.instantiationService.createInstance(TrustedAction, 'notebook.Trusted');
|
||||
this._trustedAction.enabled = false;
|
||||
|
||||
let saveNotebookButton = this.instantiationService.createInstance(SaveNotebookAction, 'notebook.SaveNotebook', localize('save', 'Save'), 'notebook-button icon-save');
|
||||
|
||||
let taskbar = <HTMLElement>this.toolbar.nativeElement;
|
||||
this._actionBar = new Taskbar(taskbar, this.contextMenuService);
|
||||
this._actionBar.context = this;
|
||||
this._actionBar.setContent([
|
||||
{ element: kernelContainer },
|
||||
{ element: attachToContainer },
|
||||
{ action: addCodeCellButton},
|
||||
{ action: addTextCellButton},
|
||||
{ action: this._trustedAction}
|
||||
{ action: addCodeCellButton },
|
||||
{ action: addTextCellButton },
|
||||
{ action: saveNotebookButton },
|
||||
{ action: this._trustedAction }
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,4 +61,13 @@
|
||||
.vs-dark .notebookEditor .notebook-button.icon-notTrusted,
|
||||
.hc-black .notebookEditor .notebook-button.icon-notTrusted{
|
||||
background-image: url("./media/dark/nottrusted_inverse.svg");
|
||||
}
|
||||
|
||||
.notebookEditor .notebook-button.icon-save{
|
||||
background-image: url("./media/light/save.svg");
|
||||
}
|
||||
|
||||
.vs-dark .notebookEditor .notebook-button.icon-save,
|
||||
.hc-black .notebookEditor .notebook-button.icon-save{
|
||||
background-image: url("./media/dark/save_inverse.svg");
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user