Skip to content

refactor: drilled props -> ResourceUploadContext - #875

Open
nabalone wants to merge 2 commits into
upload-prop-renamesfrom
resource-upload-context
Open

nabalone wants to merge 2 commits into
upload-prop-renamesfrom
resource-upload-context

Conversation

@nabalone

Copy link
Copy Markdown
Collaborator

Stacked on #868 (upload-prop-renames). Retarget to develop once #868 merges.

What changed

Follow-up to the prop audit of the add-resource wizard. The step-1 inputs were drilled 3–4 levels deep (AddResourceWizard → ResourceUploadStep → PassageRecordPanel → MediaUploadContent / MediaRecord / SpeakerName).

  • New ResourceUploadContext (PassageDetail/Internalization/ResourceUploadContext.tsx), provided by AddResourceWizard around step 1 only. useResourceUploadContext() throws outside the provider.
  • ResourceUploadStep takes no props; reads the context. Passes only its own uploadMethod (its useMediaUpload instance) and the cancelled-setting finish wrapper to the record panel.
  • PassageRecordPanel → ResourceRecordPanel, moved into Internalization/ since its only caller is the wizard. Takes uploadMethod + finish; reads the rest from context.
  • Shared leaves (MediaUploadContent, MediaRecord) keep explicit props.
  • Dropped the step's artifactId ?? VernacularTag — VernacularTag is null, so it was a no-op (the hook already yields ?? null).
  • No behavior change.

Test plan

  • npm run typecheck
  • jest: ResourceUploadStep.test.tsx (now renders inside the provider; adds a throws-outside-provider case), AddResourceWizard.test.tsx (mock step reads the context)
  • Manual: Add Audio Resource → Upload and Record tabs; General resource → Next → SelectSections → Back keeps the take/file; Faithbridge link add

🤖 Generated with Claude Code

…text

The wizard's step-1 inputs were drilled three or four levels
(AddResourceWizard -> ResourceUploadStep -> PassageRecordPanel -> leaves).
AddResourceWizard now provides them through ResourceUploadContext; the step
and its record panel read the context, and only the shared leaves
(MediaUploadContent, MediaRecord) still take explicit props.
PassageRecordPanel is wizard-only, so it moves next to the wizard as
ResourceRecordPanel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟢 Approval recommended

The refactor is accompanied by updated and expanded Jest coverage—including provider-wrapped renders and an explicit outside-provider error test—indicating the new context-based data flow is exercised with no outstanding concerns noted.

No open issues 🎉

What changed in this PR

Refactors the add-resource wizard’s step-1 (Upload/Record) data flow to eliminate deep prop drilling by introducing a step-scoped ResourceUploadContext, keeping behavior intended to remain the same.

Changes:

  • Adds ResourceUploadContext and updates step-1 components to consume shared inputs via context instead of threaded props.
  • Renames/moves the record panel to ResourceRecordPanel under Internalization/, passing only step-owned upload controls explicitly.
  • Updates Jest tests to wrap renders in the provider and validate the hook throws when used outside the provider.
File Description
web/​src/​components/​PassageDetail/​Internalization/​ResourceUploadStep.tsx Updates the upload step to read required inputs from ResourceUploadContext and simplifies its public props surface.
web/​src/​components/​PassageDetail/​Internalization/​ResourceUploadStep.test.tsx Adjusts step tests to render within the new context provider and adds coverage for the outside-provider error case.
web/​src/​components/​PassageDetail/​Internalization/​ResourceUploadContext.tsx Introduces ResourceUploadContext and a useResourceUploadContext() hook that enforces provider presence.
web/​src/​components/​PassageDetail/​Internalization/​ResourceRecordPanel.tsx Adds the wizard-scoped ResourceRecordPanel that consumes upload/record inputs from context and accepts only the step-owned upload method and finish handler.
web/​src/​components/​PassageDetail/​Internalization/​AddResourceWizard.tsx Wraps step 1 with the new context provider and removes previously drilled props by supplying them through the provider value.
web/​src/​components/​PassageDetail/​Internalization/​AddResourceWizard.test.tsx Updates wizard tests so the mocked step reads its inputs from ResourceUploadContext rather than receiving them as props.
web/​src/​components/​MediaRecord.tsx Updates an internal reference/comment to align with the ResourceRecordPanel rename.

Review effort: Balanced

Addresses Devin review on #875: the jest mock now sets displayName (jest
testing takeaways) and uses jest.requireActual<T>() instead of an `as` cast
(CODING_STANDARDS Types).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nabalone
nabalone marked this pull request as ready for review November 13, 2026 16:12
@nabalone nabalone changed the title refactor: read add-resource upload step inputs from ResourceUploadContext refactor: drilled props -> ResourceUploadContext Nov 13, 2026
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.

2 participants