|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information. |
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | | -import { Revision } from "@azure/arm-appcontainers"; |
7 | 6 | import { uiUtils } from "@microsoft/vscode-azext-azureutils"; |
8 | 7 | import { TreeElementBase, callWithTelemetryAndErrorHandling, createContextValue, createSubscriptionContext } from "@microsoft/vscode-azext-utils"; |
9 | 8 | import type { AzureSubscription } from "@microsoft/vscode-azureresources-api"; |
10 | 9 | import { TreeItem, TreeItemCollapsibleState } from "vscode"; |
11 | | -import { revisionDraftFalseContextValue, revisionDraftTrueContextValue } from "../../constants"; |
12 | | -import { ext } from "../../extensionVariables"; |
13 | 10 | import { createContainerAppsAPIClient } from "../../utils/azureClients"; |
14 | 11 | import { localize } from "../../utils/localize"; |
15 | 12 | import { treeUtils } from "../../utils/treeUtils"; |
16 | 13 | import type { ContainerAppModel } from "../ContainerAppItem"; |
17 | 14 | import type { ContainerAppsItem } from "../ContainerAppsBranchDataProvider"; |
18 | | -import { RevisionDraftItem } from "./RevisionDraftItem"; |
19 | 15 | import { RevisionItem } from "./RevisionItem"; |
20 | 16 |
|
21 | 17 | export class RevisionsItem implements ContainerAppsItem { |
22 | | - static readonly idSuffix: string = 'revisions'; |
23 | 18 | static readonly contextValue: string = 'revisionsItem'; |
24 | 19 | static readonly contextValueRegExp: RegExp = new RegExp(RevisionsItem.contextValue); |
25 | 20 |
|
26 | 21 | id: string; |
27 | 22 |
|
28 | | - constructor(readonly subscription: AzureSubscription, readonly containerApp: ContainerAppModel) { |
29 | | - this.id = `${containerApp.id}/${RevisionsItem.idSuffix}`; |
| 23 | + constructor(public readonly subscription: AzureSubscription, public readonly containerApp: ContainerAppModel) { |
| 24 | + this.id = `${containerApp.id}/Revisions`; |
30 | 25 | } |
31 | 26 |
|
32 | | - get contextValue(): string { |
| 27 | + private get contextValue(): string { |
33 | 28 | const values: string[] = [RevisionsItem.contextValue]; |
34 | | - values.push(ext.revisionDraftFileSystem.doesContainerAppsItemHaveRevisionDraft(this) ? revisionDraftTrueContextValue : revisionDraftFalseContextValue); |
| 29 | + // values.push(ext.revisionDraftFileSystem.doesContainerAppsItemHaveRevisionDraft(this) ? 'revisionDraft:true' : 'revisionDraft:false'); |
35 | 30 | return createContextValue(values); |
36 | 31 | } |
37 | 32 |
|
38 | 33 | async getChildren(): Promise<TreeElementBase[]> { |
39 | | - const revisionDraftBaseName: string | undefined = ext.revisionDraftFileSystem.getRevisionDraftFile(this)?.baseRevisionName; |
40 | | - let draftBaseRevision: Revision | undefined; |
41 | | - |
42 | | - const result = (await callWithTelemetryAndErrorHandling('getChildren', async (context) => { |
| 34 | + const result = await callWithTelemetryAndErrorHandling('getChildren', async (context) => { |
43 | 35 | const client = await createContainerAppsAPIClient([context, createSubscriptionContext(this.subscription)]); |
44 | 36 | const revisions = await uiUtils.listAllIterator(client.containerAppsRevisions.listRevisions(this.containerApp.resourceGroup, this.containerApp.name)); |
45 | | - return revisions.map(revision => { |
46 | | - if (revision.name === revisionDraftBaseName) { |
47 | | - draftBaseRevision = revision; |
48 | | - } |
49 | | - return new RevisionItem(this.subscription, this.containerApp, revision) |
50 | | - }); |
51 | | - }))?.reverse() ?? []; |
| 37 | + return revisions.map(revision => new RevisionItem(this.subscription, this.containerApp, revision)); |
| 38 | + }); |
52 | 39 |
|
53 | | - return draftBaseRevision ? [ |
54 | | - new RevisionDraftItem(this.subscription, this.containerApp, draftBaseRevision), |
55 | | - ...result.filter(item => item.revision.name !== revisionDraftBaseName) |
56 | | - ] : result; |
| 40 | + return result?.reverse() ?? []; |
57 | 41 | } |
58 | 42 |
|
59 | 43 | getTreeItem(): TreeItem { |
|
0 commit comments