@@ -16,29 +16,39 @@ import { AWSTreeErrorHandlerNode } from '../../shared/treeview/nodes/awsTreeErro
16
16
import { AWSTreeNodeBase } from '../../shared/treeview/nodes/awsTreeNodeBase'
17
17
import { ErrorNode } from '../../shared/treeview/nodes/errorNode'
18
18
import { PlaceholderNode } from '../../shared/treeview/nodes/placeholderNode'
19
+ import { makeChildrenNodes } from '../../shared/treeview/treeNodeUtilities'
19
20
import { intersection , toArrayAsync , toMap , toMapAsync , updateInPlace } from '../../shared/utilities/collectionUtils'
20
21
import { listCloudFormationStacks , listLambdaFunctions } from '../utils'
21
22
import { LambdaFunctionNode } from './lambdaFunctionNode'
22
23
23
24
export const CONTEXT_VALUE_CLOUDFORMATION_LAMBDA_FUNCTION = 'awsCloudFormationFunctionNode'
24
25
25
- export class CloudFormationNode extends AWSTreeErrorHandlerNode {
26
+ export class CloudFormationNode extends AWSTreeNodeBase {
26
27
private readonly stackNodes : Map < string , CloudFormationStackNode >
27
28
28
29
public constructor ( private readonly regionCode : string ) {
29
30
super ( 'CloudFormation' , vscode . TreeItemCollapsibleState . Collapsed )
30
31
this . stackNodes = new Map < string , CloudFormationStackNode > ( )
31
32
}
32
33
33
- public async getChildren ( ) : Promise < ( CloudFormationStackNode | ErrorNode ) [ ] > {
34
- await this . handleErrorProneOperation (
35
- async ( ) => this . updateChildren ( ) ,
36
- localize ( 'AWS.explorerNode.cloudFormation.error' , 'Error loading CloudFormation resources' )
37
- )
38
-
39
- return ! ! this . errorNode
40
- ? [ this . errorNode ]
41
- : [ ...this . stackNodes . values ( ) ] . sort ( ( nodeA , nodeB ) => nodeA . stackName . localeCompare ( nodeB . stackName ) )
34
+ public async getChildren ( ) : Promise < AWSTreeNodeBase [ ] > {
35
+ return await makeChildrenNodes ( {
36
+ getChildNodes : async ( ) => {
37
+ await this . updateChildren ( )
38
+
39
+ return [ ...this . stackNodes . values ( ) ]
40
+ } ,
41
+ getErrorNode : async ( error : Error ) =>
42
+ new ErrorNode (
43
+ this ,
44
+ error ,
45
+ localize ( 'AWS.explorerNode.cloudFormation.error' , 'Error loading CloudFormation resources' )
46
+ ) ,
47
+ getNoChildrenPlaceholderNode : async ( ) =>
48
+ new PlaceholderNode ( this , localize ( 'AWS.explorerNode.cloudformation.noStacks' , '[No Stacks found]' ) ) ,
49
+ sort : ( nodeA : CloudFormationStackNode , nodeB : CloudFormationStackNode ) =>
50
+ nodeA . stackName . localeCompare ( nodeB . stackName )
51
+ } )
42
52
}
43
53
44
54
public async updateChildren ( ) : Promise < void > {
0 commit comments