mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Remove ApiWrapper from notebook extension (#11224)
* Remove ApiWrapper in notebook extension * delete file * Remove copyrights
This commit is contained in:
@@ -4,14 +4,14 @@
|
||||
import PromptFactory from './factory';
|
||||
import EscapeException from './escapeException';
|
||||
import { IQuestion, IPrompter } from './question';
|
||||
import { ApiWrapper } from '../common/apiWrapper';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
// Supports simple pattern for prompting for user input and acting on this
|
||||
export default class CodeAdapter implements IPrompter {
|
||||
|
||||
public promptSingle<T>(question: IQuestion, apiWrapper?: ApiWrapper): Promise<T> {
|
||||
public promptSingle<T>(question: IQuestion): Promise<T> {
|
||||
let questions: IQuestion[] = [question];
|
||||
return this.prompt(questions, apiWrapper).then((answers: { [key: string]: T }) => {
|
||||
return this.prompt(questions).then((answers: { [key: string]: T }) => {
|
||||
if (answers) {
|
||||
let response: T = answers[question.name];
|
||||
return response || undefined;
|
||||
@@ -20,7 +20,7 @@ export default class CodeAdapter implements IPrompter {
|
||||
});
|
||||
}
|
||||
|
||||
public prompt<T>(questions: IQuestion[], apiWrapper = new ApiWrapper()): Promise<{ [key: string]: T }> {
|
||||
public prompt<T>(questions: IQuestion[]): Promise<{ [key: string]: T }> {
|
||||
let answers: { [key: string]: T } = {};
|
||||
|
||||
// Collapse multiple questions into a set of prompt steps
|
||||
@@ -36,7 +36,7 @@ export default class CodeAdapter implements IPrompter {
|
||||
// }
|
||||
|
||||
if (!question.shouldPrompt || question.shouldPrompt(answers) === true) {
|
||||
return prompt.render(apiWrapper).then((result: any) => {
|
||||
return prompt.render().then((result: any) => {
|
||||
answers[question.name] = result;
|
||||
|
||||
if (question.onAnswered) {
|
||||
@@ -54,7 +54,7 @@ export default class CodeAdapter implements IPrompter {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
apiWrapper.showErrorMessage(err.message);
|
||||
vscode.window.showErrorMessage(err.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
||||
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
||||
|
||||
import Prompt from './prompt';
|
||||
import LocalizedConstants = require('../common/localizedConstants');
|
||||
import EscapeException from './escapeException';
|
||||
import { ApiWrapper } from '../common/apiWrapper';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export default class ConfirmPrompt extends Prompt {
|
||||
|
||||
@@ -14,7 +12,7 @@ export default class ConfirmPrompt extends Prompt {
|
||||
super(question);
|
||||
}
|
||||
|
||||
public render(apiWrapper: ApiWrapper): any {
|
||||
public render(): any {
|
||||
let choices: { [id: string]: boolean } = {};
|
||||
choices[LocalizedConstants.msgYes] = true;
|
||||
choices[LocalizedConstants.msgNo] = false;
|
||||
@@ -22,7 +20,7 @@ export default class ConfirmPrompt extends Prompt {
|
||||
let options = this.defaultQuickPickOptions;
|
||||
options.placeHolder = this._question.message;
|
||||
|
||||
return apiWrapper.showQuickPick(Object.keys(choices), options)
|
||||
return vscode.window.showQuickPick(Object.keys(choices), options)
|
||||
.then(result => {
|
||||
if (result === undefined) {
|
||||
throw new EscapeException();
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
'use strict';
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export default require('error-ex')('EscapeException');
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
||||
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
||||
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
||||
|
||||
import { InputBoxOptions, QuickPickOptions } from 'vscode';
|
||||
import { ApiWrapper } from '../common/apiWrapper';
|
||||
|
||||
abstract class Prompt {
|
||||
|
||||
@@ -16,7 +13,7 @@ abstract class Prompt {
|
||||
this._ignoreFocusOut = ignoreFocusOut ? ignoreFocusOut : false;
|
||||
}
|
||||
|
||||
public abstract render(apiWrapper: ApiWrapper): any;
|
||||
public abstract render(): any;
|
||||
|
||||
protected get defaultQuickPickOptions(): QuickPickOptions {
|
||||
return {
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import vscode = require('vscode');
|
||||
import { ApiWrapper } from '../common/apiWrapper';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export const confirm = 'confirm';
|
||||
|
||||
@@ -48,14 +47,14 @@ export interface IQuestionHandler {
|
||||
}
|
||||
|
||||
export interface IPrompter {
|
||||
promptSingle<T>(question: IQuestion, apiWrapper?: ApiWrapper): Promise<T>;
|
||||
promptSingle<T>(question: IQuestion): Promise<T>;
|
||||
/**
|
||||
* Prompts for multiple questions
|
||||
*
|
||||
* @returns Map of question IDs to results, or undefined if
|
||||
* the user canceled the question session
|
||||
*/
|
||||
prompt<T>(questions: IQuestion[], apiWrapper?: ApiWrapper): Promise<{ [questionId: string]: any }>;
|
||||
prompt<T>(questions: IQuestion[]): Promise<{ [questionId: string]: any }>;
|
||||
}
|
||||
|
||||
export interface IPromptCallback {
|
||||
|
||||
Reference in New Issue
Block a user