mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -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 { Taskbar } from 'sql/base/browser/ui/taskbar/taskbar';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
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';
|
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
|
||||||
|
|
||||||
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
|
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
|
||||||
@@ -252,6 +252,8 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
|
|||||||
this._trustedAction = this.instantiationService.createInstance(TrustedAction, 'notebook.Trusted');
|
this._trustedAction = this.instantiationService.createInstance(TrustedAction, 'notebook.Trusted');
|
||||||
this._trustedAction.enabled = false;
|
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;
|
let taskbar = <HTMLElement>this.toolbar.nativeElement;
|
||||||
this._actionBar = new Taskbar(taskbar, this.contextMenuService);
|
this._actionBar = new Taskbar(taskbar, this.contextMenuService);
|
||||||
this._actionBar.context = this;
|
this._actionBar.context = this;
|
||||||
@@ -260,6 +262,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit {
|
|||||||
{ element: attachToContainer },
|
{ element: attachToContainer },
|
||||||
{ action: addCodeCellButton },
|
{ action: addCodeCellButton },
|
||||||
{ action: addTextCellButton },
|
{ action: addTextCellButton },
|
||||||
|
{ action: saveNotebookButton },
|
||||||
{ action: this._trustedAction }
|
{ action: this._trustedAction }
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,3 +62,12 @@
|
|||||||
.hc-black .notebookEditor .notebook-button.icon-notTrusted{
|
.hc-black .notebookEditor .notebook-button.icon-notTrusted{
|
||||||
background-image: url("./media/dark/nottrusted_inverse.svg");
|
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 {
|
export interface IToggleableState {
|
||||||
baseClass?: string;
|
baseClass?: string;
|
||||||
shouldToggleTooltip?: boolean;
|
shouldToggleTooltip?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user