@@ -53,145 +53,152 @@ export class ConfigurationDataProvider
5353 return element ;
5454 }
5555
56- getChildren (
56+ async getChildren (
5757 element ?: TreeItem | undefined
58- ) : ProviderResult < Array < TreeItem > > {
59- if ( this . connectionManager . state !== "CONNECTED" ) {
60- return [ ] ;
58+ ) : Promise < Array < TreeItem > > {
59+ switch ( this . connectionManager . state ) {
60+ case "CONNECTED" :
61+ break ;
62+ case "CONNECTING" :
63+ await this . connectionManager . waitForConnect ( ) ;
64+ break ;
65+ case "DISCONNECTED" :
66+ return [ ] ;
6167 }
62- return ( async ( ) => {
63- let cluster = this . connectionManager . cluster ;
64- let syncDestination = this . connectionManager . syncDestination ;
6568
66- if ( ! element ) {
67- let children : Array < TreeItem > = [ ] ;
69+ let cluster = this . connectionManager . cluster ;
70+ let syncDestination = this . connectionManager . syncDestination ;
71+
72+ if ( ! element ) {
73+ let children : Array < TreeItem > = [ ] ;
74+ children . push ( {
75+ label : `Workspace` ,
76+ iconPath : new ThemeIcon ( "account" ) ,
77+ id : "WORKSPACE" ,
78+ collapsibleState : TreeItemCollapsibleState . Expanded ,
79+ contextValue : "workspace" ,
80+ } ) ;
81+
82+ if ( cluster ) {
6883 children . push ( {
69- label : `Workspace` ,
70- iconPath : new ThemeIcon ( "account " ) ,
71- id : "WORKSPACE " ,
84+ label : "Cluster" ,
85+ iconPath : new ThemeIcon ( "server " ) ,
86+ id : "CLUSTER " ,
7287 collapsibleState : TreeItemCollapsibleState . Expanded ,
73- contextValue : "workspace" ,
88+ contextValue :
89+ cluster . state === "RUNNING"
90+ ? "clusterRunning"
91+ : cluster . state === "PENDING"
92+ ? "clusterPending"
93+ : "clusterStopped" ,
94+ } ) ;
95+ } else {
96+ children . push ( {
97+ label : `Cluster - "None attached"` ,
98+ iconPath : new ThemeIcon ( "server" ) ,
99+ id : "CLUSTER" ,
100+ collapsibleState : TreeItemCollapsibleState . Expanded ,
101+ contextValue : "clusterDetached" ,
74102 } ) ;
75-
76- if ( cluster ) {
77- children . push ( {
78- label : "Cluster" ,
79- iconPath : new ThemeIcon ( "server" ) ,
80- id : "CLUSTER" ,
81- collapsibleState : TreeItemCollapsibleState . Expanded ,
82- contextValue :
83- cluster . state === "RUNNING"
84- ? "clusterRunning"
85- : cluster . state === "PENDING"
86- ? "clusterPending"
87- : "clusterStopped" ,
88- } ) ;
89- } else {
90- children . push ( {
91- label : `Cluster - "None attached"` ,
92- iconPath : new ThemeIcon ( "server" ) ,
93- id : "CLUSTER" ,
94- collapsibleState : TreeItemCollapsibleState . Expanded ,
95- contextValue : "clusterDetached" ,
96- } ) ;
97- }
98-
99- if ( syncDestination ) {
100- // TODO: Add another icon over here for in_progress state
101- // DECO-220
102- children . push ( {
103- label : `Repo` ,
104- iconPath : new ThemeIcon ( "repo" ) ,
105- id : "REPO" ,
106- collapsibleState : TreeItemCollapsibleState . Expanded ,
107- contextValue :
108- this . sync . state === "WATCHING_FOR_CHANGES" ||
109- this . sync . state === "IN_PROGRESS"
110- ? "syncRunning"
111- : "syncStopped" ,
112- } ) ;
113- } else {
114- children . push ( {
115- label : `Repo - "None attached"` ,
116- iconPath : new ThemeIcon ( "repo" ) ,
117- id : "REPO" ,
118- collapsibleState : TreeItemCollapsibleState . Expanded ,
119- contextValue : "syncDetached" ,
120- } ) ;
121- }
122-
123- return children ;
124103 }
125104
126- const dbWorkspace = this . connectionManager . databricksWorkspace ;
127- if ( element . id === "WORKSPACE" && dbWorkspace ) {
128- return [
129- {
130- label : "Profile" ,
131- description : dbWorkspace . profile ,
132- collapsibleState : TreeItemCollapsibleState . None ,
133- } ,
134- {
135- label : "User" ,
136- description : dbWorkspace . userName ,
137- collapsibleState : TreeItemCollapsibleState . None ,
138- } ,
139- {
140- label : "Host" ,
141- description : dbWorkspace . host . toString ( ) ,
142- collapsibleState : TreeItemCollapsibleState . None ,
143- contextValue : "databricks-link" ,
144- } ,
145- ] ;
105+ if ( syncDestination ) {
106+ // TODO: Add another icon over here for in_progress state
107+ // DECO-220
108+ children . push ( {
109+ label : `Repo` ,
110+ iconPath : new ThemeIcon ( "repo" ) ,
111+ id : "REPO" ,
112+ collapsibleState : TreeItemCollapsibleState . Expanded ,
113+ contextValue :
114+ this . sync . state === "WATCHING_FOR_CHANGES" ||
115+ this . sync . state === "IN_PROGRESS"
116+ ? "syncRunning"
117+ : "syncStopped" ,
118+ } ) ;
119+ } else {
120+ children . push ( {
121+ label : `Repo - "None attached"` ,
122+ iconPath : new ThemeIcon ( "repo" ) ,
123+ id : "REPO" ,
124+ collapsibleState : TreeItemCollapsibleState . Expanded ,
125+ contextValue : "syncDetached" ,
126+ } ) ;
146127 }
147128
148- if ( element . id ?. startsWith ( "CLUSTER" ) && cluster ) {
149- let clusterItem =
150- ClusterListDataProvider . clusterNodeToTreeItem ( cluster ) ;
151-
152- return [
153- {
154- label : "Name:" ,
155- description : cluster . name ,
156- iconPath : clusterItem . iconPath ,
157- collapsibleState : TreeItemCollapsibleState . None ,
158- } ,
159- ...( await ClusterListDataProvider . clusterNodeToTreeItems (
160- cluster
161- ) ) ,
162- ] ;
163- }
129+ return children ;
130+ }
164131
165- if ( element . id === "REPO" && syncDestination ) {
166- return [
167- {
168- label : `Name:` ,
169- description : syncDestination . name ,
170- iconPath :
171- this . sync . state === "WATCHING_FOR_CHANGES" ||
172- this . sync . state === "IN_PROGRESS"
173- ? new ThemeIcon ( "debug-start" )
174- : new ThemeIcon ( "debug-stop" ) ,
175- collapsibleState : TreeItemCollapsibleState . None ,
176- } ,
177- {
178- label : `URL:` ,
179- description : await this . connectionManager
180- . syncDestination ?. repo . url ,
181- contextValue : "databricks-link" ,
182- } ,
183- {
184- label : `State:` ,
185- description : this . sync . state ,
186- collapsibleState : TreeItemCollapsibleState . None ,
187- } ,
188- {
189- label : `Path:` ,
190- description : syncDestination . path . path ,
191- collapsibleState : TreeItemCollapsibleState . None ,
192- } ,
193- ] ;
194- }
195- } ) ( ) ;
132+ const dbWorkspace = this . connectionManager . databricksWorkspace ;
133+ if ( element . id === "WORKSPACE" && dbWorkspace ) {
134+ return [
135+ {
136+ label : "Profile" ,
137+ description : dbWorkspace . profile ,
138+ collapsibleState : TreeItemCollapsibleState . None ,
139+ } ,
140+ {
141+ label : "User" ,
142+ description : dbWorkspace . userName ,
143+ collapsibleState : TreeItemCollapsibleState . None ,
144+ } ,
145+ {
146+ label : "Host" ,
147+ description : dbWorkspace . host . toString ( ) ,
148+ collapsibleState : TreeItemCollapsibleState . None ,
149+ contextValue : "databricks-link" ,
150+ } ,
151+ ] ;
152+ }
153+
154+ if ( element . id ?. startsWith ( "CLUSTER" ) && cluster ) {
155+ let clusterItem =
156+ ClusterListDataProvider . clusterNodeToTreeItem ( cluster ) ;
157+
158+ return [
159+ {
160+ label : "Name:" ,
161+ description : cluster . name ,
162+ iconPath : clusterItem . iconPath ,
163+ collapsibleState : TreeItemCollapsibleState . None ,
164+ } ,
165+ ...( await ClusterListDataProvider . clusterNodeToTreeItems (
166+ cluster
167+ ) ) ,
168+ ] ;
169+ }
170+
171+ if ( element . id === "REPO" && syncDestination ) {
172+ return [
173+ {
174+ label : `Name:` ,
175+ description : syncDestination . name ,
176+ iconPath :
177+ this . sync . state === "WATCHING_FOR_CHANGES" ||
178+ this . sync . state === "IN_PROGRESS"
179+ ? new ThemeIcon ( "debug-start" )
180+ : new ThemeIcon ( "debug-stop" ) ,
181+ collapsibleState : TreeItemCollapsibleState . None ,
182+ } ,
183+ {
184+ label : `URL:` ,
185+ description : await this . connectionManager . syncDestination
186+ ?. repo . url ,
187+ contextValue : "databricks-link" ,
188+ } ,
189+ {
190+ label : `State:` ,
191+ description : this . sync . state ,
192+ collapsibleState : TreeItemCollapsibleState . None ,
193+ } ,
194+ {
195+ label : `Path:` ,
196+ description : syncDestination . path . path ,
197+ collapsibleState : TreeItemCollapsibleState . None ,
198+ } ,
199+ ] ;
200+ }
201+
202+ return [ ] ;
196203 }
197204}
0 commit comments