Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort-Jobs Implemented #2462

Merged
merged 6 commits into from
Sep 19, 2023
Merged

Conversation

likhithanimma1
Copy link
Contributor

Proposed changes

Implemented the feature of sorting jobs in the jobs tree at the zosmf level based on the required criteria sortby id, name, returncode.

Release Notes

Milestone:

Changelog:

Types of changes

What types of changes does your code introduce to Zowe Explorer?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Updates to Documentation or Tests (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This checklist will be used as reference for both the contributor and the reviewer

  • I have read the CONTRIBUTOR GUIDANCE wiki
  • PR title follows Conventional Commits Guidelines
  • PR Description is included
  • gif or screenshot is included if visual changes are made
  • yarn workspace vscode-extension-for-zowe vscode:prepublish has been executed
  • All checks have passed (DCO, Jenkins and Code Coverage)
  • I have added unit test and it is passing
  • I have added integration test and it is passing
  • There is coverage for the code that I have added
  • I have tested it manually and there are no regressions found
  • I have added necessary documentation (if appropriate)
  • Any PR dependencies have been merged and published (if appropriate)

Further comments

Signed-off-by: Likhitha Nimma <[email protected]>
@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Patch coverage is 93.33% of modified lines.

Files Changed Coverage
packages/zowe-explorer/src/job/init.ts 75.00%
packages/zowe-explorer/src/globals.ts 100.00%
packages/zowe-explorer/src/job/actions.ts 100.00%

📢 Thoughts on this report? Let us know!.

@JillieBeanSim JillieBeanSim added this to the v2.12.0 milestone Sep 13, 2023
@@ -121,6 +121,21 @@
}
],
"commands": [
{
"command": "zowe.jobs.sortbyreturncode",
"title": "Sort by returncode",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add these new command titles to the package.nls.json file and reference them here like the other commands for localization, thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified the command titles in package.json and updated the respective in package.nls.json file

Copy link
Contributor

@JillieBeanSim JillieBeanSim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the couple cosmetic text items I mentioned this is working great! thanks @likhithanimma1

Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this enhancement - tested and functionality LGTM @likhithanimma1!

To minimize code duplication, could we consolidate sortById, sortByName, sortByReturnCode (in jobs/actions.ts) into one action, and then call it with a different parameter based on what command was executed? The logic is similar across these actions, so this would make maintenance easier. For example:

export async function sortJobsBy(jobs: IZoweJobTreeNode, jobsProvider: IZoweTree<IZoweJobTreeNode>, key: keyof zowe.IJob): Promise<void> {
   jobs["children"].sort((x, y) => {
       if (key !== "jobid" && x["job"][key] == y["job"][key]) {
           // if values for this key are identical, sort by job ID
       } else {
           return x["job"][key] > y["job"][key] ? 1 : -1;
       }
   });
   jobsProvider.refresh();
}

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
1.2% 1.2% Duplication

@likhithanimma1
Copy link
Contributor Author

Thanks for working on this enhancement - tested and functionality LGTM @likhithanimma1!

To minimize code duplication, could we consolidate sortById, sortByName, sortByReturnCode (in jobs/actions.ts) into one action, and then call it with a different parameter based on what command was executed? The logic is similar across these actions, so this would make maintenance easier. For example:

export async function sortJobsBy(jobs: IZoweJobTreeNode, jobsProvider: IZoweTree<IZoweJobTreeNode>, key: keyof zowe.IJob): Promise<void> {
   jobs["children"].sort((x, y) => {
       if (key !== "jobid" && x["job"][key] == y["job"][key]) {
           // if values for this key are identical, sort by job ID
       } else {
           return x["job"][key] > y["job"][key] ? 1 : -1;
       }
   });
   jobsProvider.refresh();
}

Thanks for letting me know @traeok . Updated the actions.ts file to contain the whole in 1 function .

Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and in Theia, functioning as expected - thanks for making those adjustments @likhithanimma1

Copy link
Contributor

@JillieBeanSim JillieBeanSim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks @likhithanimma1 for this enhancement.

@JillieBeanSim JillieBeanSim merged commit 5309909 into zowe:main Sep 19, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants