From 389254f639b1e1ceddff4d1aaa73dd6303cd7496 Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Fri, 2 Sep 2022 15:51:40 -0700 Subject: [PATCH 01/15] Boxing / unboxing functionality (#1231) Co-authored-by: Brandon Waterloo [MSFT] <36966225+bwateratmsft@users.noreply.github.com> --- utils/hostapi.v2.d.ts | 39 ++++++++++++++ utils/index.d.ts | 4 +- utils/src/index.ts | 1 + .../registerCommandWithTreeNodeUnboxing.ts | 52 +++++++++++++++++++ utils/test/isBox.test.ts | 30 +++++++++++ 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 utils/hostapi.v2.d.ts create mode 100644 utils/src/registerCommandWithTreeNodeUnboxing.ts create mode 100644 utils/test/isBox.test.ts diff --git a/utils/hostapi.v2.d.ts b/utils/hostapi.v2.d.ts new file mode 100644 index 0000000000..b6289593cd --- /dev/null +++ b/utils/hostapi.v2.d.ts @@ -0,0 +1,39 @@ +import { IActionContext } from "./index"; + +/** + * Interface describing an object that wraps another object. + * + * The host extension will wrap all tree nodes provided by the client + * extensions. When commands are executed, the wrapper objects are + * sent directly to the client extension, which will need to unwrap + * them. The `registerCommandWithTreeNodeUnboxing` method below, used + * in place of `registerCommand`, will intelligently do this + * unboxing automatically (i.e., will not unbox if the arguments + * aren't boxes) + */ +export interface Box { + unwrap(): Promise; +} + +/** + * Tests to see if something is a box, by ensuring it is an object + * and has an "unwrap" function + * @param maybeBox An object to test if it is a box + * @returns True if a box, false otherwise + */ +export declare function isBox(maybeBox: unknown): maybeBox is Box; + +/** + * Describes command callbacks for tree node context menu commands + */ +export type TreeNodeCommandCallback = (context: IActionContext, node?: T, nodes?: T[], ...args: any[]) => any; + +/** + * Used to register VSCode tree node context menu commands that are in the host extension's tree. It wraps your callback with consistent error and telemetry handling + * Use debounce property if you need a delay between clicks for this particular command + * A telemetry event is automatically sent whenever a command is executed. The telemetry event ID will default to the same as the + * commandId passed in, but can be overridden per command with telemetryId + * The telemetry event for this command will be named telemetryId if specified, otherwise it defaults to the commandId + * NOTE: If the environment variable `DEBUGTELEMETRY` is set to a non-empty, non-zero value, then telemetry will not be sent. If the value is 'verbose' or 'v', telemetry will be displayed in the console window. + */ +export declare function registerCommandWithTreeNodeUnboxing(commandId: string, callback: TreeNodeCommandCallback, debounce?: number, telemetryId?: string): void; diff --git a/utils/index.d.ts b/utils/index.d.ts index 192f0db440..0f01f5b888 100644 --- a/utils/index.d.ts +++ b/utils/index.d.ts @@ -635,7 +635,9 @@ export declare class UserCancelledError extends Error { constructor(stepName?: string); } -export declare class NoResourceFoundError extends Error { } +export declare class NoResourceFoundError extends Error { + constructor(context?: ITreeItemPickerContext); +} export type CommandCallback = (context: IActionContext, ...args: any[]) => any; diff --git a/utils/src/index.ts b/utils/src/index.ts index 652cb16c21..25af2ff87a 100644 --- a/utils/src/index.ts +++ b/utils/src/index.ts @@ -16,6 +16,7 @@ export { addExtensionValueToMask, callWithMaskHandling, maskValue } from './mask export * from './openReadOnlyContent'; export * from './parseError'; export * from './registerCommand'; +export * from './registerCommandWithTreeNodeUnboxing'; export * from './registerEvent'; export { registerReportIssueCommand } from './registerReportIssueCommand'; export * from './tree/AzExtParentTreeItem'; diff --git a/utils/src/registerCommandWithTreeNodeUnboxing.ts b/utils/src/registerCommandWithTreeNodeUnboxing.ts new file mode 100644 index 0000000000..33cf4a5096 --- /dev/null +++ b/utils/src/registerCommandWithTreeNodeUnboxing.ts @@ -0,0 +1,52 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.txt in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + +import type { CommandCallback, IActionContext } from '../index'; +import type { Box, TreeNodeCommandCallback } from '../hostapi.v2'; +import { registerCommand } from './registerCommand'; + +export function registerCommandWithTreeNodeUnboxing(commandId: string, treeNodeCallback: TreeNodeCommandCallback, debounce?: number, telemetryId?: string): void { + const unwrappingCallback: CommandCallback = async (context: IActionContext, ...args: unknown[]) => { + const maybeNodeBox = args?.[0]; + const maybeNodeBoxArray = args?.[1]; + const remainingArgs = args.slice(2); + + let node: T | undefined; + if (maybeNodeBox && isBox(maybeNodeBox)) { + // If the first arg is a box, unwrap it + node = await maybeNodeBox.unwrap(); + } else if (maybeNodeBox) { + // Otherwise, assume it is just a T + node = maybeNodeBox as T; + } + + let nodes: T[] | undefined; + if (maybeNodeBoxArray && Array.isArray(maybeNodeBoxArray) && maybeNodeBoxArray.every(n => isBox(n))) { + // If the first arg is an array of boxes, unwrap them + const boxedNodes = maybeNodeBoxArray as Box[]; + nodes = []; + for (const n of boxedNodes) { + nodes.push(await n.unwrap()) + } + } else if (maybeNodeBoxArray && Array.isArray(maybeNodeBoxArray)) { + // Otherwise, assume it is just an array of T's + nodes = maybeNodeBoxArray as T[]; + } + + // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call + return treeNodeCallback(context, node, nodes, ...remainingArgs); + }; + + registerCommand(commandId, unwrappingCallback, debounce, telemetryId); +} + +export function isBox(maybeBox: unknown): maybeBox is Box { + if (maybeBox && typeof maybeBox === 'object' && + (maybeBox as Box).unwrap && typeof (maybeBox as Box).unwrap === 'function') { + return true; + } + + return false; +} diff --git a/utils/test/isBox.test.ts b/utils/test/isBox.test.ts new file mode 100644 index 0000000000..a8f367d22e --- /dev/null +++ b/utils/test/isBox.test.ts @@ -0,0 +1,30 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as assert from 'assert'; +import type { Box } from '../hostapi.v2'; +import { isBox } from '../src/registerCommandWithTreeNodeUnboxing'; + +suite('isBox', () => { + + test('Not a box', () => { + assert.strictEqual(isBox(undefined), false); + assert.strictEqual(isBox(null), false); + assert.strictEqual(isBox(1), false); + assert.strictEqual(isBox(false), false); + assert.strictEqual(isBox('foo'), false); + assert.strictEqual(isBox({}), false); + assert.strictEqual(isBox({ unwrap: false }), false); + }); + + test('Box', () => { + const actualBox: Box = { + unwrap: () => { return Promise.resolve(undefined as unknown as T) }, + }; + + assert.strictEqual(isBox(actualBox), true); + }); + +}); From 514514a373d3ba2f68e7f6ce828cb6d65a6f3b7b Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Tue, 6 Sep 2022 13:51:14 -0700 Subject: [PATCH 02/15] Fixup box / unbox * Make unwrap not a Promise * Move types into index.d.ts from hostapi.v2.d.ts --- utils/hostapi.v2.d.ts | 10 +--------- utils/index.d.ts | 9 +++++++++ utils/src/registerCommandWithTreeNodeUnboxing.ts | 2 +- utils/test/isBox.test.ts | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/utils/hostapi.v2.d.ts b/utils/hostapi.v2.d.ts index b6289593cd..de5e6d886e 100644 --- a/utils/hostapi.v2.d.ts +++ b/utils/hostapi.v2.d.ts @@ -12,17 +12,9 @@ import { IActionContext } from "./index"; * aren't boxes) */ export interface Box { - unwrap(): Promise; + unwrap(): T; } -/** - * Tests to see if something is a box, by ensuring it is an object - * and has an "unwrap" function - * @param maybeBox An object to test if it is a box - * @returns True if a box, false otherwise - */ -export declare function isBox(maybeBox: unknown): maybeBox is Box; - /** * Describes command callbacks for tree node context menu commands */ diff --git a/utils/index.d.ts b/utils/index.d.ts index 0f01f5b888..7fccf64a8f 100644 --- a/utils/index.d.ts +++ b/utils/index.d.ts @@ -10,6 +10,7 @@ import { CancellationToken, CancellationTokenSource, Disposable, Event, Extensio import { TargetPopulation } from 'vscode-tas-client'; import { AzureExtensionApi, AzureExtensionApiProvider } from './api'; import type { Activity, ActivityTreeItemOptions, AppResource, OnErrorActivityData, OnProgressActivityData, OnStartActivityData, OnSuccessActivityData } from './hostapi'; // This must remain `import type` or else a circular reference will result +import { Box } from './hostapi.v2'; export declare interface RunWithTemporaryDescriptionOptions { description: string; @@ -1678,3 +1679,11 @@ export declare enum AzExtResourceType { VirtualNetworks = 'VirtualNetworks', WebHostingEnvironments = 'WebHostingEnvironments', } + +/** + * Tests to see if something is a box, by ensuring it is an object + * and has an "unwrap" function + * @param maybeBox An object to test if it is a box + * @returns True if a box, false otherwise + */ +export declare function isBox(maybeBox: unknown): maybeBox is Box; diff --git a/utils/src/registerCommandWithTreeNodeUnboxing.ts b/utils/src/registerCommandWithTreeNodeUnboxing.ts index 33cf4a5096..4adfd0ed2a 100644 --- a/utils/src/registerCommandWithTreeNodeUnboxing.ts +++ b/utils/src/registerCommandWithTreeNodeUnboxing.ts @@ -28,7 +28,7 @@ export function registerCommandWithTreeNodeUnboxing(commandId: string, treeNo const boxedNodes = maybeNodeBoxArray as Box[]; nodes = []; for (const n of boxedNodes) { - nodes.push(await n.unwrap()) + nodes.push(n.unwrap()) } } else if (maybeNodeBoxArray && Array.isArray(maybeNodeBoxArray)) { // Otherwise, assume it is just an array of T's diff --git a/utils/test/isBox.test.ts b/utils/test/isBox.test.ts index a8f367d22e..383e65e7eb 100644 --- a/utils/test/isBox.test.ts +++ b/utils/test/isBox.test.ts @@ -21,7 +21,7 @@ suite('isBox', () => { test('Box', () => { const actualBox: Box = { - unwrap: () => { return Promise.resolve(undefined as unknown as T) }, + unwrap: () => { return undefined as unknown as T }, }; assert.strictEqual(isBox(actualBox), true); From f6b7e656c7fedca0ee22b2a2f933ba2eb03d1097 Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Tue, 6 Sep 2022 13:51:34 -0700 Subject: [PATCH 03/15] Maybe unwrap node --- utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts b/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts index b44002d9d7..bf6f6d6113 100644 --- a/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts +++ b/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts @@ -7,6 +7,7 @@ import * as types from '../../../index'; import { GenericQuickPickOptions, GenericQuickPickStep } from './GenericQuickPickStep'; import { isAzExtParentTreeItem } from '../../tree/InternalInterfaces'; import { QuickPickWizardContext } from './QuickPickWizardContext'; +import { isBox } from '../../registerCommandWithTreeNodeUnboxing'; /** * Describes filtering based on context value. Items that pass the filter will @@ -49,6 +50,8 @@ export class ContextValueQuickPickStep Date: Tue, 6 Sep 2022 14:23:09 -0700 Subject: [PATCH 04/15] Don't import from index --- .../experiences/appResourceExperience.ts | 11 +++++++---- .../experiences/contextValueExperience.ts | 10 ++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts b/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts index daeb6c515d..f19dde4f64 100644 --- a/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts +++ b/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as types from '../../../../index'; import * as vscode from 'vscode'; import { ContextValueFilter } from '../ContextValueQuickPickStep'; import { QuickPickAzureSubscriptionStep } from '../quickPickAzureResource/QuickPickAzureSubscriptionStep'; @@ -14,9 +13,13 @@ import { RecursiveQuickPickStep } from '../RecursiveQuickPickStep'; import { Box, ResourceGroupsItem } from '../quickPickAzureResource/tempTypes'; import { getLastNode } from '../QuickPickWizardContext'; import { NoResourceFoundError } from '../../../errors'; +import { IActionContext } from '../../../../index'; +import { AzureWizardPromptStep } from '../../../wizard/AzureWizardPromptStep'; +import { AzExtResourceType } from '../../../AzExtResourceType'; +import { AzureWizard } from '../../../wizard/AzureWizard'; -export async function appResourceExperience(context: types.IActionContext, tdp: vscode.TreeDataProvider, resourceType: types.AzExtResourceType, childItemFilter?: ContextValueFilter): Promise { - const promptSteps: types.AzureWizardPromptStep[] = [ +export async function appResourceExperience(context: IActionContext, tdp: vscode.TreeDataProvider, resourceType: AzExtResourceType, childItemFilter?: ContextValueFilter): Promise { + const promptSteps: AzureWizardPromptStep[] = [ new QuickPickAzureSubscriptionStep(tdp), new QuickPickGroupStep(tdp, { groupType: resourceType, @@ -38,7 +41,7 @@ export async function appResourceExperience(context: types.IActionContext const wizardContext = context as AzureResourceQuickPickWizardContext; wizardContext.pickedNodes = []; - const wizard = new types.AzureWizard(context, { + const wizard = new AzureWizard(context, { hideStepCount: true, promptSteps: promptSteps, }); diff --git a/utils/src/treev2/quickPickWizard/experiences/contextValueExperience.ts b/utils/src/treev2/quickPickWizard/experiences/contextValueExperience.ts index 570fa14cc8..bd6bd591f6 100644 --- a/utils/src/treev2/quickPickWizard/experiences/contextValueExperience.ts +++ b/utils/src/treev2/quickPickWizard/experiences/contextValueExperience.ts @@ -3,15 +3,17 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as types from '../../../../index'; import * as vscode from 'vscode'; import { ContextValueFilter, ContextValueFilterableTreeNode } from '../ContextValueQuickPickStep'; import { RecursiveQuickPickStep } from '../RecursiveQuickPickStep'; import { getLastNode, QuickPickWizardContext } from '../QuickPickWizardContext'; import { NoResourceFoundError } from '../../../errors'; +import { AzureWizardPromptStep } from '../../../wizard/AzureWizardPromptStep'; +import { IActionContext } from '../../../../index'; +import { AzureWizard } from '../../../wizard/AzureWizard'; -export async function contextValueExperience(context: types.IActionContext, tdp: vscode.TreeDataProvider, contextValueFilter: ContextValueFilter): Promise { - const promptSteps: types.AzureWizardPromptStep>[] = [ +export async function contextValueExperience(context: IActionContext, tdp: vscode.TreeDataProvider, contextValueFilter: ContextValueFilter): Promise { + const promptSteps: AzureWizardPromptStep>[] = [ new RecursiveQuickPickStep(tdp, { contextValueFilter: contextValueFilter, skipIfOne: false, @@ -22,7 +24,7 @@ export async function contextValueExperience; wizardContext.pickedNodes = []; - const wizard = new types.AzureWizard(context, { + const wizard = new AzureWizard(context, { hideStepCount: true, promptSteps: promptSteps, }); From 99b023bac7e47e25009ace750af53758bcdf67df Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Tue, 6 Sep 2022 15:01:22 -0700 Subject: [PATCH 05/15] Move some types from tempTypes.ts to dedicated types files --- utils/hostapi.v2.d.ts | 31 ++++++++++++++++++- utils/index.d.ts | 4 ++- utils/src/index.ts | 1 + .../ContextValueQuickPickStep.ts | 29 +---------------- .../quickPickWizard/FindByIdQuickPickStep.ts | 3 +- .../QuickPickWithCreateStep.ts | 3 +- .../quickPickWizard/RecursiveQuickPickStep.ts | 3 +- .../experiences/appResourceExperience.ts | 9 ++---- .../experiences/contextValueExperience.ts | 2 +- .../AzureResourceQuickPickWizardContext.ts | 3 +- .../QuickPickAppResourceStep.ts | 4 +-- .../QuickPickAzureResourceGroupStep.ts | 3 +- .../QuickPickAzureSubscriptionStep.ts | 3 +- .../QuickPickGroupStep.ts | 3 +- .../quickPickAzureResource/tempTypes.ts | 4 +-- 15 files changed, 55 insertions(+), 50 deletions(-) diff --git a/utils/hostapi.v2.d.ts b/utils/hostapi.v2.d.ts index de5e6d886e..be64645254 100644 --- a/utils/hostapi.v2.d.ts +++ b/utils/hostapi.v2.d.ts @@ -1,4 +1,4 @@ -import { IActionContext } from "./index"; +import { AzExtTreeItem, IActionContext } from "./index"; /** * Interface describing an object that wraps another object. @@ -29,3 +29,32 @@ export type TreeNodeCommandCallback = (context: IActionContext, node?: T, nod * NOTE: If the environment variable `DEBUGTELEMETRY` is set to a non-empty, non-zero value, then telemetry will not be sent. If the value is 'verbose' or 'v', telemetry will be displayed in the console window. */ export declare function registerCommandWithTreeNodeUnboxing(commandId: string, callback: TreeNodeCommandCallback, debounce?: number, telemetryId?: string): void; + +/** + * Describes filtering based on context value. Items that pass the filter will + * match at least one of the `include` filters, but none of the `exclude` filters. + */ +export interface ContextValueFilter { + /** + * This filter will include items that match *any* of the values in the array. + * When a string is used, exact value comparison is done. + */ + include: string | RegExp | (string | RegExp)[]; + + /** + * This filter will exclude items that match *any* of the values in the array. + * When a string is used, exact value comparison is done. + */ + exclude?: string | RegExp | (string | RegExp)[]; +} + +export interface ContextValueFilterableTreeNodeV2 { + readonly quickPickOptions: { + readonly contextValues: Array; + readonly isLeaf: boolean; + } +} + +export type ContextValueFilterableTreeNode = ContextValueFilterableTreeNodeV2 | AzExtTreeItem; + +export type ResourceGroupsItem = ContextValueFilterableTreeNode; diff --git a/utils/index.d.ts b/utils/index.d.ts index 7fccf64a8f..b88bb98c6e 100644 --- a/utils/index.d.ts +++ b/utils/index.d.ts @@ -10,7 +10,7 @@ import { CancellationToken, CancellationTokenSource, Disposable, Event, Extensio import { TargetPopulation } from 'vscode-tas-client'; import { AzureExtensionApi, AzureExtensionApiProvider } from './api'; import type { Activity, ActivityTreeItemOptions, AppResource, OnErrorActivityData, OnProgressActivityData, OnStartActivityData, OnSuccessActivityData } from './hostapi'; // This must remain `import type` or else a circular reference will result -import { Box } from './hostapi.v2'; +import { Box, ContextValueFilter, ResourceGroupsItem } from './hostapi.v2'; export declare interface RunWithTemporaryDescriptionOptions { description: string; @@ -1687,3 +1687,5 @@ export declare enum AzExtResourceType { * @returns True if a box, false otherwise */ export declare function isBox(maybeBox: unknown): maybeBox is Box; + +export declare function appResourceExperience(context: IActionContext, tdp: TreeDataProvider, resourceType: AzExtResourceType, childItemFilter?: ContextValueFilter): Promise; diff --git a/utils/src/index.ts b/utils/src/index.ts index 25af2ff87a..288318eddc 100644 --- a/utils/src/index.ts +++ b/utils/src/index.ts @@ -37,4 +37,5 @@ export * from './utils/contextUtils'; export * from './activityLog/activities/ExecuteActivity'; export * from './getAzExtResourceType'; export * from './AzExtResourceType'; +export * from './treev2/quickPickWizard/experiences/appResourceExperience'; // NOTE: The auto-fix action "source.organizeImports" does weird things with this file, but there doesn't seem to be a way to disable it on a per-file basis so we'll just let it happen diff --git a/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts b/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts index bf6f6d6113..842ecb9097 100644 --- a/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts +++ b/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts @@ -3,38 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as types from '../../../index'; import { GenericQuickPickOptions, GenericQuickPickStep } from './GenericQuickPickStep'; import { isAzExtParentTreeItem } from '../../tree/InternalInterfaces'; import { QuickPickWizardContext } from './QuickPickWizardContext'; import { isBox } from '../../registerCommandWithTreeNodeUnboxing'; - -/** - * Describes filtering based on context value. Items that pass the filter will - * match at least one of the `include` filters, but none of the `exclude` filters. - */ -export interface ContextValueFilter { - /** - * This filter will include items that match *any* of the values in the array. - * When a string is used, exact value comparison is done. - */ - include: string | RegExp | (string | RegExp)[]; - - /** - * This filter will exclude items that match *any* of the values in the array. - * When a string is used, exact value comparison is done. - */ - exclude?: string | RegExp | (string | RegExp)[]; -} - -export interface ContextValueFilterableTreeNodeV2 { - readonly quickPickOptions: { - readonly contextValues: Array; - readonly isLeaf: boolean; - } -} - -export type ContextValueFilterableTreeNode = ContextValueFilterableTreeNodeV2 | types.AzExtTreeItem; +import { ContextValueFilter, ContextValueFilterableTreeNode, ContextValueFilterableTreeNodeV2 } from '../../../hostapi.v2'; export interface ContextValueFilterQuickPickOptions extends GenericQuickPickOptions { contextValueFilter: ContextValueFilter; diff --git a/utils/src/treev2/quickPickWizard/FindByIdQuickPickStep.ts b/utils/src/treev2/quickPickWizard/FindByIdQuickPickStep.ts index cf56e2c5fe..edbcbc4497 100644 --- a/utils/src/treev2/quickPickWizard/FindByIdQuickPickStep.ts +++ b/utils/src/treev2/quickPickWizard/FindByIdQuickPickStep.ts @@ -7,8 +7,9 @@ import * as types from '../../../index'; import * as vscode from 'vscode'; import { getLastNode, QuickPickWizardContext } from './QuickPickWizardContext'; import { isAzExtParentTreeItem } from '../../tree/InternalInterfaces'; -import { ContextValueFilterableTreeNodeV2, isContextValueFilterableTreeNodeV2 } from './ContextValueQuickPickStep'; +import { isContextValueFilterableTreeNodeV2 } from './ContextValueQuickPickStep'; import { GenericQuickPickStep, SkipIfOneQuickPickOptions } from './GenericQuickPickStep'; +import { ContextValueFilterableTreeNodeV2 } from '../../../hostapi.v2'; interface FindableByIdTreeNodeV2 extends ContextValueFilterableTreeNodeV2 { id: vscode.Uri; diff --git a/utils/src/treev2/quickPickWizard/QuickPickWithCreateStep.ts b/utils/src/treev2/quickPickWizard/QuickPickWithCreateStep.ts index a7e7fa36a1..e076d7fede 100644 --- a/utils/src/treev2/quickPickWizard/QuickPickWithCreateStep.ts +++ b/utils/src/treev2/quickPickWizard/QuickPickWithCreateStep.ts @@ -5,8 +5,9 @@ import * as types from '../../../index'; import { getLastNode, QuickPickWizardContext } from './QuickPickWizardContext'; -import { ContextValueFilterableTreeNode, ContextValueFilterQuickPickOptions, ContextValueQuickPickStep } from './ContextValueQuickPickStep'; +import { ContextValueFilterQuickPickOptions, ContextValueQuickPickStep } from './ContextValueQuickPickStep'; import { localize } from '../../localize'; +import { ContextValueFilterableTreeNode } from '../../../hostapi.v2'; type CreateCallback = () => TNode | Promise; interface CreateQuickPickOptions extends ContextValueFilterQuickPickOptions { diff --git a/utils/src/treev2/quickPickWizard/RecursiveQuickPickStep.ts b/utils/src/treev2/quickPickWizard/RecursiveQuickPickStep.ts index 0456b7e632..56050f7738 100644 --- a/utils/src/treev2/quickPickWizard/RecursiveQuickPickStep.ts +++ b/utils/src/treev2/quickPickWizard/RecursiveQuickPickStep.ts @@ -3,8 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { ContextValueFilterableTreeNode } from '../../../hostapi.v2'; import * as types from '../../../index'; -import { ContextValueFilterableTreeNode, ContextValueFilterQuickPickOptions, ContextValueQuickPickStep } from './ContextValueQuickPickStep'; +import { ContextValueFilterQuickPickOptions, ContextValueQuickPickStep } from './ContextValueQuickPickStep'; import { getLastNode, QuickPickWizardContext } from './QuickPickWizardContext'; export class RecursiveQuickPickStep> extends ContextValueQuickPickStep { diff --git a/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts b/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts index f19dde4f64..6aa8460142 100644 --- a/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts +++ b/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts @@ -4,19 +4,18 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { ContextValueFilter } from '../ContextValueQuickPickStep'; import { QuickPickAzureSubscriptionStep } from '../quickPickAzureResource/QuickPickAzureSubscriptionStep'; import { QuickPickGroupStep } from '../quickPickAzureResource/QuickPickGroupStep'; import { QuickPickAppResourceStep } from '../quickPickAzureResource/QuickPickAppResourceStep'; import { AzureResourceQuickPickWizardContext } from '../quickPickAzureResource/AzureResourceQuickPickWizardContext'; import { RecursiveQuickPickStep } from '../RecursiveQuickPickStep'; -import { Box, ResourceGroupsItem } from '../quickPickAzureResource/tempTypes'; import { getLastNode } from '../QuickPickWizardContext'; import { NoResourceFoundError } from '../../../errors'; import { IActionContext } from '../../../../index'; import { AzureWizardPromptStep } from '../../../wizard/AzureWizardPromptStep'; import { AzExtResourceType } from '../../../AzExtResourceType'; import { AzureWizard } from '../../../wizard/AzureWizard'; +import { Box, ContextValueFilter, ResourceGroupsItem } from '../../../../hostapi.v2'; export async function appResourceExperience(context: IActionContext, tdp: vscode.TreeDataProvider, resourceType: AzExtResourceType, childItemFilter?: ContextValueFilter): Promise { const promptSteps: AzureWizardPromptStep[] = [ @@ -53,9 +52,7 @@ export async function appResourceExperience(context: IActionContext, tdp: if (!lastPickedItem) { throw new NoResourceFoundError(wizardContext); } else { - // Treat lastPickedItem as a box containing the desired end object - // TODO - const pickedAsBox = lastPickedItem as unknown as Box; - return pickedAsBox.unwrap(); + const pickedAsBox = lastPickedItem as unknown as Box; + return pickedAsBox.unwrap(); } } diff --git a/utils/src/treev2/quickPickWizard/experiences/contextValueExperience.ts b/utils/src/treev2/quickPickWizard/experiences/contextValueExperience.ts index bd6bd591f6..24f672d46f 100644 --- a/utils/src/treev2/quickPickWizard/experiences/contextValueExperience.ts +++ b/utils/src/treev2/quickPickWizard/experiences/contextValueExperience.ts @@ -4,13 +4,13 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { ContextValueFilter, ContextValueFilterableTreeNode } from '../ContextValueQuickPickStep'; import { RecursiveQuickPickStep } from '../RecursiveQuickPickStep'; import { getLastNode, QuickPickWizardContext } from '../QuickPickWizardContext'; import { NoResourceFoundError } from '../../../errors'; import { AzureWizardPromptStep } from '../../../wizard/AzureWizardPromptStep'; import { IActionContext } from '../../../../index'; import { AzureWizard } from '../../../wizard/AzureWizard'; +import { ContextValueFilter, ContextValueFilterableTreeNode } from '../../../../hostapi.v2'; export async function contextValueExperience(context: IActionContext, tdp: vscode.TreeDataProvider, contextValueFilter: ContextValueFilter): Promise { const promptSteps: AzureWizardPromptStep>[] = [ diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/AzureResourceQuickPickWizardContext.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/AzureResourceQuickPickWizardContext.ts index be86bd9dd6..9c6e6d0ba0 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/AzureResourceQuickPickWizardContext.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/AzureResourceQuickPickWizardContext.ts @@ -3,8 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { ResourceGroupsItem } from "../../../../hostapi.v2"; import { QuickPickWizardContext } from "../QuickPickWizardContext"; -import { ApplicationResource, ApplicationSubscription, ResourceGroupsItem } from "./tempTypes"; +import { ApplicationResource, ApplicationSubscription } from "./tempTypes"; export interface AzureResourceQuickPickWizardContext extends QuickPickWizardContext { subscription: ApplicationSubscription | undefined; diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts index 0e076c6aff..b7d43ac2df 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts @@ -3,11 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { ContextValueFilter, ResourceGroupsItem } from '../../../../hostapi.v2'; import * as types from '../../../../index'; -import { ContextValueFilter } from '../ContextValueQuickPickStep'; import { GenericQuickPickOptions, GenericQuickPickStep } from '../GenericQuickPickStep'; import { AzureResourceQuickPickWizardContext } from './AzureResourceQuickPickWizardContext'; -import { AppResourceItem, ResourceGroupsItem } from './tempTypes'; +import { AppResourceItem } from './tempTypes'; interface AppResourceQuickPickOptions extends GenericQuickPickOptions { resourceType: types.AzExtResourceType; diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAzureResourceGroupStep.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAzureResourceGroupStep.ts index 31c8052ada..9bd31b4ddb 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAzureResourceGroupStep.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAzureResourceGroupStep.ts @@ -3,11 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { ResourceGroupsItem, ContextValueFilterableTreeNode } from "../../../../hostapi.v2"; import * as types from "../../../../index"; -import { ContextValueFilterableTreeNode } from "../ContextValueQuickPickStep"; import { GenericQuickPickOptions, GenericQuickPickStep } from "../GenericQuickPickStep"; import { AzureResourceQuickPickWizardContext } from "./AzureResourceQuickPickWizardContext"; -import { ResourceGroupsItem } from "./tempTypes"; // TODO: implement this for picking resource group // The resource group may NOT be the grouping method used in the tree diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAzureSubscriptionStep.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAzureSubscriptionStep.ts index 7cbbfdad0e..34e6d1b245 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAzureSubscriptionStep.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAzureSubscriptionStep.ts @@ -4,9 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; +import { ResourceGroupsItem } from '../../../../hostapi.v2'; import { GenericQuickPickOptions, GenericQuickPickStep, SkipIfOneQuickPickOptions } from '../GenericQuickPickStep'; import { AzureResourceQuickPickWizardContext } from './AzureResourceQuickPickWizardContext'; -import { ResourceGroupsItem, SubscriptionItem } from './tempTypes'; +import { SubscriptionItem } from './tempTypes'; export class QuickPickAzureSubscriptionStep extends GenericQuickPickStep { public constructor(tdp: vscode.TreeDataProvider, options?: GenericQuickPickOptions) { diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickGroupStep.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickGroupStep.ts index f2633c1a7d..4cd292917d 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickGroupStep.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickGroupStep.ts @@ -7,7 +7,8 @@ import * as types from '../../../../index'; import * as vscode from 'vscode'; import { GenericQuickPickStep, SkipIfOneQuickPickOptions } from '../GenericQuickPickStep'; import { AzureResourceQuickPickWizardContext } from './AzureResourceQuickPickWizardContext'; -import { GroupingItem, ResourceGroupsItem } from './tempTypes'; +import { GroupingItem } from './tempTypes'; +import { ResourceGroupsItem } from '../../../../hostapi.v2'; interface GroupQuickPickOptions extends SkipIfOneQuickPickOptions { groupType: types.AzExtResourceType; diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/tempTypes.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/tempTypes.ts index 4a4a5d258f..78f8a1941f 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/tempTypes.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/tempTypes.ts @@ -3,14 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { ResourceGroupsItem } from '../../../../hostapi.v2'; import * as types from '../../../../index'; -import { ContextValueFilterableTreeNode } from '../ContextValueQuickPickStep'; // TODO: THIS FILE IS TEMPORARY // // It needs to be replaced by real Resources extension interfaces // -export type ResourceGroupsItem = ContextValueFilterableTreeNode; - export type SubscriptionItem = ResourceGroupsItem & { subscription: ApplicationSubscription; }; From 46d0291f483aaecf110e8fe656cf56ab02ebb605 Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Tue, 6 Sep 2022 15:35:50 -0700 Subject: [PATCH 06/15] Add `fallbackToAll` option to GenericQuickPickStep Falls back to show all children if no children are direct/indirect picks --- utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts | 7 ++++++- .../quickPickAzureResource/QuickPickGroupStep.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts b/utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts index 450d4218a4..5d98a1333f 100644 --- a/utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts +++ b/utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts @@ -12,6 +12,7 @@ import { parseError } from '../../parseError'; export interface GenericQuickPickOptions { skipIfOne?: boolean; + fallbackToAll?: boolean; } export interface SkipIfOneQuickPickOptions extends GenericQuickPickOptions { @@ -72,7 +73,11 @@ export abstract class GenericQuickPickStep Date: Tue, 6 Sep 2022 15:36:13 -0700 Subject: [PATCH 07/15] Unwrap AppResourceItem nodes --- .../quickPickAzureResource/QuickPickAppResourceStep.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts index b7d43ac2df..7d0e8e563b 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts @@ -5,6 +5,7 @@ import { ContextValueFilter, ResourceGroupsItem } from '../../../../hostapi.v2'; import * as types from '../../../../index'; +import { isBox } from '../../../registerCommandWithTreeNodeUnboxing'; import { GenericQuickPickOptions, GenericQuickPickStep } from '../GenericQuickPickStep'; import { AzureResourceQuickPickWizardContext } from './AzureResourceQuickPickWizardContext'; import { AppResourceItem } from './tempTypes'; @@ -26,6 +27,9 @@ export class QuickPickAppResourceStep extends GenericQuickPickStep Date: Tue, 6 Sep 2022 15:46:35 -0700 Subject: [PATCH 08/15] Remove duplicate `Box` declaration --- .../quickPickWizard/quickPickAzureResource/tempTypes.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/tempTypes.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/tempTypes.ts index 78f8a1941f..fc19a30038 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/tempTypes.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/tempTypes.ts @@ -32,7 +32,3 @@ export interface ApplicationResource extends ResourceBase { } export type ApplicationSubscription = unknown; - -export interface Box { - unwrap(): T; -} From 25108cd6d1d0adb94bf8ba0f3882559d5642fdcd Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Tue, 6 Sep 2022 16:03:10 -0700 Subject: [PATCH 09/15] Cleanup types --- utils/hostapi.v2.d.ts | 50 +++++++++++++++++++ .../AzureResourceQuickPickWizardContext.ts | 9 ++-- .../QuickPickAppResourceStep.ts | 8 +-- .../quickPickAzureResource/tempTypes.ts | 24 +++------ 4 files changed, 65 insertions(+), 26 deletions(-) diff --git a/utils/hostapi.v2.d.ts b/utils/hostapi.v2.d.ts index 474ebbb4a3..0b1cb8a1e5 100644 --- a/utils/hostapi.v2.d.ts +++ b/utils/hostapi.v2.d.ts @@ -1,4 +1,54 @@ +/*--------------------------------------------------------------------------------------------- +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. See License.txt in the project root for license information. +*--------------------------------------------------------------------------------------------*/ + import { AzExtTreeItem, IActionContext } from "./index"; +import * as vscode from 'vscode'; +import type { Environment } from '@azure/ms-rest-azure-env'; +import { AzExtResourceType } from "./src/AzExtResourceType"; + +export interface ApplicationAuthentication { + getSession(scopes?: string[]): vscode.ProviderResult; +} + +/** + * Information specific to the Subscription + */ +export interface ApplicationSubscription { + readonly authentication: ApplicationAuthentication; + readonly displayName: string; + readonly subscriptionId: string; + readonly environment: Environment; + readonly isCustomCloud: boolean; +} + +export interface ResourceBase { + readonly id: string; + readonly name: string; +} + +export interface ApplicationResourceType { + readonly type: string; + readonly kinds?: string[]; +} + +/** + * Represents an individual resource in Azure. + * @remarks The `id` property is expected to be the Azure resource ID. + */ +export interface ApplicationResource extends ResourceBase { + readonly subscription: ApplicationSubscription; + readonly type: ApplicationResourceType; + readonly azExtResourceType?: AzExtResourceType; + readonly location?: string; + readonly resourceGroup?: string; + /** Resource tags */ + readonly tags?: { + [propertyName: string]: string; + }; + /* add more properties from GenericResource if needed */ +} /** * Interface describing an object that wraps another object. diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/AzureResourceQuickPickWizardContext.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/AzureResourceQuickPickWizardContext.ts index 9c6e6d0ba0..64fc5ae076 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/AzureResourceQuickPickWizardContext.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/AzureResourceQuickPickWizardContext.ts @@ -3,12 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ResourceGroupsItem } from "../../../../hostapi.v2"; +import { ApplicationResource, ApplicationSubscription, ResourceGroupsItem } from "../../../../hostapi.v2"; import { QuickPickWizardContext } from "../QuickPickWizardContext"; -import { ApplicationResource, ApplicationSubscription } from "./tempTypes"; export interface AzureResourceQuickPickWizardContext extends QuickPickWizardContext { - subscription: ApplicationSubscription | undefined; - resource: ApplicationResource | undefined; - resourceGroup: string | undefined; + subscription?: ApplicationSubscription; + resource?: ApplicationResource; + resourceGroup?: string; } diff --git a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts index 7d0e8e563b..2cb9256cfe 100644 --- a/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts +++ b/utils/src/treev2/quickPickWizard/quickPickAzureResource/QuickPickAppResourceStep.ts @@ -20,8 +20,8 @@ export class QuickPickAppResourceStep extends GenericQuickPickStep Date: Wed, 7 Sep 2022 11:38:40 -0700 Subject: [PATCH 10/15] Use import type --- utils/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/index.d.ts b/utils/index.d.ts index 62d97ddbe5..37a47b6d09 100644 --- a/utils/index.d.ts +++ b/utils/index.d.ts @@ -10,7 +10,7 @@ import { CancellationToken, CancellationTokenSource, Disposable, Event, Extensio import { TargetPopulation } from 'vscode-tas-client'; import { AzureExtensionApi, AzureExtensionApiProvider } from './api'; import type { Activity, ActivityTreeItemOptions, AppResource, OnErrorActivityData, OnProgressActivityData, OnStartActivityData, OnSuccessActivityData } from './hostapi'; // This must remain `import type` or else a circular reference will result -import { Box, ContextValueFilter, ResourceGroupsItem, TreeNodeCommandCallback } from './hostapi.v2'; +import type { Box, ContextValueFilter, ResourceGroupsItem, TreeNodeCommandCallback } from './hostapi.v2'; export declare interface RunWithTemporaryDescriptionOptions { description: string; From aa472140ae077e2276aedf13665e6308a1e6fdba Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Wed, 7 Sep 2022 11:53:10 -0700 Subject: [PATCH 11/15] Check `isBox` --- .../quickPickWizard/experiences/appResourceExperience.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts b/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts index 6aa8460142..9d388c0f03 100644 --- a/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts +++ b/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts @@ -15,7 +15,8 @@ import { IActionContext } from '../../../../index'; import { AzureWizardPromptStep } from '../../../wizard/AzureWizardPromptStep'; import { AzExtResourceType } from '../../../AzExtResourceType'; import { AzureWizard } from '../../../wizard/AzureWizard'; -import { Box, ContextValueFilter, ResourceGroupsItem } from '../../../../hostapi.v2'; +import { ContextValueFilter, ResourceGroupsItem } from '../../../../hostapi.v2'; +import { isBox } from '../../../registerCommandWithTreeNodeUnboxing'; export async function appResourceExperience(context: IActionContext, tdp: vscode.TreeDataProvider, resourceType: AzExtResourceType, childItemFilter?: ContextValueFilter): Promise { const promptSteps: AzureWizardPromptStep[] = [ @@ -52,7 +53,6 @@ export async function appResourceExperience(context: IActionContext, tdp: if (!lastPickedItem) { throw new NoResourceFoundError(wizardContext); } else { - const pickedAsBox = lastPickedItem as unknown as Box; - return pickedAsBox.unwrap(); + return isBox(lastPickedItem) ? lastPickedItem.unwrap() : lastPickedItem as TPick; } } From a51abaf89b682b89ddb0777b1f35291f7cc28d12 Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Wed, 7 Sep 2022 12:04:26 -0700 Subject: [PATCH 12/15] Add comment to temp type --- utils/hostapi.v2.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/hostapi.v2.d.ts b/utils/hostapi.v2.d.ts index 0b1cb8a1e5..0405211ab8 100644 --- a/utils/hostapi.v2.d.ts +++ b/utils/hostapi.v2.d.ts @@ -97,4 +97,5 @@ export interface ContextValueFilterableTreeNodeV2 { export type ContextValueFilterableTreeNode = ContextValueFilterableTreeNodeV2 | AzExtTreeItem; +// temporary type until we have the real type from RGs export type ResourceGroupsItem = ContextValueFilterableTreeNode; From 0a89e5640bcc08a8459d96e6129be6ea75cced28 Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Wed, 7 Sep 2022 12:11:27 -0700 Subject: [PATCH 13/15] Fixup --- .../treev2/quickPickWizard/experiences/appResourceExperience.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts b/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts index 9d388c0f03..f12e596e1e 100644 --- a/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts +++ b/utils/src/treev2/quickPickWizard/experiences/appResourceExperience.ts @@ -53,6 +53,6 @@ export async function appResourceExperience(context: IActionContext, tdp: if (!lastPickedItem) { throw new NoResourceFoundError(wizardContext); } else { - return isBox(lastPickedItem) ? lastPickedItem.unwrap() : lastPickedItem as TPick; + return isBox(lastPickedItem) ? lastPickedItem.unwrap() : lastPickedItem as unknown as TPick; } } From 6d16a41bbf7587964c1da2728e624580ff2283a3 Mon Sep 17 00:00:00 2001 From: Alex Weininger Date: Wed, 7 Sep 2022 12:27:34 -0700 Subject: [PATCH 14/15] Only unwrap at the end --- .../treev2/quickPickWizard/ContextValueQuickPickStep.ts | 3 --- .../quickPickAzureResource/QuickPickAppResourceStep.ts | 7 ------- 2 files changed, 10 deletions(-) diff --git a/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts b/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts index 842ecb9097..5a787fb937 100644 --- a/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts +++ b/utils/src/treev2/quickPickWizard/ContextValueQuickPickStep.ts @@ -6,7 +6,6 @@ import { GenericQuickPickOptions, GenericQuickPickStep } from './GenericQuickPickStep'; import { isAzExtParentTreeItem } from '../../tree/InternalInterfaces'; import { QuickPickWizardContext } from './QuickPickWizardContext'; -import { isBox } from '../../registerCommandWithTreeNodeUnboxing'; import { ContextValueFilter, ContextValueFilterableTreeNode, ContextValueFilterableTreeNodeV2 } from '../../../hostapi.v2'; export interface ContextValueFilterQuickPickOptions extends GenericQuickPickOptions { @@ -23,8 +22,6 @@ export class ContextValueQuickPickStep Date: Wed, 7 Sep 2022 12:28:27 -0700 Subject: [PATCH 15/15] Remove `fallbackToAll` option --- utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts | 7 +------ .../quickPickAzureResource/QuickPickGroupStep.ts | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts b/utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts index 5d98a1333f..450d4218a4 100644 --- a/utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts +++ b/utils/src/treev2/quickPickWizard/GenericQuickPickStep.ts @@ -12,7 +12,6 @@ import { parseError } from '../../parseError'; export interface GenericQuickPickOptions { skipIfOne?: boolean; - fallbackToAll?: boolean; } export interface SkipIfOneQuickPickOptions extends GenericQuickPickOptions { @@ -73,11 +72,7 @@ export abstract class GenericQuickPickStep