Skip to content

Commit

Permalink
fix(trees): Update icon when folder/session is collapsed
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Sep 27, 2023
1 parent 51fb511 commit cc45df7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
9 changes: 8 additions & 1 deletion packages/zowe-explorer/__mocks__/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ export namespace extensions {
};
}
}

export interface TreeViewExpansionEvent<T> {
/**
* Element that is expanded or collapsed.
*/
readonly element: T;
}
export interface TreeView<T> {
/**
* An optional human-readable message that will be rendered in the view.
Expand Down Expand Up @@ -177,6 +182,8 @@ export interface TreeView<T> {
* **NOTE:** The {@link TreeDataProvider} that the `TreeView` {@link window.createTreeView is registered with} with must implement {@link TreeDataProvider.getParent getParent} method to access this API.
*/
reveal(element: T, options?: { select?: boolean; focus?: boolean; expand?: boolean | number }): Thenable<void>;

onDidCollapseElement: Event<TreeViewExpansionEvent<T>>;
}

export class FileDecoration {
Expand Down
9 changes: 9 additions & 0 deletions packages/zowe-explorer/src/dataset/DatasetTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ export class DatasetTree extends ZoweTreeProvider implements IZoweTree<IZoweData
treeDataProvider: this,
canSelectMany: true,
});
this.treeView.onDidCollapseElement((e) => {
const newIcon = getIconByNode(e.element);
if (contextually.isPds(e.element) || contextually.isDsSession(e.element)) {
if (newIcon) {
e.element.iconPath = newIcon;
this.mOnDidChangeTreeData.fire(e.element);
}
}
});
}

/**
Expand Down
9 changes: 9 additions & 0 deletions packages/zowe-explorer/src/job/ZosJobsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ export class ZosJobsProvider extends ZoweTreeProvider implements IZoweTree<IZowe
treeDataProvider: this,
canSelectMany: true,
});
this.treeView.onDidCollapseElement((e) => {
const newIcon = getIconByNode(e.element);
if (contextually.isJob(e.element) || contextually.isJobsSession(e.element)) {
if (newIcon) {
e.element.iconPath = newIcon;
this.mOnDidChangeTreeData.fire(e.element);
}
}
});
}

public rename(_node: IZoweJobTreeNode): void {
Expand Down
6 changes: 3 additions & 3 deletions packages/zowe-explorer/src/uss/USSTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ export class USSTree extends ZoweTreeProvider implements IZoweTree<IZoweUSSTreeN
canSelectMany: true,
});
this.treeView.onDidCollapseElement((e) => {
if (contextually.isUssDirectory(e.element)) {
const newIcon = getIconByNode(e.element);
const newIcon = getIconByNode(e.element);
if (contextually.isUssDirectory(e.element) || contextually.isUssSession(e.element)) {
if (newIcon) {
e.element.iconPath = newIcon;
this.mOnDidChangeTreeData.fire(e.element);
}
}
})
});
}

/**
Expand Down

0 comments on commit cc45df7

Please sign in to comment.