Skip to content

Commit

Permalink
Merge branch 'main' into fix-for-unsecure-profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
rudyflores authored Oct 23, 2023
2 parents 88b5ae4 + 464d712 commit 01441d3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen
- Added new API {ZE Extender MetaData} to allow extenders to have the metadata of registered extenders to aid in team configuration file creation from a view that isn't Zowe Explorer's. [#2394](https://github.com/zowe/vscode-extension-for-zowe/issues/2394)
- Added "Sort PDS members" feature in Data Sets tree view: accessible via sort icon on session node, or by right-clicking a PDS or session. [#2420](https://github.com/zowe/vscode-extension-for-zowe/issues/2420)
- Added "Filter PDS members" feature in Data Sets tree view: accessible via filter icon on session node, or by right-clicking a PDS or session. [#2420](https://github.com/zowe/vscode-extension-for-zowe/issues/2420)
- Added descriptions to data set nodes if filtering and/or sorting is enabled (where applicable).
- Added webview for editing persistent items on Zowe Explorer [#2488](https://github.com/zowe/vscode-extension-for-zowe/issues/2488)

### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,7 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
expect(mocks.nodeDataChanged).toHaveBeenCalled();
expect(mocks.refreshElement).not.toHaveBeenCalled();
expect(nodes.pds.children?.map((c: IZoweDatasetTreeNode) => c.label)).toStrictEqual(["A", "B", "C"]);
expect(nodes.pds.children?.reduce((val, cur) => val + (cur.description as string), "")).toBe("");
});

it("sorts by last modified date", async () => {
Expand Down Expand Up @@ -2805,6 +2806,17 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
expect(mocks.refreshElement).not.toHaveBeenCalled();
expect(sortPdsMembersDialog).toHaveBeenCalledTimes(2);
});

it("sorting by session: descriptions are reset when sorted by name", async () => {
const mocks = getBlockMocks();
const nodes = nodesForSuite();
mocks.showQuickPick.mockResolvedValueOnce({ label: "$(case-sensitive) Name (default)" });
await tree.sortPdsMembersDialog(nodes.session);
expect(mocks.nodeDataChanged).toHaveBeenCalled();
expect(mocks.refreshElement).not.toHaveBeenCalled();
expect(nodes.pds.children?.map((c: IZoweDatasetTreeNode) => c.label)).toStrictEqual(["A", "B", "C"]);
expect(nodes.pds.children?.reduce((val, cur) => val + (cur.description as string), "")).toBe("");
});
});

describe("filterBy & filterPdsMembersDialog", () => {
Expand All @@ -2831,7 +2843,8 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
nodes.pds.filter = { method: DatasetFilterOpts.UserId, value: "invalidUserId" };
nodes.pds.children = [];
await tree.filterPdsMembersDialog(nodes.pds);
expect(mocks.nodeDataChanged).not.toHaveBeenCalled();
// nodeDataChanged called once to show new description
expect(mocks.nodeDataChanged).toHaveBeenCalledWith(nodes.pds);
expect(mocks.refreshElement).toHaveBeenCalledWith(nodes.pds);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"setSortDirection": "$(fold) Sort Direction",
"sort.selectDirection": "Select a sorting direction",
"sort.updated": "$(check) Sorting updated for {0}",
"filter.description": "Filter: {0}",
"ds.clearProfileFilter": "$(clear-all) Clear filter for profile",
"ds.clearPdsFilter": "$(clear-all) Clear filter for PDS",
"ds.selectFilterOpt": "Set a filter for {0}",
Expand Down
11 changes: 11 additions & 0 deletions packages/zowe-explorer/src/dataset/DatasetTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1336,12 +1336,21 @@ export class DatasetTree extends ZoweTreeProvider implements IZoweTree<IZoweData
for (const c of node.children) {
if (contextually.isPds(c) && c.children) {
c.sort = node.sort;
for (const ch of c.children) {
// remove any descriptions from child nodes
ch.description = "";
}

c.children.sort(ZoweDatasetNode.sortBy(node.sort));
this.nodeDataChanged(c);
}
}
}
} else if (node.children?.length > 0) {
for (const c of node.children) {
// remove any descriptions from child nodes
c.description = "";
}
// children nodes already exist, sort and repaint to avoid extra refresh
node.children.sort(ZoweDatasetNode.sortBy(node.sort));
this.nodeDataChanged(node);
Expand Down Expand Up @@ -1413,6 +1422,8 @@ export class DatasetTree extends ZoweTreeProvider implements IZoweTree<IZoweData
public updateFilterForNode(node: IZoweDatasetTreeNode, newFilter: DatasetFilter | null, isSession: boolean): void {
const oldFilter = node.filter;
node.filter = newFilter;
node.description = newFilter ? localize("filter.description", "Filter: {0}", newFilter.value) : null;
this.nodeDataChanged(node);

// if a session was selected, apply this sort to all PDS members
if (isSession) {
Expand Down
11 changes: 9 additions & 2 deletions packages/zowe-explorer/src/dataset/ZoweDatasetNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod
// missing keys from API response; check for FTP keys
temp.stats = {
user: item.id,
modifiedDate: item.changed ? dayjs(item.changed).toDate() : null,
modifiedDate: item.changed ? dayjs(item.changed).toDate() : undefined,
};
}
elementChildren[temp.label.toString()] = temp;
Expand Down Expand Up @@ -332,13 +332,20 @@ export class ZoweDatasetNode extends ZoweTreeNode implements IZoweDatasetTreeNod
const sortLessThan = sort.direction == SortDirection.Ascending ? -1 : 1;
const sortGreaterThan = sortLessThan * -1;

if (!a.stats && !b.stats) {
return (a.label as string) < (b.label as string) ? sortLessThan : sortGreaterThan;
}

switch (sort.method) {
case DatasetSortOpts.LastModified:
a.description = dayjs(a.stats?.modifiedDate).format("YYYY/MM/DD HH:mm:ss");
b.description = dayjs(b.stats?.modifiedDate).format("YYYY/MM/DD HH:mm:ss");
return a.stats?.modifiedDate < b.stats?.modifiedDate ? sortLessThan : sortGreaterThan;
case DatasetSortOpts.UserId:
a.description = a.stats?.user;
b.description = b.stats?.user;
return a.stats?.user < b.stats?.user ? sortLessThan : sortGreaterThan;
case DatasetSortOpts.Name:
default:
return (a.label as string) < (b.label as string) ? sortLessThan : sortGreaterThan;
}
};
Expand Down

0 comments on commit 01441d3

Please sign in to comment.