@@ -31,8 +31,10 @@ import {
3131 isImageStreamTag ,
3232 isRegistry ,
3333 isS2iComponent ,
34+ isSampleProject ,
3435 Registry ,
35- S2iComponentType
36+ S2iComponentType ,
37+ SampleProject
3638} from './odo/componentType' ;
3739import {
3840 isStarterProject ,
@@ -42,12 +44,15 @@ import { vsCommand, VsCommandError } from './vscommand';
4244import { Cluster } from '@kubernetes/client-node/dist/config_types' ;
4345import { KubeConfig } from '@kubernetes/client-node' ;
4446
45- type ComponentType = S2iComponentType | DevfileComponentType | ImageStreamTag | StarterProject | Cluster | Registry ;
47+ type ExampleProject = SampleProject | StarterProject ;
48+ type ComponentType = DevfileComponentType | ImageStreamTag | ExampleProject | Cluster | Registry ;
49+
4650
4751export enum ContextType {
4852 S2I_COMPONENT_TYPE = 's2iComponentType' ,
4953 DEVFILE_COMPONENT_TYPE = 'devfileComponentType' ,
5054 S2I_IMAGE_STREAM_TAG = 's2iImageStreamTag' ,
55+ S2I_SAMPLE_PROJECT = 's2iSampleProject' ,
5156 DEVFILE_STARTER_PROJECT = 'devfileStarterProject' ,
5257 DEVFILE_REGISTRY = 'devfileRegistry' ,
5358 OFFLINE_CLUSTER = 'clusterOffline' ,
@@ -93,12 +98,13 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
9398 return {
9499 label : `${ element . server } ` ,
95100 collapsibleState : TreeItemCollapsibleState . Collapsed ,
101+ tooltip : `Current Cluster\n Server: ${ element . server } ` ,
96102 }
97103 }
98104 if ( isRegistry ( element ) ) {
99105 return {
100106 label : element . Name ,
101- description : element . URL ,
107+ tooltip : `Devfile Registry\nName: ${ element . Name } \nURL: ${ element . URL } ` ,
102108 collapsibleState : TreeItemCollapsibleState . Collapsed ,
103109 }
104110 }
@@ -113,23 +119,38 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
113119 collapsibleState : TreeItemCollapsibleState . Collapsed ,
114120 } ;
115121 }
122+ if ( isSampleProject ( element ) ) {
123+ const to = element . sampleRepo . lastIndexOf ( '.git' ) ;
124+ const from = element . sampleRepo . lastIndexOf ( '/' ) ;
125+ const projectName = element . sampleRepo . substring ( from + 1 , to > 0 ? to : undefined ) ;
126+ return {
127+ label : projectName ,
128+ contextValue : ContextType . S2I_SAMPLE_PROJECT ,
129+ tooltip : `Sample Project\nName: ${ projectName } \nRepository: ${ element . sampleRepo } ` ,
130+ iconPath : {
131+ dark : Uri . file ( path . join ( __dirname , '..' , '..' , 'images' , 'component' , 'start-project-dark.png' ) ) ,
132+ light : Uri . file ( path . join ( __dirname , '..' , '..' , 'images' , 'component' , 'start-project-light.png' ) )
133+ } ,
134+ }
135+ }
116136 if ( isImageStreamTag ( element ) ) {
117137 return {
118138 label : element . annotations [ 'openshift.io/display-name' ] ? element . annotations [ 'openshift.io/display-name' ] : element . name ,
119139 contextValue : ContextType . S2I_IMAGE_STREAM_TAG ,
120- tooltip : element . annotations . description ,
140+ tooltip : `Component Type\nName: ${ element . name } \nKind: S2I\nDescription: ${ element ?. annotations . description ? element . annotations . description : 'n/a' } ` ,
121141 description : element . annotations . description ,
122142 iconPath : {
123- dark : Uri . file ( path . join ( __dirname , '..' , '..' , 'images' , 'component' , 'start-project -dark.png' ) ) ,
124- light : Uri . file ( path . join ( __dirname , '..' , '..' , 'images' , 'component' , 'start-project -light.png' ) )
143+ dark : Uri . file ( path . join ( __dirname , '..' , '..' , 'images' , 'component' , 'component-type -dark.png' ) ) ,
144+ light : Uri . file ( path . join ( __dirname , '..' , '..' , 'images' , 'component' , 'component-type -light.png' ) )
125145 } ,
146+ collapsibleState : isSampleProject ( element ) ? TreeItemCollapsibleState . Collapsed : TreeItemCollapsibleState . Collapsed ,
126147 }
127148 }
128149 if ( isStarterProject ( element ) ) {
129150 return {
130151 label : element . name ,
131152 contextValue : ContextType . DEVFILE_STARTER_PROJECT ,
132- tooltip : element . description ,
153+ tooltip : `Starter Project\nName: ${ element . name } \nDescription: ${ element . description ? element . description : 'n/a' } ` ,
133154 description : element . description ,
134155 iconPath : {
135156 dark : Uri . file ( path . join ( __dirname , '..' , '..' , 'images' , 'component' , 'start-project-dark.png' ) ) ,
@@ -138,13 +159,14 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
138159 }
139160 }
140161 return {
141- label : `${ element . DisplayName } (devfile) ` ,
162+ label : `${ element . DisplayName } ` ,
142163 contextValue : ContextType . DEVFILE_COMPONENT_TYPE ,
143164 iconPath : {
144165 dark : Uri . file ( path . join ( __dirname , '..' , '..' , 'images' , 'component' , 'component-type-dark.png' ) ) ,
145166 light : Uri . file ( path . join ( __dirname , '..' , '..' , 'images' , 'component' , 'component-type-light.png' ) )
146167 } ,
147- tooltip : element . Description ,
168+ tooltip : `Component Type\nName: ${ element . Name } \nKind: devfile\nDescription: ${ element . Description ? element . Description : 'n/a' } ` ,
169+ description : element . Description ,
148170 collapsibleState : this . registries . length > 1 ? TreeItemCollapsibleState . None : TreeItemCollapsibleState . Collapsed ,
149171 } ;
150172 }
@@ -179,7 +201,7 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
179201 children = [ cluster , ...this . registries ] ;
180202 } else if ( isCluster ( parent ) ) {
181203 const result : CliExitData = await this . odo . execute ( Command . listCatalogComponentsJson ( ) ) ;
182- const builders = this . loadItems < ComponentTypesJson , ComponentType > ( result , ( data ) => {
204+ const builders = this . loadItems < ComponentTypesJson , S2iComponentType > ( result , ( data ) => {
183205 if ( data . s2iItems ) { // filter hidden tags
184206 data . s2iItems . forEach ( ( s2iItem ) => s2iItem . spec . imageStreamTags = s2iItem . spec . imageStreamTags . filter ( tag => s2iItem . spec . nonHiddenTags . includes ( tag . name ) ) ) ;
185207 } else { // when not logged or disconnected form cluster s2i items are not available
@@ -193,7 +215,6 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
193215 const result : CliExitData = await this . odo . execute ( Command . listCatalogComponentsJson ( ) ) ;
194216 children = this . loadItems < ComponentTypesJson , DevfileComponentType > ( result , ( data ) => data . devfileItems ) ;
195217 children = children . filter ( ( element :DevfileComponentType ) => element . Registry . Name === parent . Name ) ;
196-
197218 } else if ( isS2iComponent ( parent ) ) {
198219 children = parent . spec . imageStreamTags . map ( ( tag :ImageStreamTag ) => {
199220 tag . typeName = parent . metadata . name ;
@@ -202,11 +223,12 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
202223 } else if ( isDevfileComponent ( parent ) ) {
203224 const result : CliExitData = await this . odo . execute ( Command . describeCatalogComponent ( parent . Name ) ) ;
204225 children = this . loadItems < ComponentTypeDescription , StarterProject > ( result , ( data ) => data . Data . starterProjects ) ;
205-
206226 children = children . map ( ( starter :StarterProject ) => {
207227 starter . typeName = parent . Name ; ;
208228 return starter ;
209229 } ) ;
230+ } else if ( isImageStreamTag ( parent ) ) {
231+ children = [ parent . annotations ] ;
210232 }
211233 return children ;
212234 }
@@ -226,18 +248,18 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
226248 ComponentTypesView . instance . refresh ( ) ;
227249 }
228250
229- public static getSampleRepositoryUrl ( element ) : string {
251+ public static getSampleRepositoryUrl ( element : ExampleProject ) : string {
230252 let url : string ;
231- if ( isImageStreamTag ( element ) ) {
232- url = element . annotations . sampleRepo ;
253+ if ( isSampleProject ( element ) ) {
254+ url = element . sampleRepo ;
233255 } else if ( isStarterProject ( element ) ) {
234256 url = Object . values ( element . git . remotes ) . find ( ( prop ) => typeof prop === 'string' ) ;
235257 }
236258 return url ;
237259 }
238260
239261 @vsCommand ( 'openshift.componentType.openStarterProjectRepository' )
240- public static async openRepositoryURL ( element : ComponentType ) : Promise < void | string > {
262+ public static async openRepositoryURL ( element : ExampleProject ) : Promise < void | string > {
241263 const url : string = ComponentTypesView . getSampleRepositoryUrl ( element ) ;
242264 if ( url ) {
243265 try {
@@ -252,7 +274,7 @@ export class ComponentTypesView implements TreeDataProvider<ComponentType> {
252274 }
253275
254276 @vsCommand ( 'openshift.componentType.cloneStarterProjectRepository' )
255- public static async cloneRepository ( element : ComponentType ) : Promise < void | string > {
277+ public static async cloneRepository ( element : ExampleProject ) : Promise < void | string > {
256278 const url : string = ComponentTypesView . getSampleRepositoryUrl ( element ) ;
257279 if ( url ) {
258280 try {
0 commit comments