Skip to content

Commit

Permalink
Add new settings for default dataset & job sort orders
Browse files Browse the repository at this point in the history
Added two new settings:
- zowe.ds.default.sort
- zowe.jobs.default.sort

They use the same defaults as is currently hardcoded.

The '(default)' is no longer hardcoded and is changed based on the settings.

TODO:
Tests need to be edited/written to reflect new feature/changes.
Perhaps include sort order persistence in the feature?

Signed-off-by: Buckminsterfullerene02 <[email protected]>
  • Loading branch information
Buckminsterfullerene02 committed Dec 21, 2024
1 parent aea6d92 commit 790c29f
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2928,13 +2928,13 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
const mocks = getBlockMocks();
const nodes = nodesForSuite();
// case 1: called on PDS node
mocks.showQuickPick.mockResolvedValueOnce({ label: "$(case-sensitive) Name (default)" });
mocks.showQuickPick.mockResolvedValueOnce({ label: "$(case-sensitive) Name" });
nodes.pds.children = [];
await tree.sortPdsMembersDialog(nodes.pds);
expect(mocks.nodeDataChanged).not.toHaveBeenCalled();

// case 2: called on session node
mocks.showQuickPick.mockResolvedValueOnce({ label: "$(case-sensitive) Name (default)" });
mocks.showQuickPick.mockResolvedValueOnce({ label: "$(case-sensitive) Name" });
nodes.session.children = [];
await tree.sortPdsMembersDialog(nodes.session);
expect(mocks.nodeDataChanged).not.toHaveBeenCalled();
Expand All @@ -2943,7 +2943,7 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
it("sorts by name", async () => {
const mocks = getBlockMocks();
const nodes = nodesForSuite();
mocks.showQuickPick.mockResolvedValueOnce({ label: "$(case-sensitive) Name (default)" });
mocks.showQuickPick.mockResolvedValueOnce({ label: "$(case-sensitive) Name" });
await tree.sortPdsMembersDialog(nodes.pds);
expect(mocks.nodeDataChanged).toHaveBeenCalled();
expect(mocks.refreshElement).not.toHaveBeenCalled();
Expand Down Expand Up @@ -3107,7 +3107,7 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
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)" });
mocks.showQuickPick.mockResolvedValueOnce({ label: "$(case-sensitive) Name" });
await tree.sortPdsMembersDialog(nodes.session);
expect(mocks.nodeDataChanged).toHaveBeenCalled();
expect(mocks.refreshElement).not.toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ describe("sortJobs function", () => {
testtree.mSessionNodes[0].children = [...[globalMocks.mockJobArray[2], globalMocks.mockJobArray[1], globalMocks.mockJobArray[0]]];
expected.mSessionNodes[0].children = [...[globalMocks.mockJobArray[1], globalMocks.mockJobArray[0], globalMocks.mockJobArray[2]]];
const sortbyidspy = jest.spyOn(JobTree.prototype, "sortBy");
jest.spyOn(Gui, "showQuickPick").mockResolvedValueOnce({ label: "$(list-ordered) Job ID (default)" });
jest.spyOn(Gui, "showQuickPick").mockResolvedValueOnce({ label: "$(list-ordered) Job ID" });
//act
await JobActions.sortJobs(testtree.mSessionNodes[0], testtree);
//asert
Expand Down
17 changes: 14 additions & 3 deletions packages/zowe-explorer/l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,15 @@
"No spool files found": "No spool files found",
"No jobs found": "No jobs found",
"Retrieving response from JES list API": "Retrieving response from JES list API",
"Job ID (default)": "Job ID (default)",
"Job ID": "Job ID",
"Date Submitted": "Date Submitted",
"Date Completed": "Date Completed",
"Job Name": "Job Name",
"Return Code": "Return Code",
"Sort Direction": "Sort Direction",
"Go to Local Filtering": "Go to Local Filtering",
"Clear filter for profile": "Clear filter for profile",
"(default)": "(default)",
"Create new...": "Create new...",
"Submit this query": "Submit this query",
"Enter job owner ID": "Enter job owner ID",
Expand Down Expand Up @@ -577,7 +578,6 @@
"No data sets found": "No data sets found",
"Retrieving response from MVS list API": "Retrieving response from MVS list API",
"Cannot download, item invalid.": "Cannot download, item invalid.",
"Name (default)": "Name (default)",
"Date Created": "Date Created",
"Date Modified": "Date Modified",
"User ID": "User ID",
Expand Down Expand Up @@ -898,7 +898,6 @@
"The number of data sets that are about to be searched"
]
},
"Percent Complete": "Percent Complete",
"Failed to upload changes for {0}: {1}/Build file hyperlinkError message": {
"message": "Failed to upload changes for {0}: {1}",
"comment": [
Expand All @@ -907,6 +906,18 @@
]
},
"Error encountered while activating and initializing logger": "Error encountered while activating and initializing logger",
"Insufficient read permissions for {0} in local storage./Local storage key": {
"message": "Insufficient read permissions for {0} in local storage.",
"comment": [
"Local storage key"
]
},
"Insufficient write permissions for {0} in local storage./Local storage key": {
"message": "Insufficient write permissions for {0} in local storage.",
"comment": [
"Local storage key"
]
},
"Add Credentials": "Add Credentials",
"Add username and password for basic authentication": "Add username and password for basic authentication",
"Update stored username and password": "Update stored username and password",
Expand Down
70 changes: 67 additions & 3 deletions packages/zowe-explorer/l10n/poeditor.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,36 @@
"zowe.ds.default.ps": {
"Default values of Sequential data set creation": ""
},
"zowe.ds.default.sort": {
"Default sort order of data set tree": ""
},
"zowe.ds.default.sort.method.name": {
"Sort by name": ""
},
"zowe.ds.default.sort.method.dateCreated": {
"Sort by date created": ""
},
"zowe.ds.default.sort.method.lastModified": {
"Sort by last modified": ""
},
"zowe.ds.default.sort.method.userId": {
"Sort by user ID": ""
},
"zowe.ds.default.sort.method.description": {
"Default method to sort datasets": ""
},
"zowe.ds.default.sort.direction.ascending": {
"Sort in ascending order": ""
},
"zowe.ds.default.sort.direction.descending": {
"Sort in descending order": ""
},
"zowe.ds.default.sort.direction.description": {
"Default direction to sort datasets": ""
},
"zowe.ds.default.sort.description": {
"Default sort order for datasets": ""
},
"zowe.ds.history": {
"Toggle if favorite files persist locally": ""
},
Expand All @@ -239,6 +269,39 @@
"zowe.jobs.history": {
"Toggle if Jobs favorite files persist locally": ""
},
"zowe.jobs.default.sort": {
"Default sort order of job tree": ""
},
"zowe.jobs.default.sort.method.id": {
"Sort by job ID": ""
},
"zowe.jobs.default.sort.method.dateSubmitted": {
"Sort by date submitted": ""
},
"zowe.jobs.default.sort.method.dateCompleted": {
"Sort by date completed": ""
},
"zowe.jobs.default.sort.method.name": {
"Sort by name": ""
},
"zowe.jobs.default.sort.method.returnCode": {
"Sort by return code": ""
},
"zowe.jobs.default.sort.method.description": {
"Default method to sort jobs": ""
},
"zowe.jobs.default.sort.direction.ascending": {
"Sort in ascending order": ""
},
"zowe.jobs.default.sort.direction.descending": {
"Sort in descending order": ""
},
"zowe.jobs.default.sort.direction.description": {
"Default direction to sort jobs": ""
},
"zowe.jobs.default.sort.description": {
"Default sort order for jobs": ""
},
"zowe.jobs.confirmSubmission": {
"Require user confirmation before submitting a job": ""
},
Expand Down Expand Up @@ -623,14 +686,15 @@
"No spool files found": "",
"No jobs found": "",
"Retrieving response from JES list API": "",
"Job ID (default)": "",
"Job ID": "",
"Date Submitted": "",
"Date Completed": "",
"Job Name": "",
"Return Code": "",
"Sort Direction": "",
"Go to Local Filtering": "",
"Clear filter for profile": "",
"(default)": "",
"Create new...": "",
"Submit this query": "",
"Enter job owner ID": "",
Expand Down Expand Up @@ -696,7 +760,6 @@
"No data sets found": "",
"Retrieving response from MVS list API": "",
"Cannot download, item invalid.": "",
"Name (default)": "",
"Date Created": "",
"Date Modified": "",
"User ID": "",
Expand Down Expand Up @@ -813,9 +876,10 @@
"Contents": "",
"Open": "",
"Are you sure you want to search {0} data sets and members?": "",
"Percent Complete": "",
"Failed to upload changes for {0}: {1}": "",
"Error encountered while activating and initializing logger": "",
"Insufficient read permissions for {0} in local storage.": "",
"Insufficient write permissions for {0} in local storage.": "",
"Add Credentials": "",
"Add username and password for basic authentication": "",
"Update stored username and password": "",
Expand Down
90 changes: 84 additions & 6 deletions packages/zowe-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,50 @@
"description": "%zowe.ds.default.ps%",
"scope": "resource"
},
"zowe.ds.templates": {
"type": "array",
"default": [],
"description": "%zowe.ds.templates%",
"scope": "window"
},
"zowe.ds.default.sort": {
"type": "object",
"default": {
"method": "Name",
"direction": "Ascending"
},
"properties": {
"method": {
"type": "string",
"enum": [
"Name",
"DateCreated",
"LastModified",
"UserId"
],
"enumDescriptions": [
"%zowe.ds.default.sort.method.name%",
"%zowe.ds.default.sort.method.dateCreated%",
"%zowe.ds.default.sort.method.lastModified%",
"%zowe.ds.default.sort.method.userId%"
],
"description": "%zowe.ds.default.sort.method.description%"
},
"direction": {
"type": "string",
"enum": [
"Ascending",
"Descending"
],
"enumDescriptions": [
"%zowe.ds.default.sort.direction.ascending%",
"%zowe.ds.default.sort.direction.descending%"
],
"description": "%zowe.ds.default.sort.direction.description%"
}
},
"description": "%zowe.ds.default.sort.description%"
},
"zowe.ds.history": {
"default": {
"persistence": true,
Expand All @@ -1699,12 +1743,6 @@
"scope": "application",
"deprecationMessage": "%zowe.history.deprecationMsg%"
},
"zowe.ds.templates": {
"type": "array",
"default": [],
"description": "%zowe.ds.templates%",
"scope": "window"
},
"zowe.files.logsFolder.path": {
"type": "string",
"default": "",
Expand All @@ -1722,6 +1760,46 @@
"scope": "application",
"deprecationMessage": "%zowe.history.deprecationMsg%"
},
"zowe.jobs.default.sort": {
"type": "object",
"default": {
"method": "Name",
"direction": "Ascending"
},
"properties": {
"method": {
"type": "string",
"enum": [
"Id",
"DateSubmitted",
"DateCompleted",
"Name",
"ReturnCode"
],
"enumDescriptions": [
"%zowe.jobs.default.sort.method.id%",
"%zowe.jobs.default.sort.method.dateSubmitted%",
"%zowe.jobs.default.sort.method.dateCompleted%",
"%zowe.jobs.default.sort.method.name%",
"%zowe.jobs.default.sort.method.returnCode%"
],
"description": "%zowe.jobs.default.sort.method.description%"
},
"direction": {
"type": "string",
"enum": [
"Ascending",
"Descending"
],
"enumDescriptions": [
"%zowe.jobs.default.sort.direction.ascending%",
"%zowe.jobs.default.sort.direction.descending%"
],
"description": "%zowe.jobs.default.sort.direction.description%"
}
},
"description": "%zowe.jobs.default.sort.description%"
},
"zowe.jobs.history": {
"default": {
"persistence": true,
Expand Down
21 changes: 21 additions & 0 deletions packages/zowe-explorer/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,32 @@
"zowe.ds.default.pds": "Default values of Partitioned data set creation",
"zowe.ds.default.extended": "Default values of Partitioned data set extended creation",
"zowe.ds.default.ps": "Default values of Sequential data set creation",
"zowe.ds.default.sort": "Default sort order of data set tree",
"zowe.ds.default.sort.method.name": "Sort by name",
"zowe.ds.default.sort.method.dateCreated": "Sort by date created",
"zowe.ds.default.sort.method.lastModified": "Sort by last modified",
"zowe.ds.default.sort.method.userId": "Sort by user ID",
"zowe.ds.default.sort.method.description": "Default method to sort datasets",
"zowe.ds.default.sort.direction.ascending": "Sort in ascending order",
"zowe.ds.default.sort.direction.descending": "Sort in descending order",
"zowe.ds.default.sort.direction.description": "Default direction to sort datasets",
"zowe.ds.default.sort.description": "Default sort order for datasets",
"zowe.ds.history": "Toggle if favorite files persist locally",
"zowe.ds.templates": "Zowe Explorer saved data set templates",
"zowe.files.logsFolder.path": "Path to Zowe Explorer logs folder",
"zowe.uss.history": "Toggle if USS favorite files persist locally",
"zowe.jobs.history": "Toggle if Jobs favorite files persist locally",
"zowe.jobs.default.sort": "Default sort order of job tree",
"zowe.jobs.default.sort.method.id": "Sort by job ID",
"zowe.jobs.default.sort.method.dateSubmitted": "Sort by date submitted",
"zowe.jobs.default.sort.method.dateCompleted": "Sort by date completed",
"zowe.jobs.default.sort.method.name": "Sort by name",
"zowe.jobs.default.sort.method.returnCode": "Sort by return code",
"zowe.jobs.default.sort.method.description": "Default method to sort jobs",
"zowe.jobs.default.sort.direction.ascending": "Sort in ascending order",
"zowe.jobs.default.sort.direction.descending": "Sort in descending order",
"zowe.jobs.default.sort.direction.description": "Default direction to sort jobs",
"zowe.jobs.default.sort.description": "Default sort order for jobs",
"zowe.jobs.confirmSubmission": "Require user confirmation before submitting a job",
"zowe.jobs.confirmSubmission.yourJobs": "Your Jobs",
"zowe.jobs.confirmSubmission.otherUserJobs": "Other user Jobs",
Expand Down
2 changes: 2 additions & 0 deletions packages/zowe-explorer/src/configuration/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export class Constants {
public static readonly SETTINGS_DS_DEFAULT_EXTENDED = "zowe.ds.default.extended";
public static readonly SETTINGS_DS_DEFAULT_PS = "zowe.ds.default.ps";
public static readonly SETTINGS_DS_TEMPLATES = "zowe.ds.templates";
public static readonly SETTINGS_DS_DEFAULT_SORT = "zowe.ds.default.sort";
public static readonly SETTINGS_JOBS_DEFAULT_SORT = "zowe.jobs.default.sort";
public static readonly SETTINGS_COMMANDS_ALWAYS_EDIT = "zowe.commands.alwaysEdit";
public static readonly SETTINGS_AUTOMATIC_PROFILE_VALIDATION = "zowe.automaticProfileValidation";
public static readonly SETTINGS_SECURE_CREDENTIALS_ENABLED = "zowe.security.secureCredentialsEnabled";
Expand Down
16 changes: 11 additions & 5 deletions packages/zowe-explorer/src/trees/dataset/DatasetTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1303,11 +1303,16 @@ export class DatasetTree extends ZoweTreeProvider<IZoweDatasetTreeNode> implemen
public async sortPdsMembersDialog(node: IZoweDatasetTreeNode): Promise<void> {
const isSession = SharedContext.isSession(node);

// Assume defaults if a user hasn't selected any sort options yet
const sortOpts = node.sort ?? {
method: Sorting.DatasetSortOpts.Name,
direction: Sorting.SortDirection.Ascending,
};
// Read default options from settings if a user hasn't selected any sort options yet
const sortOpts = node.sort ?? SettingsConfig.getDirectValue<Sorting.NodeSort>(Constants.SETTINGS_DS_DEFAULT_SORT);
if (typeof sortOpts.method === "string") {
sortOpts.method = Sorting.DatasetSortOpts[sortOpts.method as keyof typeof Sorting.DatasetSortOpts];
DatasetUtils.updateSortOptionsWithDefault(sortOpts.method);
}
if (typeof sortOpts.direction === "string") {
sortOpts.direction = Sorting.SortDirection[sortOpts.direction as keyof typeof Sorting.SortDirection];
}
ZoweLogger.debug(`DatasetTree: sort options: ${JSON.stringify(sortOpts)}`);

// Adapt menus to user based on the node that was interacted with
const specifier = isSession
Expand Down Expand Up @@ -1348,6 +1353,7 @@ export class DatasetTree extends ZoweTreeProvider<IZoweDatasetTreeNode> implemen
...sortOpts,
direction: Constants.SORT_DIRS.indexOf(dir),
};
// TODO: Update sort order as persistence setting maybe
}
await this.sortPdsMembersDialog(node);
return;
Expand Down
Loading

0 comments on commit 790c29f

Please sign in to comment.