Skip to content

Commit

Permalink
library tree item label builder
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Twydell <[email protected]>
  • Loading branch information
AndrewTwydell committed Dec 18, 2024
1 parent 7e3de0a commit 37980ec
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/vsce/src/trees/treeItems/CICSLibraryTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand All @@ -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}`;
Expand Down

0 comments on commit 37980ec

Please sign in to comment.