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
Changes from 2 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
72 changes: 72 additions & 0 deletions src/tree/v2/providers/CompatibleBranchDataProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------------------
* 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 { AppResource, AppResourceResolver } from '@microsoft/vscode-azext-utils/hostapi';
import * as vscode from 'vscode';
import { ApplicationResource, BranchDataProvider, ResourceModelBase } from '../../../api/v2/v2AzureResourcesApi';

export class CompatibleBranchDataProvider<TResource extends ApplicationResource, TModel extends AzExtTreeItem & ResourceModelBase> extends AzExtTreeDataProvider implements BranchDataProvider<TResource, TModel> {
private readonly overrideOnDidChangeTreeDataEmitter = new vscode.EventEmitter<TModel | undefined>();

public constructor(private readonly resolver: AppResourceResolver, loadMoreCommandId: string) {
super(undefined as unknown as AzExtParentTreeItem, loadMoreCommandId);
}

//#region TreeDataProvider

public override readonly onDidChangeTreeData = this.overrideOnDidChangeTreeDataEmitter.event;

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

public override 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 BranchDataProvider

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

return this.resolver.resolveResource(/* TODO */'foo', oldAppResource) as Promise<TModel>;
bwateratmsft marked this conversation as resolved.
Show resolved Hide resolved
}

//#endregion BranchDataProvider

//#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');
}

//#endregion AzExtTreeDataProvider
}