From 813f1e87f929efe47f1898b390963aa731ae5a0c Mon Sep 17 00:00:00 2001 From: MicroFish91 <40250218+MicroFish91@users.noreply.github.com> Date: Wed, 29 May 2024 15:06:25 -0700 Subject: [PATCH 1/4] Revert "Add showWorkspaceFolderPick to AzExtUserInput" This reverts commit 585232118fb5d8f607bf23bfaa8a7fc143307e20. --- utils/index.d.ts | 20 ++--------------- utils/src/userInput/AzExtUserInput.ts | 18 +-------------- .../userInput/AzExtUserInputWithInputQueue.ts | 22 +------------------ .../src/userInput/showWorkspaceFolderPick.ts | 20 ----------------- utils/test/AzureAgentInputTypeCheck.test.ts | 10 ++------- 5 files changed, 6 insertions(+), 84 deletions(-) delete mode 100644 utils/src/userInput/showWorkspaceFolderPick.ts diff --git a/utils/index.d.ts b/utils/index.d.ts index 8d7e7a3780..ff019f78a2 100644 --- a/utils/index.d.ts +++ b/utils/index.d.ts @@ -7,7 +7,7 @@ import type { Environment } from '@azure/ms-rest-azure-env'; import type { AzExtResourceType, AzureResource, AzureSubscription, ResourceModelBase } from '@microsoft/vscode-azureresources-api'; -import { AuthenticationSession, CancellationToken, CancellationTokenSource, Disposable, Event, ExtensionContext, FileChangeEvent, FileChangeType, FileStat, FileSystemProvider, FileType, InputBoxOptions, LogOutputChannel, MarkdownString, MessageItem, MessageOptions, OpenDialogOptions, OutputChannel, Progress, ProviderResult, QuickPickItem, TextDocumentShowOptions, ThemeIcon, TreeDataProvider, TreeItem, TreeItemCollapsibleState, TreeView, Uri, QuickPickOptions as VSCodeQuickPickOptions, WorkspaceFolder, WorkspaceFolderPickOptions } from 'vscode'; +import { AuthenticationSession, CancellationToken, CancellationTokenSource, Disposable, Event, ExtensionContext, FileChangeEvent, FileChangeType, FileStat, FileSystemProvider, FileType, InputBoxOptions, LogOutputChannel, MarkdownString, MessageItem, MessageOptions, OpenDialogOptions, OutputChannel, Progress, ProviderResult, QuickPickItem, TextDocumentShowOptions, ThemeIcon, TreeDataProvider, TreeItem, TreeItemCollapsibleState, TreeView, Uri, QuickPickOptions as VSCodeQuickPickOptions } from 'vscode'; import { TargetPopulation } from 'vscode-tas-client'; import type { Activity, ActivityTreeItemOptions, AppResource, OnErrorActivityData, OnProgressActivityData, OnStartActivityData, OnSuccessActivityData } from './hostapi'; // This must remain `import type` or else a circular reference will result @@ -884,7 +884,7 @@ export interface IParsedError { } export type PromptResult = { - value: string | QuickPickItem | QuickPickItem[] | MessageItem | Uri[] | WorkspaceFolder; + value: string | QuickPickItem | QuickPickItem[] | MessageItem | Uri[]; /** * True if the user did not change from the default value, currently only supported for `showInputBox` @@ -959,15 +959,6 @@ export interface IAzureUserInput { * @returns A promise that resolves to the selected resources. */ showOpenDialog(options: AzExtOpenDialogOptions): Promise; - - /** - * Shows a selection list of existing workspace folders to choose from. - * - * @param options Configures the behavior of the workspace folder list. - * @throws `UserCancelledError` if the user cancels. - * @returns A promise that resolves to the selected `WorkspaceFolder`. - */ - showWorkspaceFolderPick(options: AzExtWorkspaceFolderPickOptions): Promise; } /** @@ -1095,11 +1086,6 @@ export interface AzExtInputBoxOptions extends InputBoxOptions, AzExtUserInputOpt */ export interface AzExtOpenDialogOptions extends OpenDialogOptions, AzExtUserInputOptions { } -/** -* Provides additional options for workspace folder picks used in Azure Extensions -*/ -export type AzExtWorkspaceFolderPickOptions = WorkspaceFolderPickOptions & AzExtUserInputOptions; - /** * A queue of inputs that should be used by an {@link IAzureUserInput} implementation to answer prompts instead of showing prompts to the user. * If the head of the queue is undefined or null, then the {@link IAzureUserInput} implementation should show a prompt to the user. @@ -1121,7 +1107,6 @@ export declare class AzExtUserInputWithInputQueue implements IAzureUserInput { showWarningMessage(message: string, ...items: T[]): Promise; showWarningMessage(message: string, options: IAzureMessageOptions, ...items: T[]): Promise; showOpenDialog(options: AzExtOpenDialogOptions): Promise; - showWorkspaceFolderPick(options: AzExtWorkspaceFolderPickOptions): Promise; } export interface IWizardOptions { @@ -2246,7 +2231,6 @@ export interface IAzureAgentInput { showWarningMessage(message: string, ...items: T[]): Promise; showWarningMessage(message: string, options: IAzureMessageOptions, ...items: T[]): Promise; showOpenDialog(options: AzExtOpenDialogOptions): Promise; - showWorkspaceFolderPick(options: AzExtWorkspaceFolderPickOptions): Promise; } // #endregion diff --git a/utils/src/userInput/AzExtUserInput.ts b/utils/src/userInput/AzExtUserInput.ts index d690d9c639..cb50a9fddc 100644 --- a/utils/src/userInput/AzExtUserInput.ts +++ b/utils/src/userInput/AzExtUserInput.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Event, EventEmitter, MessageItem, Uri, WorkspaceFolder } from 'vscode'; +import { Event, EventEmitter, MessageItem, Uri } from 'vscode'; import * as types from '../../index'; import { UserCancelledError } from '../errors'; import { IInternalActionContext, IInternalAzureWizard } from './IInternalActionContext'; @@ -11,7 +11,6 @@ import { showInputBox } from './showInputBox'; import { showOpenDialog } from './showOpenDialog'; import { showQuickPick } from './showQuickPick'; import { showWarningMessage } from './showWarningMessage'; -import { showWorkspaceFolderPick } from './showWorkspaceFolderPick'; export class AzExtUserInput implements types.IAzureUserInput { public wizard?: IInternalAzureWizard; @@ -80,21 +79,6 @@ export class AzExtUserInput implements types.IAzureUserInput { } } - public async showWorkspaceFolderPick(options: types.AzExtWorkspaceFolderPickOptions): Promise { - addStepTelemetry(this._context, options.stepName, 'WorkspaceFolderPick', options.placeHolder); - if (this._context.ui.wizard?.cancellationToken.isCancellationRequested) { - throw new UserCancelledError(); - } - try { - this._isPrompting = true; - const result = await showWorkspaceFolderPick(options); - this._onDidFinishPromptEmitter.fire({ value: result }); - return result; - } finally { - this._isPrompting = false; - } - } - public async showWarningMessage(message: string, ...items: T[]): Promise; public async showWarningMessage(message: string, options: types.IAzureMessageOptions, ...items: T[]): Promise; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/utils/src/userInput/AzExtUserInputWithInputQueue.ts b/utils/src/userInput/AzExtUserInputWithInputQueue.ts index feeb37abd6..8f1c5830ce 100644 --- a/utils/src/userInput/AzExtUserInputWithInputQueue.ts +++ b/utils/src/userInput/AzExtUserInputWithInputQueue.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from "vscode"; -import { AzExtInputBoxOptions, AzExtOpenDialogOptions, AzExtWorkspaceFolderPickOptions, AzureUserInputQueue, IAzureMessageOptions, IAzureQuickPickItem, IAzureQuickPickOptions, IAzureUserInput, PromptResult, type AzExtUserInputWithInputQueue as AzExtUserInputWithInputQueueType } from "../../"; +import { AzExtInputBoxOptions, AzExtOpenDialogOptions, AzureUserInputQueue, IAzureMessageOptions, IAzureQuickPickItem, IAzureQuickPickOptions, IAzureUserInput, PromptResult, type AzExtUserInputWithInputQueue as AzExtUserInputWithInputQueueType } from "../../"; import { UserCancelledError } from "../errors"; import { AzExtUserInput, addStepTelemetry } from "./AzExtUserInput"; import { IInternalActionContext } from "./IInternalActionContext"; @@ -100,26 +100,6 @@ export class AzExtUserInputWithInputQueue implements AzExtUserInputWithInputQueu return result; } - public async showWorkspaceFolderPick(options: AzExtWorkspaceFolderPickOptions): Promise { - addStepTelemetry(this._context, options.stepName, 'WorkspaceFolderPick', options.placeHolder); - if (this._context.ui.wizard?.cancellationToken.isCancellationRequested) { - throw new UserCancelledError(); - } - this._isPrompting = true; - - let result: vscode.WorkspaceFolder; - const nextItemInQueue = (this._inputsQueue.shift() as vscode.WorkspaceFolder | null | undefined); - if (!nextItemInQueue) { - result = await this._realAzureUserInput.showWorkspaceFolderPick(options); - } else { - result = nextItemInQueue; - this._onDidFinishPromptEmitter.fire({ value: result }); - } - - this._isPrompting = false; - return result; - } - public async showWarningMessage(message: string, ...items: T[]): Promise; public async showWarningMessage(message: string, options: IAzureMessageOptions, ...items: T[]): Promise; // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/utils/src/userInput/showWorkspaceFolderPick.ts b/utils/src/userInput/showWorkspaceFolderPick.ts deleted file mode 100644 index 39275c62e7..0000000000 --- a/utils/src/userInput/showWorkspaceFolderPick.ts +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { WorkspaceFolder, WorkspaceFolderPickOptions, l10n, window } from "vscode"; -import { UserCancelledError } from "../errors"; - -export async function showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions): Promise { - const folder: WorkspaceFolder | undefined = await window.showWorkspaceFolderPick({ - ...options, - placeHolder: options?.placeHolder ?? l10n.t('Select a root workspace folder') - }); - - if (!folder) { - throw new UserCancelledError('selectRootWorkspaceFolder'); - } - - return folder; -} diff --git a/utils/test/AzureAgentInputTypeCheck.test.ts b/utils/test/AzureAgentInputTypeCheck.test.ts index c76af8e49d..5421e9f925 100644 --- a/utils/test/AzureAgentInputTypeCheck.test.ts +++ b/utils/test/AzureAgentInputTypeCheck.test.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from "assert"; -import { Event, MessageItem, QuickPickItem, Uri, WorkspaceFolder } from "vscode"; -import { AgentInputBoxOptions, AgentQuickPickItem, AgentQuickPickOptions, AzExtInputBoxOptions, AzExtOpenDialogOptions, AzExtWorkspaceFolderPickOptions, IAzureAgentInput, IAzureMessageOptions, IAzureQuickPickOptions, IAzureUserInput, PromptResult } from ".."; +import { Event, MessageItem, QuickPickItem, Uri } from "vscode"; +import { AgentInputBoxOptions, AgentQuickPickItem, AgentQuickPickOptions, AzExtInputBoxOptions, AzExtOpenDialogOptions, IAzureAgentInput, IAzureMessageOptions, IAzureQuickPickOptions, IAzureUserInput, PromptResult } from ".."; class MockAzureUserInput implements IAzureUserInput { onDidFinishPrompt: Event; @@ -25,9 +25,6 @@ class MockAzureUserInput implements IAzureUserInput { showOpenDialog(_options: AzExtOpenDialogOptions): Promise { throw new Error("Method not implemented."); } - showWorkspaceFolderPick(_options: AzExtWorkspaceFolderPickOptions): Promise { - throw new Error("Method not implemented."); - } } class MockAzureAgentInput implements IAzureAgentInput { @@ -48,9 +45,6 @@ class MockAzureAgentInput implements IAzureAgentInput { showOpenDialog(_options: AzExtOpenDialogOptions): Promise { throw new Error("Method not implemented."); } - showWorkspaceFolderPick(_options: AzExtWorkspaceFolderPickOptions): Promise { - throw new Error("Method not implemented."); - } } const mockAzureUserInput: IAzureUserInput = new MockAzureUserInput(); From c50405b11499a915ffd77e1011d97a7dcfb658e4 Mon Sep 17 00:00:00 2001 From: MicroFish91 <40250218+MicroFish91@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:22:26 -0700 Subject: [PATCH 2/4] Add duplicate properties error properties and deprecated old ones --- azure/src/wizard/VerifyProvidersStep.ts | 15 +++++++++++++-- utils/src/callWithTelemetryAndErrorHandling.ts | 11 +++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/azure/src/wizard/VerifyProvidersStep.ts b/azure/src/wizard/VerifyProvidersStep.ts index 02a31f6d8b..484d6bd4dd 100644 --- a/azure/src/wizard/VerifyProvidersStep.ts +++ b/azure/src/wizard/VerifyProvidersStep.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import type { Provider, ResourceManagementClient } from '@azure/arm-resources'; -import { AzureWizardExecuteStep, ISubscriptionActionContext, parseError } from '@microsoft/vscode-azext-utils'; +import { AzureWizardExecuteStep, IParsedError, ISubscriptionActionContext, parseError } from '@microsoft/vscode-azext-utils'; import { l10n, Progress } from 'vscode'; import * as types from '../../index'; import { createResourcesClient } from '../clients'; @@ -39,7 +39,18 @@ export class VerifyProvidersStep extends A } } catch (error) { // ignore and continue with wizard. An error here would likely be confusing and un-actionable - context.telemetry.properties.providerError = parseError(error).message; + const perror: IParsedError = parseError(error); + + /** + * @param providerError + * @deprecated + * Continue to emit telemetry for clients who are still using this property. + * + * @param providerError2 + * A duplicate replacement of the `providerError` telemetry property. + */ + context.telemetry.properties.providerError = perror.message; + context.telemetry.properties.providerError2 = perror.message; } })); } diff --git a/utils/src/callWithTelemetryAndErrorHandling.ts b/utils/src/callWithTelemetryAndErrorHandling.ts index badff50597..02167345c1 100644 --- a/utils/src/callWithTelemetryAndErrorHandling.ts +++ b/utils/src/callWithTelemetryAndErrorHandling.ts @@ -136,7 +136,18 @@ function handleError(context: types.IActionContext, callbackId: string, error: u } else { context.telemetry.properties.result = 'Failed'; context.telemetry.properties.error = errorData.errorType; + + /** + * @param errorMessage + * @deprecated + * Continue to emit telemetry for clients who are still using this property. + * + * @param errorMessage2 + * A duplicate replacement of the `errorMessage` telemetry property. + */ context.telemetry.properties.errorMessage = errorData.message; + context.telemetry.properties.errorMessage2 = errorData.message; + context.telemetry.properties.stack = errorData.stack ? limitLines(errorData.stack, maxStackLines) : undefined; if (context.telemetry.suppressIfSuccessful || context.telemetry.suppressAll) { context.telemetry.properties.suppressTelemetry = 'true'; From f14656b0b5d4ea76856561aa58e491fd01d92f16 Mon Sep 17 00:00:00 2001 From: MicroFish91 <40250218+MicroFish91@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:28:06 -0700 Subject: [PATCH 3/4] Update comments --- azure/src/wizard/VerifyProvidersStep.ts | 2 +- utils/src/callWithTelemetryAndErrorHandling.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure/src/wizard/VerifyProvidersStep.ts b/azure/src/wizard/VerifyProvidersStep.ts index 484d6bd4dd..37083f6285 100644 --- a/azure/src/wizard/VerifyProvidersStep.ts +++ b/azure/src/wizard/VerifyProvidersStep.ts @@ -44,7 +44,7 @@ export class VerifyProvidersStep extends A /** * @param providerError * @deprecated - * Continue to emit telemetry for clients who are still using this property. + * Continue to emit telemetry for clients who are still using this property. You should suppress this property if you need to migrate to the new replacement. * * @param providerError2 * A duplicate replacement of the `providerError` telemetry property. diff --git a/utils/src/callWithTelemetryAndErrorHandling.ts b/utils/src/callWithTelemetryAndErrorHandling.ts index 02167345c1..ebdabe105a 100644 --- a/utils/src/callWithTelemetryAndErrorHandling.ts +++ b/utils/src/callWithTelemetryAndErrorHandling.ts @@ -140,10 +140,10 @@ function handleError(context: types.IActionContext, callbackId: string, error: u /** * @param errorMessage * @deprecated - * Continue to emit telemetry for clients who are still using this property. + * Continue to emit telemetry for clients who are still using this property. You should suppress this property if you need to migrate to the new replacement. * * @param errorMessage2 - * A duplicate replacement of the `errorMessage` telemetry property. + * A duplicate replacement of the `errorMessage` telemetry property which should be used instead. */ context.telemetry.properties.errorMessage = errorData.message; context.telemetry.properties.errorMessage2 = errorData.message; From 1c41ddeac6fbd277d6c2d3cfdbbcb7de298c3a06 Mon Sep 17 00:00:00 2001 From: MicroFish91 <40250218+MicroFish91@users.noreply.github.com> Date: Tue, 27 Aug 2024 10:13:57 -0700 Subject: [PATCH 4/4] Feedback change to v2 --- azure/src/wizard/VerifyProvidersStep.ts | 4 ++-- utils/src/callWithTelemetryAndErrorHandling.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/azure/src/wizard/VerifyProvidersStep.ts b/azure/src/wizard/VerifyProvidersStep.ts index 37083f6285..6a860eca40 100644 --- a/azure/src/wizard/VerifyProvidersStep.ts +++ b/azure/src/wizard/VerifyProvidersStep.ts @@ -46,11 +46,11 @@ export class VerifyProvidersStep extends A * @deprecated * Continue to emit telemetry for clients who are still using this property. You should suppress this property if you need to migrate to the new replacement. * - * @param providerError2 + * @param providerErrorV2 * A duplicate replacement of the `providerError` telemetry property. */ context.telemetry.properties.providerError = perror.message; - context.telemetry.properties.providerError2 = perror.message; + context.telemetry.properties.providerErrorV2 = perror.message; } })); } diff --git a/utils/src/callWithTelemetryAndErrorHandling.ts b/utils/src/callWithTelemetryAndErrorHandling.ts index ebdabe105a..b9813c294b 100644 --- a/utils/src/callWithTelemetryAndErrorHandling.ts +++ b/utils/src/callWithTelemetryAndErrorHandling.ts @@ -142,11 +142,11 @@ function handleError(context: types.IActionContext, callbackId: string, error: u * @deprecated * Continue to emit telemetry for clients who are still using this property. You should suppress this property if you need to migrate to the new replacement. * - * @param errorMessage2 + * @param errorMessageV2 * A duplicate replacement of the `errorMessage` telemetry property which should be used instead. */ context.telemetry.properties.errorMessage = errorData.message; - context.telemetry.properties.errorMessage2 = errorData.message; + context.telemetry.properties.errorMessageV2 = errorData.message; context.telemetry.properties.stack = errorData.stack ? limitLines(errorData.stack, maxStackLines) : undefined; if (context.telemetry.suppressIfSuccessful || context.telemetry.suppressAll) {