Fix/issue 4371 migrated datasets sorting#4406
Conversation
9b6b96d to
94196c5
Compare
94196c5 to
01dde83
Compare
traeok
left a comment
There was a problem hiding this comment.
The symptom ("migrated data sets always shown at the bottom") happens on load, and sortTreeItems is never called on the load path. sortTreeItems is only invoked from addFavorite / addMemberToFavorites (in-session add-time). Favorites are loaded by refreshFavorites, which reads from separate persistence buckets and concatenates migrated ones last:
const combinedLines = [
...this.mPersistence.readFavorites(),
...this.mPersistence.readVsamFavorites(),
...this.mPersistence.readMemberFavorites(),
...this.mPersistence.readMigratedFavorites(), // appended LAST
];refreshFavorites then pushes these into favProfileNode.children in that order with no sort. Correspondingly, updateFavorites splits migrated favorites into their own migratedFavorites bucket on save. So migrated favorites are persisted separately and always reloaded at the end of the list - and no in-memory sort survives a restart.
The correct fix is to sort each profile's children after loading - for example, call the existing, unmodified SharedUtils.sortTreeItems(favProfileNode.children, Constants.DS_SESSION_CONTEXT + Constants.FAV_SUFFIX) at the end of refreshFavorites (my manual test shows the original signature already interleaves migrated alphabetically). The string | string[] signature change is unnecessary for the real fix.
traeok
left a comment
There was a problem hiding this comment.
See above comments for details
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4406 +/- ##
=======================================
Coverage 94.85% 94.85%
=======================================
Files 146 146
Lines 30936 30948 +12
Branches 7643 7644 +1
=======================================
+ Hits 29344 29356 +12
Misses 1592 1592 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
01dde83 to
44d5250
Compare
44d5250 to
6ab9a37
Compare
This fixes zowe#4371 Signed-off-by: Saksham Gupta <sakshamgupta@Jawahars-MacBook-Air-2.local>
6ab9a37 to
34f134a
Compare
Proposed changes
Resolves #4371.
Previously,
SharedUtils.sortTreeItemsonly accepted a single string forspecificContext, andDatasetTree.tspassedConstants.DS_SESSION_CONTEXT + Constants.FAV_SUFFIX. Because migrated datasets use the distinctDS_MIGRATED_FILE_CONTEXT, they failed the string match and were systematically pushed to the bottom of the array during the Favorites tree sort.This PR updates
SharedUtils.sortTreeItemsto accept an array of contexts (specificContext: string | string[]) and updatesDatasetTree.tsto pass an array containing both the standard dataset context and the migrated dataset context, allowing them to sort together alphabetically.Release Notes
Milestone: TBD
Changelog: Fix migrated datasets in favorites appearing at the bottom rather than sorting alphabetically
Types of changes
Checklist
All checks must pass before this pull request is reviewed by the Zowe Explorer squad.
General
yarn workspace vscode-extension-for-zowe vscode:prepublishpnpm --filter vscode-extension-for-zowe vscode:prepublishCode coverage
Deployment
Further comments
The unit tests in
SharedUtils.unit.test.tsnaturally support this modification, and the entire test suite has been run and passes locally.