Skip to content

Commit

Permalink
utils: Revert commit 5852321 (#1733)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroFish91 authored May 29, 2024
1 parent 5852321 commit 494a281
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 84 deletions.
20 changes: 2 additions & 18 deletions utils/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -959,15 +959,6 @@ export interface IAzureUserInput {
* @returns A promise that resolves to the selected resources.
*/
showOpenDialog(options: AzExtOpenDialogOptions): Promise<Uri[]>;

/**
* 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<WorkspaceFolder>;
}

/**
Expand Down Expand Up @@ -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.
Expand All @@ -1121,7 +1107,6 @@ export declare class AzExtUserInputWithInputQueue implements IAzureUserInput {
showWarningMessage<T extends MessageItem>(message: string, ...items: T[]): Promise<T>;
showWarningMessage<T extends MessageItem>(message: string, options: IAzureMessageOptions, ...items: T[]): Promise<T>;
showOpenDialog(options: AzExtOpenDialogOptions): Promise<Uri[]>;
showWorkspaceFolderPick(options: AzExtWorkspaceFolderPickOptions): Promise<WorkspaceFolder>;
}

export interface IWizardOptions<T extends IActionContext> {
Expand Down Expand Up @@ -2246,7 +2231,6 @@ export interface IAzureAgentInput {
showWarningMessage<T extends MessageItem>(message: string, ...items: T[]): Promise<T>;
showWarningMessage<T extends MessageItem>(message: string, options: IAzureMessageOptions, ...items: T[]): Promise<T>;
showOpenDialog(options: AzExtOpenDialogOptions): Promise<Uri[]>;
showWorkspaceFolderPick(options: AzExtWorkspaceFolderPickOptions): Promise<WorkspaceFolder>;
}

// #endregion
Expand Down
18 changes: 1 addition & 17 deletions utils/src/userInput/AzExtUserInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
* 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';
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;
Expand Down Expand Up @@ -80,21 +79,6 @@ export class AzExtUserInput implements types.IAzureUserInput {
}
}

public async showWorkspaceFolderPick(options: types.AzExtWorkspaceFolderPickOptions): Promise<WorkspaceFolder> {
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<T extends MessageItem>(message: string, ...items: T[]): Promise<T>;
public async showWarningMessage<T extends MessageItem>(message: string, options: types.IAzureMessageOptions, ...items: T[]): Promise<T>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
22 changes: 1 addition & 21 deletions utils/src/userInput/AzExtUserInputWithInputQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -100,26 +100,6 @@ export class AzExtUserInputWithInputQueue implements AzExtUserInputWithInputQueu
return result;
}

public async showWorkspaceFolderPick(options: AzExtWorkspaceFolderPickOptions): Promise<vscode.WorkspaceFolder> {
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<T extends vscode.MessageItem>(message: string, ...items: T[]): Promise<T>;
public async showWarningMessage<T extends vscode.MessageItem>(message: string, options: IAzureMessageOptions, ...items: T[]): Promise<T>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
20 changes: 0 additions & 20 deletions utils/src/userInput/showWorkspaceFolderPick.ts

This file was deleted.

10 changes: 2 additions & 8 deletions utils/test/AzureAgentInputTypeCheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PromptResult>;
Expand All @@ -25,9 +25,6 @@ class MockAzureUserInput implements IAzureUserInput {
showOpenDialog(_options: AzExtOpenDialogOptions): Promise<Uri[]> {
throw new Error("Method not implemented.");
}
showWorkspaceFolderPick(_options: AzExtWorkspaceFolderPickOptions): Promise<WorkspaceFolder> {
throw new Error("Method not implemented.");
}
}

class MockAzureAgentInput implements IAzureAgentInput {
Expand All @@ -48,9 +45,6 @@ class MockAzureAgentInput implements IAzureAgentInput {
showOpenDialog(_options: AzExtOpenDialogOptions): Promise<Uri[]> {
throw new Error("Method not implemented.");
}
showWorkspaceFolderPick(_options: AzExtWorkspaceFolderPickOptions): Promise<WorkspaceFolder> {
throw new Error("Method not implemented.");
}
}

const mockAzureUserInput: IAzureUserInput = new MockAzureUserInput();
Expand Down

0 comments on commit 494a281

Please sign in to comment.