fix: stabilize workspace kind ordering - #1344
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@christian-heusel @andyatmiami PR is up: #1344. Thanks again for the guidance and for helping me validate the direction before implementation. I kept the change focused on deterministic frontend ordering and added regression coverage for the default sort and tie-breaker. Would appreciate your review when you get a chance! |
christian-heusel
left a comment
There was a problem hiding this comment.
@thisis-Shitanshu great job on your first PR to this repository 🎉
I briefly reviewed your changes, see the comments below 😊
There was a problem hiding this comment.
Why did you opt to add the fix add the presentation layer instead of the data layer? 😊 the useWorkspaceKinds() hook is also used in other parts of the code, did you audit them if they suffer from the same issue? Some have other sorting mechanisms, but might be sensible to look at 😊
There was a problem hiding this comment.
Very good point. My initial reason for keeping this in WorkspaceFormKindList came partly from the earlier discussion with @andyatmiami about whether the PatternFly container should own the ordering. We found that Gallery itself doesn't own ordering, and the adjacent Image and PodConfig list components also prepare their ordering before rendering, so I treated this as frontend list/presentation preparation.
After your comment, I audited all production consumers of useWorkspaceKinds():
WorkspaceFormKindSelectionpasses the result into theWorkspaceKindcard list, which is the flow affected by this issue.WorkspaceKinds.tsxapplies its own sorting based on the active table sort.WorkspaceTable.tsxonly uses the result to build the kind/logo lookup.useWorkspaceFormData.tsuses it for lookup, so ordering is irrelevant there.
So currently only the Create Workspace flow depends on this default ordering, while one consumer replaces the ordering and the other two are order-insensitive. There will be a small redundant sort for WorkspaceKinds.tsx if we move this into the hook, but here that cost is negligible.
This still seems consistent with the earlier discussion with Andy because the ordering remains in the frontend data-preparation layer rather than being delegated to PatternFly.
I also noticed the duplicate useWorkspaceKinds() / API requests again while auditing this. That's already tracked separately in #1112, so I'd keep that out of this PR and will look at it independently.
Signed-off-by: Shitanshu Pandey <shitanshu.19p@gmail.com>
2014112 to
3620a17
Compare
|
/ok-to-test |
What
Sort WorkspaceKinds by
displayNamebefore rendering them in the Create Workspace form, usingnameas a deterministic tie-breaker.Why
The WorkspaceKinds API does not guarantee a presentation order, so the order of cards on the Create Workspace page could change between page refreshes.
The frontend owns presentation sorting for WorkspaceKinds, so the selection list should apply a deterministic default order before rendering.
Testing
Added unit coverage for ordering WorkspaceKinds by
displayNameAdded coverage for deterministic ordering when display names are equal
454/454 Jest tests pass
Create Workspace Cypress suite passes 73/73 tests
Manually verified across repeated page refreshes that the UI consistently renders:
even when the WorkspaceKinds API returns the items in different orders
The full mocked Cypress run has one unrelated failure in
workspaces/secretsEdit.cy.ts. The same failure is reproducible on a cleanorigin/notebooks-v2checkout.Related
related: #336
related: #1112
#336 documents the decision to keep paging, sorting, and filtering in the frontend.
#1112 separately tracks duplicate WorkspaceKind requests and is not addressed by this change.