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 4a581db commit d7cfb60
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Fixed issue where USS nodes were not removed from tree during deletion. [#2479](https://github.com/zowe/vscode-extension-for-zowe/issues/2479)
- Fixed issue where new USS nodes from a paste operation were not shown in tree until refreshed. [#2479](https://github.com/zowe/vscode-extension-for-zowe/issues/2479)
- Fixed issue where the "Delete Job" action showed a successful deletion message, even if the API returned an error.
- USS directories and sessions now update with their respective "collapsed icon" when collapsed.
- USS directories, PDS nodes, job nodes and session nodes now update with their respective "collapsed icon" when collapsed.

## `2.11.0`

Expand Down
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 d7cfb60

Please sign in to comment.