Files
azuredatastudio/extensions/kusto/src/prompts/input.ts
Shafiq Ur Rahman 2f94307635 Kusto extension for ADS (#11752)
* Kusto extension

* Add kusto to extensions.ts

* Remove objectExplorerNodeProvider

* Removed some BDC items + CR cleanup

* Cleanup unused strings in package.nls.json

* Remove unused svgs, and some cleanup

* Bringing objectExplorerNode back and hygiene changes

* rename to KustoObjectExplorerNodeProvider

* rename to KustoIconProvider

* Cleanup SQL code

* Fix compilation error

* Clean up in objectExplorerNodeProvider folder

* Some more clean up based on comments

* apiWrapper add

* changed to camelCase

* Remove unused functions/files

* Removed AgentServicesFeature

* dacfx, cms, schemacompare clean up

* Clean up and addressed few comments

* Remove apWrapper from kusto extension

* Addressed few comments

* credentialstore and escapeexception changes

* Added strict check for Kusto extension

* Fix error and addressed comment

* Saving Kusto files shoulf default to .kql

* package.json changes

* Fix objectExplorerNodeProvider

* Amir/kusto fix (#11972)

* Add the compiled extensions.js

* Fix strict compile rules

Co-authored-by: Monica Gupta <mogupt@microsoft.com>
Co-authored-by: Amir Omidi <amomidi@microsoft.com>
2020-08-26 14:13:31 -07:00

60 lines
1.6 KiB
TypeScript

'use strict';
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
import { window, InputBoxOptions } from 'vscode';
import Prompt from './prompt';
import EscapeException from './escapeException';
const figures = require('figures');
export default class InputPrompt extends Prompt {
protected _options: InputBoxOptions;
constructor(question: any, ignoreFocusOut?: boolean) {
super(question, ignoreFocusOut);
this._options = this.defaultInputBoxOptions;
this._options.prompt = this._question.message;
}
// Helper for callers to know the right type to get from the type factory
public static get promptType(): string { return 'input'; }
public render(): any {
// Prefer default over the placeHolder, if specified
let placeHolder = this._question.default ? this._question.default : this._question.placeHolder;
if (this._question.default instanceof Error) {
placeHolder = this._question.default.message;
this._question.default = undefined;
}
this._options.placeHolder = placeHolder;
return window.showInputBox(this._options)
.then(result => {
if (result === undefined) {
throw new EscapeException();
}
if (result === '') {
// Use the default value, if defined
result = this._question.default || '';
}
const validationError = this._question.validate ? this._question.validate(result || '') : undefined;
if (validationError) {
this._question.default = new Error(`${figures.warning} ${validationError}`);
return this.render();
}
return result;
});
}
}