@@ -89,42 +89,113 @@ export class ContainersTreeDataProvider implements theia.TreeDataProvider<ITreeN
89
89
tooltip : `open a new terminal for ${ container . name } ` ,
90
90
command : { id : 'terminal-in-specific-container:new' , arguments : [ container . name ] }
91
91
} ) ;
92
- const servers = container . servers ;
93
- if ( ! servers ) {
94
- return ;
92
+ const serverKeys = container . servers ? Object . keys ( container . servers ) : [ ] ;
93
+ if ( serverKeys . length ) {
94
+ const endpointsId = this . getRandId ( ) ;
95
+ this . treeNodeItems . push ( {
96
+ id : endpointsId ,
97
+ parentId : treeItem . id ,
98
+ name : 'endpoints' ,
99
+ tooltip : 'endpoints' ,
100
+ isExpanded : true
101
+ } ) ;
102
+ serverKeys . forEach ( ( serverName : string ) => {
103
+ const server = container . servers [ serverName ] ;
104
+ if ( ! server ) {
105
+ return ;
106
+ }
107
+ const treeNodeItem : ITreeNodeItem = {
108
+ id : this . getRandId ( ) ,
109
+ parentId : endpointsId ,
110
+ name : serverName ,
111
+ iconPath : 'fa-info-circle medium-blue' ,
112
+ tooltip : server . url ? server . url : 'endpoint'
113
+ } ;
114
+ if ( server . url && server . url . startsWith ( 'http' ) ) {
115
+ treeNodeItem . name = serverName ;
116
+ treeNodeItem . iconPath = 'fa-share medium-blue' ;
117
+ treeNodeItem . command = { id : 'theia.open' , arguments : [ server . url ] } ;
118
+ treeNodeItem . tooltip = 'open in a new tab ' + treeNodeItem . tooltip ;
119
+ }
120
+ this . treeNodeItems . push ( treeNodeItem ) ;
121
+ } ) ;
95
122
}
96
- const serverKeys = Object . keys ( servers ) ;
97
- if ( ! serverKeys . length ) {
98
- return ;
123
+ const envKeys = container . env ? Object . keys ( container . env ) : [ ] ;
124
+ if ( envKeys . length ) {
125
+ const envsId = this . getRandId ( ) ;
126
+ this . treeNodeItems . push ( {
127
+ id : envsId ,
128
+ parentId : treeItem . id ,
129
+ name : 'env' ,
130
+ tooltip : 'environment variables' ,
131
+ isExpanded : false
132
+ } ) ;
133
+ envKeys . forEach ( ( envName : string ) => {
134
+ this . treeNodeItems . push ( {
135
+ id : this . getRandId ( ) ,
136
+ parentId : envsId ,
137
+ name : `${ envName } : ${ container . env [ envName ] } ` ,
138
+ tooltip : `environment variable ${ envName } ` ,
139
+ iconPath : 'fa-info-circle medium-blue'
140
+ } ) ;
141
+ } ) ;
142
+ }
143
+ const volumesKeys = container . volumes ? Object . keys ( container . volumes ) : [ ] ;
144
+ if ( volumesKeys . length ) {
145
+ const volumesId = this . getRandId ( ) ;
146
+ this . treeNodeItems . push ( {
147
+ id : volumesId ,
148
+ parentId : treeItem . id ,
149
+ name : 'volumes' ,
150
+ tooltip : 'volumes' ,
151
+ isExpanded : false
152
+ } ) ;
153
+ volumesKeys . forEach ( ( volumeName : string ) => {
154
+ const volume : {
155
+ [ paramRef : string ] : string ;
156
+ } = container . volumes [ volumeName ] ;
157
+ if ( ! volume ) {
158
+ return ;
159
+ }
160
+ const volumeId = this . getRandId ( ) ;
161
+ this . treeNodeItems . push ( {
162
+ id : volumeId ,
163
+ parentId : volumesId ,
164
+ name : volumeName ,
165
+ tooltip : 'volume name' ,
166
+ isExpanded : true
167
+ } ) ;
168
+ Object . keys ( volume ) . forEach ( ( key : string ) => {
169
+ this . treeNodeItems . push ( {
170
+ id : this . getRandId ( ) ,
171
+ parentId : volumeId ,
172
+ name : `${ key } : ${ volume [ key ] } ` ,
173
+ tooltip : `volume ${ volumeName } ` ,
174
+ iconPath : 'fa-info-circle medium-blue'
175
+ } ) ;
176
+ } ) ;
177
+ } ) ;
178
+ }
179
+ if ( container . commands && container . commands . length ) {
180
+ const commandsId = this . getRandId ( ) ;
181
+ this . treeNodeItems . push ( {
182
+ id : commandsId ,
183
+ parentId : treeItem . id ,
184
+ name : 'commands' ,
185
+ tooltip : 'commands' ,
186
+ isExpanded : false
187
+ } ) ;
188
+ container . commands . forEach ( ( commandName : string ) => {
189
+ this . treeNodeItems . push ( {
190
+ id : this . getRandId ( ) ,
191
+ parentId : commandsId ,
192
+ name : commandName ,
193
+ tooltip : 'execute the command' ,
194
+ iconPath : 'fa-terminal medium-yellow' ,
195
+ command : { id : 'task:run' , arguments : [ 'che' , commandName ] }
196
+ } ) ;
197
+ } ) ;
99
198
}
100
- const endpointsId = this . getRandId ( ) ;
101
- this . treeNodeItems . push ( {
102
- id : endpointsId ,
103
- parentId : treeItem . id ,
104
- name : 'endpoints' ,
105
- tooltip : 'endpoints' ,
106
- isExpanded : true
107
- } ) ;
108
- serverKeys . forEach ( ( serverName : string ) => {
109
- const server = servers [ serverName ] ;
110
- if ( ! server ) {
111
- return ;
112
- }
113
- const treeNodeItem : ITreeNodeItem = {
114
- id : this . getRandId ( ) ,
115
- parentId : endpointsId ,
116
- name : serverName ,
117
- iconPath : 'fa-info-circle medium-blue' ,
118
- tooltip : server . url ? server . url : 'endpoint'
119
- } ;
120
- if ( server . url && server . url . startsWith ( 'http' ) ) {
121
- treeNodeItem . name = serverName ;
122
- treeNodeItem . iconPath = 'fa-share medium-blue' ;
123
- treeNodeItem . command = { id : 'theia.open' , arguments : [ server . url ] } ;
124
- treeNodeItem . tooltip = 'open in a new tab ' + treeNodeItem . tooltip ;
125
- }
126
- this . treeNodeItems . push ( treeNodeItem ) ;
127
- } ) ;
128
199
} ) ;
129
200
if ( hasPlugin ) {
130
201
this . treeNodeItems . push ( pluginsDir ) ;
0 commit comments