mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 02:02:35 -05:00
* Added Azure Log Analytics resource for generating AAD Token. * Fixed AzureResource * Removed debug code from connectionManagementService * Moved AzureLogAnalytics from AzureResource enum in azdata.d.ts to azdata.proposed.d.ts. Added azureLogAnalyticsResource to all azureSettings in providerSettings.ts * Updated endpoint for generating AAD Token for LogAnalytics for UsGov, UsNat, and China * Initial Commit of Azure Monitor Extension * Added extension name to azuremonitor package strings * Removed azureMonitor resource from germanyCloud in providerSettings * Added logic to exclude menuItems in object explorer for LogAnalytics * Changed exe from AzureMonitor to Kusto * Added if clause for queryName for new queries * Changed queryWindow name from KustoQuery to KQLQuery for Kusto and LogAnalytics. * Added LogAnalytics for setTaskBarContent * Added serialization and telemetry feature classes to AzureMonitor. Added references for azdata and vscode. * Added azure monitor light and dark icons * Added config for Dashboard in package.json * Added workspace information to dashboard * Added language support for LogAnalytics * Added Notebook support * Added Hide flag to package.json for databaseName * Changed providerId from LogAnalytics to LOGANALYTICS * Changed Workspace to Workspace ID in package.nls.json * Added support for Azure Widget browser * Changed fullName to use workspaceId when connecting * Changed providerId from alertsManagement to azureMonitor * Added .gitignore and *.vsix to vscodeignore. * Removed unused devDependencies * Code Review Feedback * Changed tsconfig.json to match Kusto and Sql * Changed package.json to match kusto package. * Changed tsconfig to validate unused params and implictAny. Changed existing code to satisfy build. * Fixed tsconfig to use the correct base class. * Added objectExplorerNodeProvider and all related classes. * Removed unused tmLanguage file * Added logic to to download extension from toolservice * Fixed launchArgs. Removed commented code from extension.ts. Changed config.json to use net5.0 * Added displayName to package.nls.json. Removed hide flag from databaseName. Other code review feedback. * Added readme info to AzureMonitor * Removed unused client-error-handler and ui-references files. Combined outputChannel in azuremonitorServer. Removed TODO from contextProvider. Renamed function in extension.ts. Removed unneeded 'use strict' from cancelableStream.ts. Removed second outputChannel from objectExplorerNodeProvider. * Removed unused files
78 lines
2.5 KiB
TypeScript
78 lines
2.5 KiB
TypeScript
// This code is originally from https://github.com/DonJayamanne/bowerVSCode
|
|
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
|
|
|
|
import { window } from 'vscode';
|
|
import PromptFactory from './factory';
|
|
import EscapeException from './escapeException';
|
|
import { IQuestion, IPrompter, IPromptCallback, Answers } from './question';
|
|
|
|
// Supports simple pattern for prompting for user input and acting on this
|
|
export default class CodeAdapter implements IPrompter {
|
|
|
|
// TODO define question interface
|
|
private fixQuestion(question: IQuestion): any {
|
|
if (question.type === 'checkbox' && Array.isArray(question.choices)) {
|
|
// For some reason when there's a choice of checkboxes, they aren't formatted properly
|
|
// Not sure where the issue is
|
|
question.choices = question.choices.map(item => {
|
|
if (typeof (item) === 'string') {
|
|
return { checked: false, name: item, value: item };
|
|
} else {
|
|
return item;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public async promptSingle<T>(question: IQuestion, ignoreFocusOut?: boolean): Promise<T | undefined> {
|
|
let questions: IQuestion[] = [question];
|
|
const answers = await this.prompt<T>(questions, ignoreFocusOut);
|
|
if (answers) {
|
|
let response: T = answers[question.name];
|
|
return response || undefined;
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
public async prompt<T>(questions: IQuestion[], ignoreFocusOut?: boolean): Promise<Answers<T> | undefined> {
|
|
// Collapse multiple questions into a set of prompt steps
|
|
const promptResult = new Promise<Answers<T>>((resolve) => {
|
|
let answers: Answers<T> = {};
|
|
questions.forEach(async (question: IQuestion) => {
|
|
this.fixQuestion(question);
|
|
const prompt = await PromptFactory.createPrompt(question, ignoreFocusOut);
|
|
if (!question.shouldPrompt || question.shouldPrompt(answers) === true) {
|
|
const result = await prompt.render();
|
|
answers[question.name] = result;
|
|
|
|
if (question.onAnswered) {
|
|
question.onAnswered(result);
|
|
}
|
|
return;
|
|
}
|
|
});
|
|
|
|
resolve(answers);
|
|
});
|
|
|
|
try {
|
|
return await promptResult;
|
|
} catch (err) {
|
|
if (err instanceof EscapeException || err instanceof TypeError) {
|
|
window.showErrorMessage(err.message);
|
|
}
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
// Helper to make it possible to prompt using callback pattern. Generally Promise is a preferred flow
|
|
public promptCallback(questions: IQuestion[], callback: IPromptCallback | undefined): void {
|
|
// Collapse multiple questions into a set of prompt steps
|
|
this.prompt(questions).then(answers => {
|
|
if (callback && answers) {
|
|
callback(answers);
|
|
}
|
|
});
|
|
}
|
|
}
|