@@ -498,7 +498,10 @@ export class NamespaceTreeItem extends SMTreeItem {
498498 * @returns feature folders of a namespace.
499499 */
500500async function namespaceFeatures ( element : NamespaceTreeItem , params ?: any ) : Promise < FeatureTreeItem [ ] | undefined > {
501- return [ new ProjectsTreeItem ( { parent : element , id : element . name , label : element . name } , params . serverName ) ] ;
501+ return [
502+ new ProjectsTreeItem ( { parent : element , id : element . name , label : element . name } , params . serverName ) ,
503+ new WebAppsTreeItem ( { parent : element , id : element . name , label : element . name } , params . serverName )
504+ ] ;
502505}
503506
504507export class ProjectsTreeItem extends FeatureTreeItem {
@@ -585,3 +588,76 @@ export class ProjectTreeItem extends SMTreeItem {
585588 this . iconPath = new vscode . ThemeIcon ( 'files' ) ;
586589 }
587590}
591+
592+ export class WebAppsTreeItem extends FeatureTreeItem {
593+ public readonly name : string ;
594+ constructor (
595+ element : ISMItem ,
596+ serverName : string
597+ ) {
598+ const parentFolderId = element . parent ?. id || '' ;
599+ super ( {
600+ parent : element . parent ,
601+ label : 'Web Applications' ,
602+ id : parentFolderId + ':webapps' ,
603+ tooltip : `Web Applications in this namespace` ,
604+ getChildren : namespaceWebApps ,
605+ params : { serverName, ns : element . label }
606+ } ) ;
607+ this . name = 'Web Applications' ;
608+ this . contextValue = 'webapps' ;
609+ this . iconPath = new vscode . ThemeIcon ( 'library' ) ;
610+ }
611+ }
612+
613+ /**
614+ * getChildren function returning web applications in a server namespace.
615+ *
616+ * @param element parent
617+ * @param params { serverName }
618+ * @returns web applications in a server namespace.
619+ */
620+ async function namespaceWebApps ( element : ProjectsTreeItem , params ?: any ) : Promise < WebAppTreeItem [ ] | undefined > {
621+ const children : ProjectTreeItem [ ] = [ ] ;
622+
623+ if ( params ?. serverName && params . ns ) {
624+ const name : string = params . serverName ;
625+ const serverSpec = await getServerSpec ( name )
626+ if ( ! serverSpec ) {
627+ return undefined
628+ }
629+
630+ const response = await makeRESTRequest (
631+ "GET" ,
632+ serverSpec ,
633+ { apiVersion : 1 , namespace : "%SYS" , path : `/cspapps/${ params . ns } ` }
634+ ) ;
635+ if ( response !== undefined ) {
636+ if ( response . data . result . content === undefined ) {
637+ vscode . window . showErrorMessage ( response . data . status . summary ) ;
638+ return undefined ;
639+ }
640+ response . data . result . content . map ( ( webapp : string ) => {
641+ children . push ( new WebAppTreeItem ( { parent : element , label : name , id : name } , webapp ) ) ;
642+ } ) ;
643+ }
644+ }
645+
646+ return children ;
647+ }
648+
649+ export class WebAppTreeItem extends SMTreeItem {
650+ public readonly name : string ;
651+ constructor ( element : ISMItem , name : string ) {
652+ const parentFolderId = element . parent ?. id || '' ;
653+ const id = parentFolderId + ':' + name ;
654+ super ( {
655+ parent : element . parent ,
656+ label : name ,
657+ id
658+ } ) ;
659+ this . name = name ;
660+ this . contextValue = 'webapp' ;
661+ this . iconPath = new vscode . ThemeIcon ( 'file-code' ) ;
662+ }
663+ }
0 commit comments