Fix several regressions in master (#613)

* Fix service option type enum

* Fix broken Explain button and Actual plan command
This commit is contained in:
Karl Burtram
2018-02-06 15:22:03 -05:00
committed by GitHub
parent bbb0f39a94
commit b7c935c602
12 changed files with 190 additions and 51 deletions

View File

@@ -14,7 +14,7 @@ import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox';
import * as types from 'vs/base/common/types';
import data = require('data');
import { localize } from 'vs/nls';
import { ServiceOptionType, ServiceOptionTypeNames } from 'sql/workbench/api/common/sqlExtHostTypes';
import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
export interface IOptionElement {
optionWidget: any;
@@ -31,8 +31,7 @@ export function createOptionElement(option: data.ServiceOption, rowContainer: Bu
let missingErrorMessage = localize('missingRequireField', ' is required.');
let invalidInputMessage = localize('invalidInput', 'Invalid input. Numeric value expected.');
let typeName: string = option.valueType.toString();
if (typeName === ServiceOptionTypeNames.number) {
if (option.valueType === ServiceOptionType.number) {
optionWidget = new InputBox(rowContainer.getHTMLElement(), contextViewService, {
validationOptions: {
validation: (value: string) => {
@@ -48,11 +47,11 @@ export function createOptionElement(option: data.ServiceOption, rowContainer: Bu
});
optionWidget.value = optionValue;
inputElement = this.findElement(rowContainer, 'input');
} else if (typeName === ServiceOptionTypeNames.category || typeName === ServiceOptionTypeNames.boolean) {
} else if (option.valueType === ServiceOptionType.category || option.valueType === ServiceOptionType.boolean) {
optionWidget = new SelectBox(possibleInputs, optionValue.toString());
DialogHelper.appendInputSelectBox(rowContainer, optionWidget);
inputElement = this.findElement(rowContainer, 'select-box');
} else if (typeName === ServiceOptionTypeNames.string || typeName === ServiceOptionTypeNames.password) {
} else if (option.valueType === ServiceOptionType.string || option.valueType === ServiceOptionType.password) {
optionWidget = new InputBox(rowContainer.getHTMLElement(), contextViewService, {
validationOptions: {
validation: (value: string) => (!value && option.isRequired) ? ({ type: MessageType.ERROR, content: option.displayName + missingErrorMessage }) : null
@@ -70,11 +69,10 @@ export function createOptionElement(option: data.ServiceOption, rowContainer: Bu
export function getOptionValueAndCategoryValues(option: data.ServiceOption, options: { [optionName: string]: any }, possibleInputs: string[]): any {
let valueTypeName:string = option.valueType.toString();
var optionValue = option.defaultValue;
if (options[option.name]) {
// if the value type is boolean, the option value can be either boolean or string
if (valueTypeName === ServiceOptionTypeNames.boolean) {
if (option.valueType === ServiceOptionType.boolean) {
if (options[option.name] === true || options[option.name] === this.trueInputValue) {
optionValue = this.trueInputValue;
} else {
@@ -85,13 +83,13 @@ export function getOptionValueAndCategoryValues(option: data.ServiceOption, opti
}
}
if (valueTypeName === ServiceOptionTypeNames.boolean || valueTypeName === ServiceOptionTypeNames.category) {
if (option.valueType === ServiceOptionType.boolean || option.valueType === ServiceOptionType.category) {
// If the option is not required, the empty string should be add at the top of possible choices
if (!option.isRequired) {
possibleInputs.push('');
}
if (valueTypeName === ServiceOptionTypeNames.boolean) {
if (option.valueType === ServiceOptionType.boolean) {
possibleInputs.push(this.trueInputValue, this.falseInputValue);
} else {
option.categoryValues.map(c => possibleInputs.push(c.name));
@@ -111,9 +109,9 @@ export function validateInputs(optionsMap: { [optionName: string]: IOptionElemen
for (var optionName in optionsMap) {
var optionElement: IOptionElement = optionsMap[optionName];
var widget = optionElement.optionWidget;
var isInputBox = (optionElement.option.valueType.toString() === ServiceOptionTypeNames.string ||
optionElement.option.valueType.toString() === ServiceOptionTypeNames.password ||
optionElement.option.valueType.toString() === ServiceOptionTypeNames.number);
var isInputBox = (optionElement.option.valueType === ServiceOptionType.string ||
optionElement.option.valueType === ServiceOptionType.password ||
optionElement.option.valueType === ServiceOptionType.number);
if (isInputBox) {
if (!widget.validate()) {