Alanren/sql on windows (#6785)

* download file

* add entry

* fix issues

* add 2019

* string updates

* make dialog self contained

* expose notebook input dialog

* refactoring

* add log and correct the url

* comments
This commit is contained in:
Alan Ren
2019-08-20 14:45:27 -07:00
committed by GitHub
parent c540e81108
commit 7bd8a6f2b1
10 changed files with 206 additions and 65 deletions

View File

@@ -11,7 +11,7 @@ export abstract class DialogBase {
protected _toDispose: vscode.Disposable[] = [];
protected _dialogObject: azdata.window.Dialog;
constructor(protected extensionContext: vscode.ExtensionContext, dialogTitle: string, dialogName: string, isWide: boolean = false) {
constructor(dialogTitle: string, dialogName: string, isWide: boolean = false) {
this._dialogObject = azdata.window.createModelViewDialog(dialogTitle, dialogName, isWide);
this._dialogObject.cancelButton.onClick(() => this.onCancel());
}

View File

@@ -6,29 +6,27 @@
import * as azdata from 'azdata';
import * as nls from 'vscode-nls';
import * as vscode from 'vscode';
import { DialogBase } from './dialogBase';
import { INotebookService } from '../services/notebookService';
import { DeploymentProvider, DialogFieldInfo, FieldType } from '../interfaces';
import { DialogFieldInfo, FieldType, DialogInfo } from '../interfaces';
const localize = nls.loadMessageBundle();
export class DeploymentDialog extends DialogBase {
export class NotebookInputDialog extends DialogBase {
private variables: { [s: string]: string | undefined; } = {};
private validators: (() => { valid: boolean, message: string })[] = [];
constructor(context: vscode.ExtensionContext,
private notebookService: INotebookService,
private deploymentProvider: DeploymentProvider) {
super(context, deploymentProvider.dialog.title, deploymentProvider.dialog.name, false);
constructor(private notebookService: INotebookService,
private dialogInfo: DialogInfo) {
super(dialogInfo.title, dialogInfo.name, false);
this._dialogObject.okButton.label = localize('deploymentDialog.OKButtonText', 'Open Notebook');
this._dialogObject.okButton.onClick(() => this.onComplete());
}
protected initializeDialog() {
const tabs: azdata.window.DialogTab[] = [];
this.deploymentProvider.dialog.tabs.forEach(tabInfo => {
this.dialogInfo.tabs.forEach(tabInfo => {
const tab = azdata.window.createTab(tabInfo.title);
tab.registerContent((view: azdata.ModelView) => {
const sections: azdata.FormComponentGroup[] = [];
@@ -191,7 +189,7 @@ export class DeploymentDialog extends DialogBase {
Object.keys(this.variables).forEach(key => {
process.env[key] = this.variables[key];
});
this.notebookService.launchNotebook(this.deploymentProvider.notebook);
this.notebookService.launchNotebook(this.dialogInfo.notebook);
this.dispose();
}

View File

@@ -5,14 +5,12 @@
'use strict';
import * as azdata from 'azdata';
import * as nls from 'vscode-nls';
import { IResourceTypeService } from '../services/resourceTypeService';
import * as vscode from 'vscode';
import { ResourceType, DeploymentProvider } from '../interfaces';
import { IToolsService } from '../services/toolsService';
import { INotebookService } from '../services/notebookService';
import * as nls from 'vscode-nls';
import { DialogBase } from './dialogBase';
import { DeploymentDialog } from './deploymentDialog';
import { ResourceType, DeploymentProvider } from '../interfaces';
import { IResourceTypeService } from '../services/resourceTypeService';
import { IToolsService } from '../services/toolsService';
const localize = nls.loadMessageBundle();
@@ -26,12 +24,11 @@ export class ResourceTypePickerDialog extends DialogBase {
private _cardResourceTypeMap: Map<string, azdata.CardComponent> = new Map();
private _optionDropDownMap: Map<string, azdata.DropDownComponent> = new Map();
constructor(context: vscode.ExtensionContext,
private notebookService: INotebookService,
constructor(private extensionContext: vscode.ExtensionContext,
private toolsService: IToolsService,
private resourceTypeService: IResourceTypeService,
resourceType: ResourceType) {
super(context, localize('resourceTypePickerDialog.title', "Select the deployment options"), 'ResourceTypePickerDialog', true);
super(localize('resourceTypePickerDialog.title', "Select the deployment options"), 'ResourceTypePickerDialog', true);
this._selectedResourceType = resourceType;
this._dialogObject.okButton.label = localize('deploymentDialog.OKButtonText', 'Select');
this._dialogObject.okButton.onClick(() => this.onComplete());
@@ -156,11 +153,15 @@ export class ResourceTypePickerDialog extends DialogBase {
private updateTools(): void {
const tools = this.getCurrentProvider().requiredTools;
const headerRowHeight = 28;
this._toolsTable.height = 25 * tools.length + headerRowHeight;
this._toolsTable.data = tools.map(toolRef => {
const tool = this.toolsService.getToolByName(toolRef.name)!;
return [tool.displayName, tool.description];
});
this._toolsTable.height = 25 * Math.max(tools.length, 1) + headerRowHeight;
if (tools.length === 0) {
this._toolsTable.data = [[localize('deploymentDialog.NoRequiredTool', "No tools required"), '']];
} else {
this._toolsTable.data = tools.map(toolRef => {
const tool = this.toolsService.getToolByName(toolRef.name)!;
return [tool.displayName, tool.description];
});
}
}
private getCurrentProvider(): DeploymentProvider {
@@ -175,13 +176,7 @@ export class ResourceTypePickerDialog extends DialogBase {
}
private onComplete(): void {
const provider = this.getCurrentProvider();
if (provider.dialog) {
const dialog = new DeploymentDialog(this.extensionContext, this.notebookService, provider);
dialog.open();
} else {
this.notebookService.launchNotebook(provider.notebook);
}
this.resourceTypeService.startDeployment(this.getCurrentProvider());
this.dispose();
}
}