forked from aws/aws-toolkit-vscode
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some refactoring/standardization on tree nodes
- Loading branch information
1 parent
90d26a5
commit 5ae6885
Showing
13 changed files
with
142 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
'use strict'; | ||
|
||
import * as vscode from 'vscode'; | ||
import { ExplorerNodeBase } from '../../shared/nodes'; | ||
import { TreeItem, TreeItemCollapsibleState } from 'vscode'; | ||
import { AWSTreeNodeBase } from '../../shared/awsTreeNodeBase'; | ||
import { FunctionNode } from './functionNode'; | ||
import { ext } from '../../shared/extensionGlobals'; | ||
import Lambda = require('aws-sdk/clients/lambda'); | ||
import { listLambdas } from '../utils'; | ||
|
||
export class FunctionsNode extends ExplorerNodeBase { | ||
export class FunctionsNode extends AWSTreeNodeBase { | ||
public static contextValue: string = 'awsLambdaFns'; | ||
public readonly contextValue: string = FunctionsNode.contextValue; | ||
public readonly label: string = 'Lambda Functions'; | ||
|
||
public async getChildren(): Promise<ExplorerNodeBase[]> { | ||
return await listLambdas(await ext.sdkClientBuilder.createAndConfigureSdkClient(Lambda, undefined)); | ||
public getChildren(): Thenable<AWSTreeNodeBase[]> { | ||
return new Promise(resolve => { | ||
this.queryDeployedLambdaFunctions().then((result) => resolve(result)); | ||
}); | ||
} | ||
|
||
public getTreeItem(): vscode.TreeItem | Promise<vscode.TreeItem> { | ||
const item = new vscode.TreeItem('Functions', vscode.TreeItemCollapsibleState.Collapsed); | ||
public getTreeItem(): TreeItem { | ||
const item = new TreeItem('Functions', TreeItemCollapsibleState.Collapsed); | ||
item.tooltip = 'My deployed Lambda functions'; | ||
|
||
return item; | ||
} | ||
|
||
private async queryDeployedLambdaFunctions() : Promise<FunctionNode[]> { | ||
const client = await ext.sdkClientBuilder.createAndConfigureSdkClient(Lambda, undefined); | ||
return await listLambdas(client); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
import { AWSContext } from "./awsContext"; | ||
|
||
export interface IAWSTreeProvider { | ||
viewProviderId: string; | ||
|
||
initialize(): void; | ||
} | ||
|
||
export interface IRefreshableAWSTreeProvider extends IAWSTreeProvider { | ||
refresh(newContext?: AWSContext): void; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
import { Command, Disposable, TreeItem } from 'vscode'; | ||
import { AWSContext } from './awsContext'; | ||
|
||
export abstract class AWSTreeNodeBase extends Disposable { | ||
|
||
public readonly supportsPaging: boolean = false; | ||
|
||
protected children: AWSTreeNodeBase[] | undefined; | ||
protected disposable: Disposable | undefined; | ||
|
||
constructor() { | ||
super(() => this.dispose()); | ||
} | ||
|
||
dispose() { | ||
if (this.disposable !== undefined) { | ||
this.disposable.dispose(); | ||
this.disposable = undefined; | ||
} | ||
|
||
this.resetChildren(); | ||
} | ||
|
||
public abstract getTreeItem(): TreeItem; | ||
|
||
public abstract getChildren(): Thenable<AWSTreeNodeBase[]>; | ||
|
||
public getCommand(): Command | undefined { | ||
return undefined; | ||
} | ||
|
||
public refresh(newContext: AWSContext): void { } | ||
|
||
public resetChildren(): void { | ||
if (this.children !== undefined) { | ||
this.children.forEach(c => c.dispose()); | ||
this.children = undefined; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.