Add Notebook <-> SQL convert (#11590)

* Add Notebook <-> SQL convert

* Update STS
This commit is contained in:
Charles Gagnon
2020-08-03 14:50:24 -07:00
committed by GitHub
parent fbbb9ce529
commit 694f34a4cd
17 changed files with 248 additions and 7 deletions

View File

@@ -553,7 +553,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
// This is similar behavior that exists in MenuItemActionItem
if (action instanceof MenuItemAction) {
if (action.item.id.includes('jupyter.cmd') && this.previewFeaturesEnabled) {
if ((action.item.id.includes('jupyter.cmd') && this.previewFeaturesEnabled) || action.item.id.includes('mssql')) {
action.tooltip = action.label;
action.label = '';
}

View File

@@ -36,7 +36,7 @@ import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/q
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { getCurrentGlobalConnection } from 'sql/workbench/browser/taskUtilities';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { OEAction } from 'sql/workbench/services/objectExplorer/browser/objectExplorerActions';
import { TreeViewItemHandleArg } from 'sql/workbench/common/views';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
@@ -813,3 +813,27 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
}
}
/**
* Action class that sends the request to convert the contents of the sql editor
* into a Notebook document
*/
export class ExportAsNotebookAction extends QueryTaskbarAction {
public static IconClass = 'export';
public static ID = 'exportAsNotebookAction';
constructor(
editor: QueryEditor,
@IConnectionManagementService connectionManagementService: IConnectionManagementService,
@ICommandService private _commandService: ICommandService
) {
super(connectionManagementService, editor, ConnectDatabaseAction.ID, ExportAsNotebookAction.IconClass);
this.label = nls.localize('queryEditor.exportSqlAsNotebook', "Export as Notebook");
}
public async run(): Promise<void> {
this._commandService.executeCommand('mssql.exportSqlAsNotebook', this.editor.input.uri);
}
}

View File

@@ -86,6 +86,7 @@ export class QueryEditor extends BaseEditor {
private _actualQueryPlanAction: actions.ActualQueryPlanAction;
private _listDatabasesActionItem: actions.ListDatabasesActionItem;
private _toggleSqlcmdMode: actions.ToggleSqlCmdModeAction;
private _exportAsNotebookAction: actions.ExportAsNotebookAction;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@@ -183,6 +184,7 @@ export class QueryEditor extends BaseEditor {
this._estimatedQueryPlanAction = this.instantiationService.createInstance(actions.EstimatedQueryPlanAction, this);
this._actualQueryPlanAction = this.instantiationService.createInstance(actions.ActualQueryPlanAction, this);
this._toggleSqlcmdMode = this.instantiationService.createInstance(actions.ToggleSqlCmdModeAction, this, false);
this._exportAsNotebookAction = this.instantiationService.createInstance(actions.ExportAsNotebookAction, this);
this.setTaskbarContent();
@@ -266,13 +268,14 @@ export class QueryEditor extends BaseEditor {
{ action: this._listDatabasesAction },
{ element: separator },
{ action: this._estimatedQueryPlanAction },
{ action: this._toggleSqlcmdMode }
{ action: this._toggleSqlcmdMode },
{ action: this._exportAsNotebookAction }
];
// Remove the estimated query plan action if preview features are not enabled
let previewFeaturesEnabled = this.configurationService.getValue('workbench')['enablePreviewFeatures'];
if (!previewFeaturesEnabled) {
content = content.slice(0, -2);
content.splice(7, 1);
}
this.taskbar.setContent(content);