diff --git a/packages/vsce/src/trees/treeItems/CICSLibraryTreeItem.ts b/packages/vsce/src/trees/treeItems/CICSLibraryTreeItem.ts index a06a5071..79b8c714 100644 --- a/packages/vsce/src/trees/treeItems/CICSLibraryTreeItem.ts +++ b/packages/vsce/src/trees/treeItems/CICSLibraryTreeItem.ts @@ -66,8 +66,7 @@ export class CICSLibraryTreeItem extends TreeItem { criteria: criteria, }); const datasetArray = toArray(libraryResponse.response.records.cicslibrarydatasetname); - this.label = `${this.library.name}${this.parentRegion.parentPlex ? ` (${this.library.eyu_cicsname})` : ""}${this.activeFilter ? ` (${this.activeFilter}) ` : " " - }[${datasetArray.length}]`; + this.label = this.buildLabel(datasetArray); for (const dataset of datasetArray) { const newDatasetItem = new CICSLibraryDatasets(dataset, this.parentRegion, this); //this=CICSLibraryTreeItem this.addDataset(newDatasetItem); @@ -78,8 +77,7 @@ export class CICSLibraryTreeItem extends TreeItem { window.showErrorMessage(`Resource Limit Exceeded - Set a datasets filter to narrow search`); } else if (this.children.length === 0) { window.showInformationMessage(`No datasets found`); - this.label = `${this.library.name}${this.parentRegion.parentPlex ? ` (${this.library.eyu_cicsname})` : ""}${this.activeFilter ? ` (${this.activeFilter}) ` : " " - }[0]`; + this.label = this.buildLabel([]); } else { window.showErrorMessage( `Something went wrong when fetching datasets - ${JSON.stringify(error, Object.getOwnPropertyNames(error)).replace( @@ -91,6 +89,16 @@ export class CICSLibraryTreeItem extends TreeItem { } } + private buildLabel(datasetArray?: any[]) { + let labelContent = this.library.name; + labelContent += this.parentRegion.parentPlex ? ` (${this.library.eyu_cicsname})` : ""; + labelContent += this.activeFilter ? ` (${this.activeFilter}) ` : " "; + if (datasetArray) { + labelContent += `[${datasetArray.length}]`; + } + return labelContent; + } + public clearFilter() { this.activeFilter = undefined; this.contextValue = `cicslibrary.${this.activeFilter ? "filtered" : "unfiltered"}${this.library.name}`;