Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start implementation of compat shim #358

Merged
merged 87 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
9b165fc
Start implementation of compat shim
bwateratmsft Aug 10, 2022
37bc0f2
Minor edits
bwateratmsft Aug 11, 2022
1f016b4
Merge branch 'philliphoff-resource-api' into bmw/philliphoff-resource…
bwateratmsft Aug 15, 2022
224f71a
Add subscription info
bwateratmsft Aug 15, 2022
46f86f3
Minor changes to API
bwateratmsft Aug 15, 2022
6329934
Minor change
bwateratmsft Aug 15, 2022
871c257
Merge branch 'api-v2' into bmw/philliphoff-resource-api-compatshim
bwateratmsft Sep 8, 2022
08c9b83
Current changes
bwateratmsft Sep 8, 2022
75acdd9
Comment addition
bwateratmsft Sep 8, 2022
b4711b4
Commit rough progress
bwateratmsft Sep 9, 2022
f1eefe3
Renaming to wrapper
bwateratmsft Sep 9, 2022
caa0ab2
More renaming
bwateratmsft Sep 9, 2022
a10244e
Add `CompatibleBranchDataItem` (#381)
alexweininger Sep 23, 2022
b26ecf8
Merge remote-tracking branch 'origin/api-v2' into bmw/philliphoff-res…
alexweininger Oct 5, 2022
84674c8
Fixup
alexweininger Oct 5, 2022
d69a4ac
Remove `quickPickOptions`
bwateratmsft Oct 6, 2022
82a8e02
Make `pickAppResource` compatible with Tree API v2 (#382)
alexweininger Oct 6, 2022
fe7545a
Fix import
alexweininger Oct 12, 2022
efdcaf3
Workspace tree compatibility (#398)
alexweininger Oct 13, 2022
f539058
Expose `TreeDataProvider`s in API (#402)
alexweininger Oct 13, 2022
fafa95f
Merge remote-tracking branch 'origin/api-v2' into bmw/philliphoff-res…
alexweininger Oct 13, 2022
14fc525
Merge remote-tracking branch 'origin/api-v2' into bmw/philliphoff-res…
alexweininger Oct 13, 2022
02a386e
Stop registering V1 views
alexweininger Oct 13, 2022
22f9a24
Add "Create Resource" to view title
alexweininger Oct 14, 2022
ef91972
Merge remote-tracking branch 'origin/api-v2' into bmw/philliphoff-res…
alexweininger Oct 15, 2022
96fb245
Add refresh capabilities to `CompatibleBranchDataProvider` (#406)
alexweininger Oct 18, 2022
3a4a4b5
refresh workspace
alexweininger Oct 19, 2022
b2c41c5
Fix duplicate resources
alexweininger Oct 19, 2022
dd0f916
Merge remote-tracking branch 'origin/api-v2' into bmw/philliphoff-res…
alexweininger Oct 19, 2022
846bac2
Fixups
alexweininger Oct 19, 2022
84e0639
Change view Ids to match V1 (#408)
alexweininger Oct 19, 2022
4796fd6
Use `CompatibleAzExtTreeDataProvider` (#409)
alexweininger Oct 19, 2022
45820ec
Fix pick subscription
alexweininger Oct 19, 2022
94cf8d5
Fix type create commands
alexweininger Oct 19, 2022
99f353b
Cleanup unused extension variable
alexweininger Oct 19, 2022
82b3e7c
Remove unneeded void
alexweininger Nov 3, 2022
3ff193b
Merge remote-tracking branch 'origin/api-v2' into bmw/philliphoff-res…
alexweininger Nov 9, 2022
bf6f6de
Improve errors in `CompatibleAzExtTreeDataProvider`
alexweininger Nov 10, 2022
6eed795
Reset unneeded changes
alexweininger Nov 10, 2022
91d89ee
Better rrganize compatibility source files
alexweininger Nov 10, 2022
5717bb8
Merge remote-tracking branch 'origin/api-v2' into bmw/philliphoff-res…
alexweininger Nov 10, 2022
725f52f
Improve types
alexweininger Nov 16, 2022
acc1978
Fix cast
alexweininger Nov 16, 2022
4867558
Add telemetry event for register application resource resolver
alexweininger Nov 16, 2022
7f4e321
Remove `_` prefix
alexweininger Nov 16, 2022
1c5ffab
Fix refresh command
alexweininger Nov 18, 2022
1a8f4c1
Fix removeChildFromCache
alexweininger Nov 18, 2022
5f7d85e
Pickup latest tools changes
alexweininger Nov 29, 2022
4cc2823
Merge branch 'api-v2' into bmw/philliphoff-resource-api-compatshim
alexweininger Nov 29, 2022
ff0db98
Register azure tree
alexweininger Nov 30, 2022
eca2a4f
Cleanup tree registration
alexweininger Nov 30, 2022
866b1a5
Merge branch 'api-v2' into alex/api-v2-register-trees
alexweininger Nov 30, 2022
db482a2
Delete unused file
alexweininger Nov 30, 2022
8d89322
Fix option interface name
alexweininger Nov 30, 2022
c7f2f26
Call `refreshWorkspace`
alexweininger Nov 30, 2022
b57f8fa
Fixup
alexweininger Nov 30, 2022
6646d07
Merge branch 'alex/api-v2-register-trees' into bmw/philliphoff-resour…
alexweininger Nov 30, 2022
9b8ae75
Fixups
alexweininger Nov 30, 2022
0a0541f
Fixup
alexweininger Nov 30, 2022
9731eca
Don't expose EventEmitter
alexweininger Nov 30, 2022
fb898ec
Use AzExtResourceType
alexweininger Nov 30, 2022
e29a827
Merge branch 'api-v2' into bmw/philliphoff-resource-api-compatshim
alexweininger Nov 30, 2022
1d1a95f
Fixup
alexweininger Nov 30, 2022
46f0560
Don't use tools
alexweininger Nov 30, 2022
aeac586
Update utils
alexweininger Nov 30, 2022
4c651d9
Remove fs-extra
alexweininger Nov 30, 2022
373f24b
Don't expose `ResourceGroupsItem` in api
alexweininger Nov 30, 2022
c9245bb
Use this instead of super
alexweininger Nov 30, 2022
1f13782
Revert changes to createResource.ts
alexweininger Nov 30, 2022
610676a
Merge branch 'api-v2' into bmw/philliphoff-resource-api-compatshim
alexweininger Dec 1, 2022
5f08aea
Merge branch 'api-v2' into bmw/philliphoff-resource-api-compatshim
alexweininger Dec 1, 2022
6dbec20
Update src/api/v2/compatibility/application/CompatibleApplicationReso…
alexweininger Dec 2, 2022
73da5d9
Combine disposables
alexweininger Dec 6, 2022
b2c992d
Combine disposables
alexweininger Dec 6, 2022
f0acea1
Update todo comment
alexweininger Dec 6, 2022
8024ea8
Remove reveal temporarily
alexweininger Dec 6, 2022
2ed6bd4
Merge branch 'api-v2' into bmw/philliphoff-resource-api-compatshim
alexweininger Dec 6, 2022
84ec52b
Fixup refresh tree emitters
alexweininger Dec 6, 2022
253fd53
Add compat comment
alexweininger Dec 6, 2022
82e9391
Add comment
alexweininger Dec 6, 2022
0b5494d
Use common context value util
alexweininger Dec 6, 2022
29dd9f8
Fixup refresh workspace
alexweininger Dec 6, 2022
a217028
Fixup register resolver
alexweininger Dec 6, 2022
e5189f9
Make emitter private
alexweininger Dec 6, 2022
220ecef
Update comment
alexweininger Dec 6, 2022
dc172ce
Merge branch 'api-v2' into bmw/philliphoff-resource-api-compatshim
alexweininger Dec 6, 2022
b9588be
import types from published package
alexweininger Dec 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/api/registerApplicationResourceResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzExtResourceType, AzExtTreeItem, callWithTelemetryAndErrorHandlingSync } from "@microsoft/vscode-azext-utils";
import { AppResourceResolver } from "@microsoft/vscode-azext-utils/hostapi";
import { AzureResourceBranchDataProvider } from "@microsoft/vscode-azext-utils/hostapi.v2";
import { Disposable } from "vscode";
import { ext } from "../extensionVariables";
import { CompatibleApplicationResourceBranchDataProvider } from "./v2/compatibility/application/CompatibleApplicationResourceBranchDataProvider";

export const applicationResourceResolvers: Record<string, AppResourceResolver> = {};
export const applicationResourceResolvers: Partial<Record<AzExtResourceType, AppResourceResolver>> = {};

export function registerApplicationResourceResolver(id: string, resolver: AppResourceResolver): Disposable {
if (applicationResourceResolvers[id]) {
throw new Error(`Application resource resolver with id '${id}' has already been registered.`);
}
export function registerApplicationResourceResolver(type: AzExtResourceType, resolver: AppResourceResolver): Disposable {
return callWithTelemetryAndErrorHandlingSync('registerApplicationResourceResolver', () => {
if (applicationResourceResolvers[type]) {
throw new Error(`Application resource resolver with id '${type}' has already been registered.`);
alexweininger marked this conversation as resolved.
Show resolved Hide resolved
}

applicationResourceResolvers[id] = resolver;
ext.emitters.onDidRegisterResolver.fire(resolver);
applicationResourceResolvers[type] = resolver;
ext.emitters.onDidRegisterResolver.fire(resolver);

return new Disposable(() => {
delete applicationResourceResolvers[id];
});
const compat = new CompatibleApplicationResourceBranchDataProvider(resolver, 'azureResourceGroups.loadMore' /** TODO: what is the correct value for this? */);
nturinski marked this conversation as resolved.
Show resolved Hide resolved
const disposable = ext.v2.api.registerAzureResourceBranchDataProvider(type, compat as unknown as AzureResourceBranchDataProvider<AzExtTreeItem>);

return new Disposable(() => {
delete applicationResourceResolvers[type];
disposable.dispose();
compat.dispose();
});
}) as Disposable;
}
20 changes: 16 additions & 4 deletions src/api/registerWorkspaceResourceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,35 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { callWithTelemetryAndErrorHandlingSync } from "@microsoft/vscode-azext-utils";
import { AzExtTreeItem, callWithTelemetryAndErrorHandlingSync } from "@microsoft/vscode-azext-utils";
import { WorkspaceResourceProvider } from "@microsoft/vscode-azext-utils/hostapi";
import { BranchDataProvider, WorkspaceResource } from "@microsoft/vscode-azext-utils/hostapi.v2";
import { Disposable } from "vscode";
import { refreshWorkspace } from "../commands/workspace/refreshWorkspace";
import { ext } from "../extensionVariables";
import { CompatibilityWorkspaceResourceProvider } from "./v2/compatibility/workspace/CompatibilityWorkspaceResourceProvider";
import { CompatibleWorkspaceResourceBranchDataProvider } from "./v2/compatibility/workspace/CompatibleWorkspaceResourceBranchDataProvider";

export const workspaceResourceProviders: Record<string, WorkspaceResourceProvider> = {};

export function registerWorkspaceResourceProvider(resourceType: string, provider: WorkspaceResourceProvider): Disposable {
workspaceResourceProviders[resourceType] = provider;

return callWithTelemetryAndErrorHandlingSync('registerWorkspaceResourceProvider', (context) => {
return callWithTelemetryAndErrorHandlingSync('registerWorkspaceResourceProvider', () => {
alexweininger marked this conversation as resolved.
Show resolved Hide resolved
const disposables: Disposable[] = [];

void refreshWorkspace(context);
refreshWorkspace();

disposables.push(ext.v2.api.registerWorkspaceResourceProvider(new CompatibilityWorkspaceResourceProvider(resourceType, provider)));
disposables.push(ext.v2.api.registerWorkspaceResourceBranchDataProvider(resourceType, new CompatibleWorkspaceResourceBranchDataProvider('azureWorkspace.loadMore') as unknown as BranchDataProvider<WorkspaceResource, AzExtTreeItem>));

return new Disposable(() => {
for (const disposable of disposables) {
disposable.dispose();
}
delete workspaceResourceProviders[resourceType];
void refreshWorkspace(context);
refreshWorkspace();
nturinski marked this conversation as resolved.
Show resolved Hide resolved
bwateratmsft marked this conversation as resolved.
Show resolved Hide resolved
});
}) as Disposable;
}

77 changes: 77 additions & 0 deletions src/api/v2/compatibility/CompatibleBranchDataProviderBase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzExtParentTreeItem, AzExtTreeDataProvider, AzExtTreeItem, IFindTreeItemContext, ITreeItemPickerContext } from "@microsoft/vscode-azext-utils";
import { BranchDataProvider, ResourceBase, ResourceModelBase } from "@microsoft/vscode-azext-utils/hostapi.v2";
import * as vscode from 'vscode';

export abstract class CompatibleBranchDataProviderBase<TResource extends ResourceBase, TModel extends AzExtTreeItem & ResourceModelBase> extends AzExtTreeDataProvider implements BranchDataProvider<TResource, TModel>, vscode.Disposable {
protected readonly overrideOnDidChangeTreeDataEmitter = new vscode.EventEmitter<TModel | undefined>();
alexweininger marked this conversation as resolved.
Show resolved Hide resolved

public constructor(loadMoreCommandId: string) {
// Using `{}` here so property assignment doesn't throw
super({} as unknown as AzExtParentTreeItem, loadMoreCommandId);
}

abstract getResourceItem(element: TResource): TModel | Thenable<TModel>;

//#region TreeDataProvider

// @ts-expect-error overriding a property with an accessor
public override get onDidChangeTreeData(): vscode.Event<TModel | undefined> {
return this.overrideOnDidChangeTreeDataEmitter.event;
alexweininger marked this conversation as resolved.
Show resolved Hide resolved
}

public override set onDidChangeTreeData(_: vscode.Event<TModel | undefined>) {
// Do nothing
}

public override getParent(_treeItem: TModel): Promise<TModel> {
throw new Error('Use the Resources extension API to do getParent');
}

public override async getChildren(treeItem: TModel & AzExtParentTreeItem): Promise<TModel[]> {
// This method is redeclared to make TypeScript happier, but it's no more than a super call with extra casts
return super.getChildren(treeItem) as Promise<TModel[]>;
}

//#endregion

//#region AzExtTreeDataProvider

public override refreshUIOnly(treeItem?: TModel): void {
// Override the default behavior to remain scoped to specific elements, like it ought
// And also, use overrideOnDidChangeTreeDataEmitter
this.overrideOnDidChangeTreeDataEmitter.fire(treeItem);
}

public override async showTreeItemPicker<T extends AzExtTreeItem>(expectedContextValues: string | RegExp | (string | RegExp)[], context: ITreeItemPickerContext & { canPickMany: true; }, startingTreeItem?: AzExtTreeItem): Promise<T[]>;
public override async showTreeItemPicker<T extends AzExtTreeItem>(_expectedContextValues: string | RegExp | (string | RegExp)[], _context: ITreeItemPickerContext, _startingTreeItem?: AzExtTreeItem): Promise<T> {
throw new Error('Use the Resources extension API to do showTreeItemPicker');
}

public override async findTreeItem<T extends AzExtTreeItem>(_fullId: string, _context: IFindTreeItemContext): Promise<T | undefined> {
throw new Error('Use the Resources extension API to do findTreeItem');
}

// TODO: this (probably?) shouldn't remain in the code we release, but will be helpful in testing to ensure we never access the root
// @ts-expect-error TypeScript is unhappy that we're overriding something that it doesn't know is secretly on the base class
private override get _rootTreeItem(): AzExtParentTreeItem {
throw new Error('The root tree item should not be accessed in a BranchDataProvider');
}

// This is assigned to in the constructor of AzExtTreeDataProvider
// @ts-expect-error TypeScript is unhappy that we're overriding something that it doesn't know is secretly on the base class
private override set _rootTreeItem(_value: AzExtParentTreeItem) {
// Do nothing!
}

//#endregion AzExtTreeDataProvider

public dispose(): void {
super.dispose();
this.overrideOnDidChangeTreeDataEmitter.dispose();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzExtTreeItem, ISubscriptionContext } from '@microsoft/vscode-azext-utils';
import type { AppResource, AppResourceResolver } from '@microsoft/vscode-azext-utils/hostapi';
import type { AzureResource, ResourceModelBase } from '@microsoft/vscode-azext-utils/hostapi.v2';
import { createSubscriptionContext } from '../../../../utils/v2/credentialsUtils';
import { CompatibleBranchDataProviderBase } from '../CompatibleBranchDataProviderBase';
import { CompatibleResolvedApplicationResourceTreeItem } from './CompatibleApplicationResourceTreeItem';

/**
* Provides compatibility between an `AppResourceResolver` (v1) and a `BranchDataProvider` (v2)
*/
export class CompatibleApplicationResourceBranchDataProvider<TResource extends AzureResource, TModel extends AzExtTreeItem & ResourceModelBase> extends CompatibleBranchDataProviderBase<TResource, TModel> {
public constructor(private readonly resolver: AppResourceResolver, loadMoreCommandId: string) {
super(loadMoreCommandId);
}

public async getResourceItem(element: TResource): Promise<TModel> {
const oldAppResource: AppResource = {
...element,
type: element.azureResourceType.type,
kind: element.azureResourceType.kinds?.join(';'),
};
const subscriptionContext: ISubscriptionContext = createSubscriptionContext(element.subscription);

const resolved = await this.resolver.resolveResource(subscriptionContext, oldAppResource);
const result = CompatibleResolvedApplicationResourceTreeItem.Create(element, resolved!, subscriptionContext, this, element) as unknown as TModel;
Object.defineProperty(result, 'fullId', {
get: () => {
return element.id;
}
});

return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzExtParentTreeItem, AzExtResourceType, AzExtTreeDataProvider, AzExtTreeItem, IActionContext, ISubscriptionContext, nonNullProp, TreeItemIconPath } from "@microsoft/vscode-azext-utils";
import type { ResolvedAppResourceBase } from "@microsoft/vscode-azext-utils/hostapi";
import { AzureResource } from "@microsoft/vscode-azext-utils/hostapi.v2";
import { TreeItemCollapsibleState } from "vscode";
import { createResolvableProxy } from "../../../../tree/AppResourceTreeItem";
import { getIconPath } from "../../../../utils/azureUtils";

/**
* Must imitate the behavior of ResolvedAppResourceBase
*/
export class CompatibleResolvedApplicationResourceTreeItem extends AzExtParentTreeItem {
bwateratmsft marked this conversation as resolved.
Show resolved Hide resolved
public static contextValue: string = 'azureResource';
protected readonly contextValues: Set<string> = new Set<string>();
public get contextValue(): string {
return Array.from(this.contextValues.values()).sort().join(';');
}

// override
public get effectiveId(): string | undefined {
return undefined;
}

public valuesToMask: string[] = [];

public readonly resolveResult: ResolvedAppResourceBase;
public data: AzureResource;
public readonly azExtResourceType: AzExtResourceType;

public readonly cTime: number = Date.now();
public mTime: number = Date.now();
public tags?: { [propertyName: string]: string; } | undefined;

public get id(): string | undefined {
return undefined;
}

public get label(): string {
return nonNullProp(this.data, 'name');
}

public get iconPath(): TreeItemIconPath {
return getIconPath(this.data.resourceType);
}

public get description(): string | undefined {
return this.resolveResult?.description;
}

public get collapsibleState(): TreeItemCollapsibleState | undefined {
return this.resolveResult?.initialCollapsibleState ?? !!this.resolveResult?.loadMoreChildrenImpl ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None;
}

public static Create(resource: AzureResource, resolveResult: ResolvedAppResourceBase, subscription: ISubscriptionContext, treeDataProvider: AzExtTreeDataProvider, azureResource: AzureResource): CompatibleResolvedApplicationResourceTreeItem {
const resolvable: CompatibleResolvedApplicationResourceTreeItem = new CompatibleResolvedApplicationResourceTreeItem(resource, resolveResult, subscription, treeDataProvider, azureResource);
return createResolvableProxy(resolvable);
}

public readonly resource: AzureResource;

private constructor(resource: AzureResource, resolved: ResolvedAppResourceBase, __subscription: ISubscriptionContext, __treeDataProvider: AzExtTreeDataProvider, azureResource: AzureResource) {
super(
(<Partial<AzExtParentTreeItem>>{
treeDataProvider: __treeDataProvider,
valuesToMask: [],
subscription: __subscription,
parent: undefined,
removeChildFromCache: () => {
//
},
}) as unknown as AzExtParentTreeItem
);

this.resource = azureResource;
this.resolveResult = resolved;
this.data = resource;
this.tags = resource.tags;

this.contextValues.add(CompatibleResolvedApplicationResourceTreeItem.contextValue);
if (azureResource.resourceType) {
this.contextValues.add(azureResource.resourceType);
}
resolved.contextValuesToAdd?.forEach((value: string) => this.contextValues.add(value));
}

public async loadMoreChildrenImpl(clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
if (this.resolveResult?.loadMoreChildrenImpl) {
// this is actually calling resolveResult.loadMoreChildrenImpl through the Proxy so that the function has the correct thisArg
return await this.loadMoreChildrenImpl(clearCache, context);
} else {
return [];
}
}

public hasMoreChildrenImpl(): boolean {
return false;
}

public async refreshImpl(): Promise<void> {
this.mTime = Date.now();
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzExtParentTreeItem, AzExtTreeItem } from "@microsoft/vscode-azext-utils";
import { WorkspaceResourceProvider } from "@microsoft/vscode-azext-utils/hostapi";
import { WorkspaceResource, WorkspaceResourceProvider as V2WorkspaceResourceProvider } from "@microsoft/vscode-azext-utils/hostapi.v2";
import { Event, WorkspaceFolder } from "vscode";
import { CompatibleWorkspaceResourceBranchDataProvider } from "./CompatibleWorkspaceResourceBranchDataProvider";

export class CompatibilityWorkspaceResourceProvider implements V2WorkspaceResourceProvider {
constructor(private readonly resourceType: string, private readonly provider: WorkspaceResourceProvider) { }

// No comparable mechanism in v1, leave as undefined
onDidChangeResource?: Event<WorkspaceResource | undefined> = undefined;

public async getResources(source: WorkspaceFolder): Promise<WorkspaceResource[]> {

const resources = await this.provider.provideResources(
// pass in stub parent
{
treeDataProvider: new CompatibleWorkspaceResourceBranchDataProvider('azureWorkspace.loadMore'),
valuesToMask: [],
parent: undefined,
} as unknown as AzExtParentTreeItem
);

if (resources) {
return resources.map((resource) => {
return Object.assign<AzExtTreeItem, WorkspaceResource>(resource,
{
// omit id because it's already in the treeItem
folder: source,
resourceType: this.resourceType,
name: resource.label,
} as WorkspaceResource
);
});
}

return [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import type { WorkspaceResource } from '@microsoft/vscode-azext-utils/hostapi';
import type { WorkspaceResource as v2WorkspaceResource } from '@microsoft/vscode-azext-utils/hostapi.v2';
import { CompatibleBranchDataProviderBase } from '../CompatibleBranchDataProviderBase';

export class CompatibleWorkspaceResourceBranchDataProvider<TResource extends WorkspaceResource & v2WorkspaceResource> extends CompatibleBranchDataProviderBase<TResource, TResource> {
public async getResourceItem(element: TResource): Promise<TResource> {
return element;
}
}
Loading