feat(activity-feed-v2): add contact mapping utility for task modal v2#4657
feat(activity-feed-v2): add contact mapping utility for task modal v2#4657jackiejou wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds contact-mapping helpers for collaborator, contact, and assignee conversions, including group support, raw ID preservation, and Jest coverage for the mapping paths. ChangesContact mapping utilities
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Suggested reviewers
Poem
🚥 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 |
b2f63ed to
de59f8d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/elements/content-sidebar/activity-feed-v2/task-modal-v2/utils/contactMapping.ts`:
- Around line 12-15: The ID mapping in toContactId is lossy because non-numeric
collaborator IDs are converted to 0, which later becomes target.id = '0' in
mapUserContactToAssignee and breaks the original identifier. Update the
contactMapping flow so mapCollaboratorToUserContact and mapUserContactToAssignee
preserve the raw collaborator/group ID string end-to-end instead of parsing it
to a number, and adjust the affected contact/assignee types accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d7f01392-719a-4b45-b76f-c1716842e67a
📒 Files selected for processing (2)
src/elements/content-sidebar/activity-feed-v2/task-modal-v2/utils/__tests__/contactMapping.test.tssrc/elements/content-sidebar/activity-feed-v2/task-modal-v2/utils/contactMapping.ts
de59f8d to
b1a0da4
Compare
b1a0da4 to
fc0a7b3
Compare
Summary
Adds a pure-functional contact-shape mapper utility for the V2 task modal. Three exported functions convert between the existing approver-selector shape (
SelectorItem<UserMini | GroupMini>returned by the file collaborators API) and@box/user-selector'sUserContactType, and back into theTaskCollabAssigneeshape the create-task / edit-task callbacks expect.This is the second step in the V2 task modal migration (groundwork for the upcoming TaskFormV2 work). No UI, no callers wired up yet.
Changes
src/elements/content-sidebar/activity-feed-v2/task-modal-v2/utils/contactMapping.tsexports:mapCollaboratorToUserContact— selector item →UserContactType(group → empty email, user → preserves email, numeric id coercion with0fallback for non-numeric ids).mapUserContactToAssignee—UserContactType→TaskCollabAssigneewith the new-approver permission shape (can_delete: false,can_update: false).mapAssigneeToUserContact—TaskCollabAssignee→UserContactType, used to seed selected users when editing an existing task.utils/__tests__/contactMapping.test.ts.Design notes
TaskCollabAssignee.target. Flow typestargetasUserMini, but groups are also valid at runtime (the file collaborators endpoint returns both wheninclude_groups=true, and v1 setstarget: pill.itemdirectly). The TS mapper widens toUserMini | GroupMinito reflect reality.valueformat<name>-<id>matches the precedent set by@box/unified-share-modal(useContactService.ts:42) so selected-user state has a stable unique key.UserContactType.idisnumber, butUserMini.id/GroupMini.idarestring. The mapper coerces viaNumber()and falls back to0if the source id is not numeric (matches the unified-share-modal pattern for external/no-account contacts).useContactServicebehavior.getContactsAvatarUrls(which the V2 form will wire up later) filters out groups viaemail === ''to avoid 404s on the avatar endpoint.Test plan
yarn test --testPathPattern="task-modal-v2"— 18/18 pass (10 new mapper tests + the 8 shell tests from feat(activity-feed-v2): scaffold accessible task modal v2 shell #4656)npx eslint --max-warnings=0 src/elements/content-sidebar/activity-feed-v2/task-modal-v2/— cleannpx tsc --noEmit— cleanTest scenarios covered:
0SelectorItem→UserContactType→TaskCollabAssignee→UserContactType)Follow-ups
TaskFormV2built onUserSelectorContainerand Blueprint form primitives (next PR)TaskFormV2intoTaskModalV2with edit-mode prefill and submit handlingActivityFeedV2.tsxto renderTaskModalV2Summary by CodeRabbit