fix(web): default new work item to the first project in sidebar order - #9593
Open
gaerae wants to merge 1 commit into
Open
fix(web): default new work item to the first project in sidebar order#9593gaerae wants to merge 1 commit into
gaerae wants to merge 1 commit into
Conversation
The create work item modal falls back to `allowedProjectIds[0]`, which the issue modal provider builds with `Object.keys(projectsWithCreatePermissions)`. That map is keyed in the order the `project-roles` endpoint returns rows, i.e. by `ProjectMember.created_at` descending, so the preselected project has no relation to the order projects are listed in the sidebar and in the modal's own project dropdown. It also includes archived projects, so the modal can preselect a project that is not in the dropdown at all, and saving then fails with a 500 from the work item create endpoint. Derive the fallback list from `joinedProjectIds` instead, which is sorted by `sort_order` and excludes archived projects, so the default project is the first project the user sees.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe issue modal provider now derives create-permitted project IDs from ordered, non-archived project memberships instead of permission-map keys. ChangesIssue modal project selection
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The New work item modal preselects
allowedProjectIds[0], and the issue modal provider builds that list withObject.keys(projectsWithCreatePermissions). That map is the response ofGET /api/users/me/workspaces/<slug>/project-roles/, whose key order is theProjectMemberdefault ordering("-created_at",)— the order the user joined the projects, newest first.Everything the user sees is ordered by
sort_orderinstead: the sidebar and the modal's ownProjectDropdownboth readjoinedProjectIdsfrom the project store. The two orders match on a fresh workspace and drift apart as soon as projects are dragged into a different order, since dragging writesProjectUserProperty.sort_orderand leavesProjectMember.created_atuntouched. The preselected project then has no relation to the list the user is looking at.The permission map is also not filtered by
archived_at, so an archived project can end up asallowedProjectIds[0]. It is absent from the dropdown (that list excludes archived projects), so the modal preselects a project the user cannot see or pick, and saving fails with a 500 from the work item create endpoint.This derives the fallback list from
joinedProjectIdsand keeps only the projects the user can create in. The list stays in the order the user sees, archived projects drop out, and everything else about the modal is unchanged — a project id from the route still wins over the fallback, and an explicitallowedProjectIdsprop is still passed straight through.Fixes #9592
Type of Change
Screenshots and Media (if applicable)
Six projects, with the sidebar dragged into the order
Alpha, Bravo, Echo, Delta, Charlie, Foxtrot.Before — the modal preselects
Foxtrot, the last project in the sidebar:After — the modal preselects
Alpha, the first project in the sidebar:Archived-project variant, before the change —
Foxtrotis archived, so it is gone from the sidebar and from the modal's project dropdown, yet the modal still preselects it andSavereturns a 500:Test Scenarios
Verified against a self-hosted v1.4.1 stack (
makeplane/plane-backend:v1.4.1and friends) with the web app running from source, in a workspace with six projects that were dragged out of their default order:Alpha, the first project in the sidebar, instead ofFoxtrot. The dropdown order and contents are unchanged.Foxtrotarchived: before the change the modal preselected it andSavereturned500; after the change the modal preselectsAlphaand the work item is created.Foxtrotputs it back at the bottom of the sidebar, and the default staysAlpha./<workspace>/projects/<id>/issues/) still preselects that project — the route still takes precedence over the fallback.pnpm --filter web check:types,oxlintandoxfmt --checkpass on the changed file.No unit tests are included:
apps/webhas no test runner configured, so there is nowhere to hang a spec for this yet.References
Fixes #9592
Summary by CodeRabbit