From b7006b944bef5f02cc18b823f64f16720cd47c56 Mon Sep 17 00:00:00 2001 From: Noel Chou Date: Wed, 11 Nov 2026 23:07:07 -0500 Subject: [PATCH 1/5] refactor: consistent prop names in the upload components Rename props that changed name hop-to-hop without reason: GraphicUploader's metadata -> metaData; submitRef/mediaUploadControlsRef -> controlsRef; onOpen/onVisible (only ever called with false) -> onClose across the upload family and ProjectResourceConfigure, with MediaUploadDialog's visible -> isOpen. useAddResourceWizard's return names now match the child props they feed. Co-Authored-By: Claude Opus 5.5 --- web/src/components/AudioTab/AudioTab.tsx | 2 +- web/src/components/GraphicPicker.test.tsx | 12 ++-- web/src/components/GraphicPicker.tsx | 18 +++--- web/src/components/GraphicUploader.tsx | 21 +++---- web/src/components/ImportTab.tsx | 4 +- web/src/components/MediaUploadContent.tsx | 6 +- web/src/components/MediaUploadDialog.tsx | 14 ++--- .../AddResourceWizard.test.tsx | 18 +++--- .../Internalization/AddResourceWizard.tsx | 31 +++++----- .../ProjectResourceConfigure.tsx | 6 +- .../ResourceUploadStep.test.tsx | 10 ++-- .../Internalization/ResourceUploadStep.tsx | 7 +-- .../Internalization/useAddResourceWizard.ts | 58 +++++++++---------- .../PassageDetail/PassageDetailItem.tsx | 5 +- .../PassageDetail/PassageDetailRecord.tsx | 5 +- web/src/components/PassageRecordPanel.tsx | 5 +- web/src/components/ProvideRights.tsx | 5 +- web/src/components/Sheet/ScriptureTable.tsx | 6 +- web/src/components/TitleTabs.tsx | 2 +- web/src/components/TitleUploader.tsx | 9 +-- web/src/components/Uploader.tsx | 12 ++-- web/src/utils/useCompression.ts | 6 +- 22 files changed, 126 insertions(+), 136 deletions(-) diff --git a/web/src/components/AudioTab/AudioTab.tsx b/web/src/components/AudioTab/AudioTab.tsx index 076dd7036..58735e49e 100644 --- a/web/src/components/AudioTab/AudioTab.tsx +++ b/web/src/components/AudioTab/AudioTab.tsx @@ -445,7 +445,7 @@ export function AudioTab() { setUploadVisible(false)} multiple={true} finish={afterUpload} cancelled={cancelled} diff --git a/web/src/components/GraphicPicker.test.tsx b/web/src/components/GraphicPicker.test.tsx index 23ddb001e..9187a93d7 100644 --- a/web/src/components/GraphicPicker.test.tsx +++ b/web/src/components/GraphicPicker.test.tsx @@ -65,23 +65,23 @@ jest.mock('./GraphicUploader', () => { return { mockHandleAddOrSave: handleAddOrSave, GraphicUploader: (props: { - metadata?: React.ReactNode; + metaData?: React.ReactNode; onFiles?: (files: File[]) => void; - mediaUploadControlsRef?: { + controlsRef?: { current: { handleAddOrSave: unknown; handleCancel: unknown; }; }; }) => { - if (props.mediaUploadControlsRef) { - props.mediaUploadControlsRef.current.handleAddOrSave = handleAddOrSave; - props.mediaUploadControlsRef.current.handleCancel = jest.fn(); + if (props.controlsRef) { + props.controlsRef.current.handleAddOrSave = handleAddOrSave; + props.controlsRef.current.handleCancel = jest.fn(); } return (
custom-upload - {props.metadata} + {props.metaData} {/* Deferred flow: pick a file, then Next only advances (no upload here) — the retained selection is uploaded later by the wizard - via submitRef. */} + via controlsRef. */} )} -
@@ -469,7 +469,7 @@ describe('AddResourceWizard', () => { }); stageToSelectSections(); - // Choose sections → the wizard fires the deferred upload through submitRef, + // Choose sections → the wizard fires the deferred upload through controlsRef, // which completes → configure step. fireEvent.click(screen.getByText('sections-select')); diff --git a/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx b/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx index 6904ee601..2277af5e7 100644 --- a/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx +++ b/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx @@ -51,7 +51,7 @@ export function AddResourceWizard({ ? w.t.selectPassagesSub.replace('{0}', getOrganizedBy(false)) : w.t.editingFile.replace( '{0}', - safeFileBasename(w.projMedia?.attributes?.originalFile) + safeFileBasename(w.media?.attributes?.originalFile) )} ) : undefined @@ -78,33 +78,36 @@ export function AddResourceWizard({ > w.setRecordingStarted(true)} - isAudioMode={w.isAddingAudioResource} + isAddingAudioResource={w.isAddingAudioResource} active={w.step === WizardStep.Upload} finish={w.afterUpload} beforeUpload={w.handleBeforeUpload} cancelled={w.cancelled} artifactId={w.artifactId} uploadType={w.uploadType} - ready={w.resourceReady} + ready={w.ready} speaker={w.speaker} onSpeaker={w.setSpeaker} - inValue={w.markdownValue} + inValue={w.inValue} eafUrl={w.eafUrl} - defaultFilename={w.filename} - pendingRestore={w.resourcePendingRestore} + defaultFilename={w.defaultFilename} + pendingRestore={w.pendingRestore} onFiles={w.setResourceUploadFiles} deferred={ w.uploadType === UploadType.ProjectResource - ? { onNext: w.handleUploadStepNext, submitRef: w.submitRef } + ? { + onNext: w.handleUploadStepNext, + controlsRef: w.controlsRef, + } : undefined } - validationMessage={w.resourceUploadValidationMessage} + validationMessage={w.validationMessage} metaData={ void; + onClose?: (() => void) | undefined; /** * When set, a "Back" button (the reverse of the selection dialog's Next) is * shown. It returns to SelectSections keeping the media, so the caller must @@ -217,7 +217,7 @@ export const ProjectResourceConfigure = (props: IProps) => { items, candidateItems, resourceTypeId, - onOpen, + onClose, onBack, } = props; const mediafiles = useOrbitData('mediafile'); @@ -384,7 +384,7 @@ export const ProjectResourceConfigure = (props: IProps) => { .finally(() => { setSaving(false); setComplete(0); - onOpen && onOpen(false); + onClose?.(); }); } } diff --git a/web/src/components/PassageDetail/Internalization/ResourceUploadStep.test.tsx b/web/src/components/PassageDetail/Internalization/ResourceUploadStep.test.tsx index eab29eae7..a8632bbe0 100644 --- a/web/src/components/PassageDetail/Internalization/ResourceUploadStep.test.tsx +++ b/web/src/components/PassageDetail/Internalization/ResourceUploadStep.test.tsx @@ -58,7 +58,7 @@ type StepProps = React.ComponentProps; function renderStep(overrides: Partial = {}) { const props: StepProps = { active: true, - isAudioMode: true, + isAddingAudioResource: true, uploadType: UploadType.Media, cancelled: { current: false }, finish: jest.fn(), @@ -127,14 +127,14 @@ describe('ResourceUploadStep', () => { describe('mode', () => { it('renders the record panel in audio mode, wired to the upload hook', () => { - renderStep({ isAudioMode: true }); + renderStep({ isAddingAudioResource: true }); expect(capturedPanel?.uploadMethod).toBe(mockUploadMethod); expect(capturedContent).toBeUndefined(); }); it('renders the upload content otherwise, wired to the upload hook', () => { - renderStep({ isAudioMode: false }); + renderStep({ isAddingAudioResource: false }); expect(capturedContent?.uploadMethod).toBe(mockUploadMethod); expect(capturedPanel).toBeUndefined(); @@ -144,7 +144,7 @@ describe('ResourceUploadStep', () => { describe('Faithbridge link value', () => { it('shows only the url and sends the transcription to the upload', () => { renderStep({ - isAudioMode: false, + isAddingAudioResource: false, uploadType: UploadType.FaithbridgeLink, inValue: 'https://fb.example/x||hello world', }); @@ -155,7 +155,7 @@ describe('ResourceUploadStep', () => { it('passes inValue through untouched for other upload types', () => { renderStep({ - isAudioMode: false, + isAddingAudioResource: false, uploadType: UploadType.Link, inValue: 'https://example.com/a||b', }); diff --git a/web/src/components/PassageDetail/Internalization/ResourceUploadStep.tsx b/web/src/components/PassageDetail/Internalization/ResourceUploadStep.tsx index ea034e4f3..2fb44b2e3 100644 --- a/web/src/components/PassageDetail/Internalization/ResourceUploadStep.tsx +++ b/web/src/components/PassageDetail/Internalization/ResourceUploadStep.tsx @@ -9,7 +9,7 @@ import type { PendingRestoreInput } from '../../../store/upload/pendingMediaUplo interface IProps { active: boolean; - isAudioMode: boolean; //shows a Record option as well as upload + isAddingAudioResource: boolean; //shows a Record option as well as upload uploadType: UploadType; artifactId?: string | null | undefined; speaker?: string | undefined; @@ -38,7 +38,7 @@ interface IProps { export function ResourceUploadStep(props: IProps) { const { active, - isAudioMode, + isAddingAudioResource, uploadType, artifactId: artifactIdProp, speaker, @@ -103,7 +103,7 @@ export function ResourceUploadStep(props: IProps) { '& > .MuiDialogActions-root > .MuiButton-root': { m: 0 }, }} > - {isAudioMode ? ( + {isAddingAudioResource ? ( {}} uploadType={uploadType} multiple uploadMethod={uploadMedia} diff --git a/web/src/components/PassageDetail/Internalization/useAddResourceWizard.ts b/web/src/components/PassageDetail/Internalization/useAddResourceWizard.ts index e8e006108..363e99f43 100644 --- a/web/src/components/PassageDetail/Internalization/useAddResourceWizard.ts +++ b/web/src/components/PassageDetail/Internalization/useAddResourceWizard.ts @@ -149,7 +149,7 @@ export function useAddResourceWizard({ launchSource.kind === WizardLaunchKind.Add && launchSource.action === AddResourceAction.Audio; const aiGenerated = launchSource.kind === WizardLaunchKind.FaithBridge; - const markdownValue = + const inValue = launchSource.kind === WizardLaunchKind.FaithBridge ? launchSource.audioUrl ? `${launchSource.audioUrl}||${launchSource.transcript}` @@ -175,21 +175,21 @@ export function useAddResourceWizard({ // The description's single copy (ResourceData's field is uncontrolled). A ref, // not state: it's only read at upload time, so typing needn't re-render. const descriptionRef = useRef(initDescription); - const addCategorySaveRef = useRef<(() => Promise) | null>(null); + const catCommitRef = useRef<(() => Promise) | null>(null); const pendingResourceSeqRef = useRef(0); const [projSelection, setProjSelection] = useState<{ items: RecordIdentity[]; candidates: RecordIdentity[]; }>({ items: [], candidates: [] }); - const [projMedia, setProjMedia] = useState( + const [media, setMedia] = useState( launchSource.kind === WizardLaunchKind.EditGeneralResource ? launchSource.media : undefined ); // Handle to the (hidden, still-mounted) Upload step's active tab; // SelectSections' Upload button calls it to upload the held file/take. - const submitRef = useRef({ + const controlsRef = useRef({ handleAddOrSave: null, handleCancel: null, }); @@ -209,14 +209,14 @@ export function useAddResourceWizard({ : resourceType) ?? null; const planRec = plan ? getPlan(plan) : null; - const filename = planRec?.attributes?.slug + const defaultFilename = planRec?.attributes?.slug ? `${planRec.attributes.slug}resource` : 'resource'; const isPassageResource = resourceKind === ResourceTypeEnum.passageResource; const isProjectResource = resourceKind === ResourceTypeEnum.projectResource; - const resourcePendingRestore = useCallback(() => { + const pendingRestore = useCallback(() => { // Project resources should not get staged as pending uploads; they need to be configured in one go. if (resourceKind === ResourceTypeEnum.projectResource) { return undefined; @@ -251,10 +251,10 @@ export function useAddResourceWizard({ resourceUploadFiles, resourceKind ); - const resourceUploadValidationMessage = uploadConflict + const validationMessage = uploadConflict ? t.generalResourcesIndividually : ''; - const resourceReady = + const ready = (!descriptionRequiredForResource(undefined, uploadType) || hasDescription) && !uploadConflict; @@ -317,11 +317,11 @@ export function useAddResourceWizard({ } if (projRes.length === 1) { if (areSectionsPreselectedRef.current) { - const media = projRes[0] as MediaFileD; - setProjMedia(media); + const created = projRes[0] as MediaFileD; + setMedia(created); areSectionsPreselectedRef.current = false; setUploading(false); - setSelected(media.id, PlayInPlayer.yes); + setSelected(created.id, PlayInPlayer.yes); setStep(WizardStep.Configure); advanced = true; } @@ -345,17 +345,17 @@ export function useAddResourceWizard({ // Commit the staged new category (if any) right before the real upload. const handleBeforeUpload = async () => { pendingResourceSeqRef.current = 0; - if (addCategorySaveRef.current) { - categoryIdRef.current = await addCategorySaveRef.current(); + if (catCommitRef.current) { + categoryIdRef.current = await catCommitRef.current(); // Cleared so a retry can't create a duplicate category. - addCategorySaveRef.current = null; + catCommitRef.current = null; } }; // Upload step Next (general resource): go to SelectSections without uploading; - // the hidden Upload step keeps the file/take until submitRef fires it. + // the hidden Upload step keeps the file/take until controlsRef fires it. const handleUploadStepNext = () => { - setProjMedia(undefined); + setMedia(undefined); setStep(WizardStep.SelectSections); }; @@ -364,10 +364,10 @@ export function useAddResourceWizard({ candidates: RecordIdentity[] ) => { setProjSelection({ items, candidates }); - if (isAddingAudioResource && !projMedia) { + if (isAddingAudioResource && !media) { // Nothing uploaded yet. Fire the held upload now. SelectSections shows a // spinner until afterUpload advances or re-enables it. - const submit = submitRef.current.handleAddOrSave; + const submit = controlsRef.current.handleAddOrSave; if (!submit) return; cancelled.current = false; areSectionsPreselectedRef.current = true; @@ -396,7 +396,7 @@ export function useAddResourceWizard({ // SelectSections Back (add flow only): back to Upload to change the audio. // Any already-uploaded media is left in place; a replacement creates a new one. const handleSelectSectionsBack = () => { - setProjMedia(undefined); + setMedia(undefined); setStep(WizardStep.Upload); }; @@ -488,24 +488,24 @@ export function useAddResourceWizard({ isAddingAudioResource, // seeded upload-step values uploadType, - resourceReady, + ready, speaker, setSpeaker, - markdownValue, + inValue, eafUrl: aiGenerated ? AIGenerated : '', - filename, - resourceUploadValidationMessage, + defaultFilename, + validationMessage, resourceKind, resourceType, // Seed only: ResourceData owns the live value (reported via handleDescription). initDescription, - projMedia, - projIdentity: projSelection.items, - projCandidate: projSelection.candidates, + media, + items: projSelection.items, + candidateItems: projSelection.candidates, cancelled, artifactId, - addCategorySaveRef, - submitRef, + catCommitRef, + controlsRef, // section-select initialItems, uploading, @@ -515,7 +515,7 @@ export function useAddResourceWizard({ setRecordingStarted, afterUpload, handleBeforeUpload, - resourcePendingRestore, + pendingRestore, setResourceUploadFiles, handleDescription, handleCategory, diff --git a/web/src/components/PassageDetail/PassageDetailItem.tsx b/web/src/components/PassageDetail/PassageDetailItem.tsx index f29234186..a390e825b 100644 --- a/web/src/components/PassageDetail/PassageDetailItem.tsx +++ b/web/src/components/PassageDetail/PassageDetailItem.tsx @@ -297,9 +297,6 @@ export function PassageDetailItem(props: IProps) { setPlayItem(''); }; - const handleUploadVisible = (v: boolean) => { - setUploadVisible(v); - }; const handleUpload = () => { if (canSave) { showMessage(t.saveFirst); @@ -587,7 +584,7 @@ export function PassageDetailItem(props: IProps) { setUploadVisible(false)} multiple={false} finish={afterUpload} cancelled={cancelled} diff --git a/web/src/components/PassageDetail/PassageDetailRecord.tsx b/web/src/components/PassageDetail/PassageDetailRecord.tsx index a844134b2..ac9070058 100644 --- a/web/src/components/PassageDetail/PassageDetailRecord.tsx +++ b/web/src/components/PassageDetail/PassageDetailRecord.tsx @@ -333,9 +333,6 @@ export function PassageDetailRecord(props: IProps) { const handleAudacityClose = () => { setAudacityVisible(false); }; - const handleUploadVisible = (v: boolean) => { - setUploadVisible(v); - }; const handleUpload = () => { saveIfChanged(() => { void confirmIfPending().then((ok) => { @@ -469,7 +466,7 @@ export function PassageDetailRecord(props: IProps) { setUploadVisible(false)} multiple={false} finish={afterUpload} cancelled={cancelled} diff --git a/web/src/components/PassageRecordPanel.tsx b/web/src/components/PassageRecordPanel.tsx index e33f8d922..f72373220 100644 --- a/web/src/components/PassageRecordPanel.tsx +++ b/web/src/components/PassageRecordPanel.tsx @@ -58,7 +58,7 @@ export interface IPassageRecordPanelProps { export interface IDeferredUpload { onNext: () => void; // for the wizard to trigger the real upload later - submitRef: React.RefObject; + controlsRef: React.RefObject; } export function PassageRecordPanel(props: IPassageRecordPanelProps) { @@ -81,7 +81,7 @@ export function PassageRecordPanel(props: IPassageRecordPanelProps) { onStartRecording, } = props; const onNext = deferred?.onNext; - const controlsRef = deferred?.submitRef; + const controlsRef = deferred?.controlsRef; const resourceStrings: IPassageDetailArtifactsStrings = useSelector( resourceSelector, shallowEqual @@ -219,7 +219,6 @@ export function PassageRecordPanel(props: IPassageRecordPanelProps) { {}} uploadType={uploadType} primaryButtonText={primaryButtonText} onNext={onNext} diff --git a/web/src/components/ProvideRights.tsx b/web/src/components/ProvideRights.tsx index 5a948e72b..09089509e 100644 --- a/web/src/components/ProvideRights.tsx +++ b/web/src/components/ProvideRights.tsx @@ -278,9 +278,6 @@ export function ProvideRights(props: IProps) { ); }; - const handleUploadVisible = (v: boolean) => { - setUploadVisible(v); - }; const handleUpload = () => { if (canSave) { showMessage(t.saveFirst); @@ -336,7 +333,7 @@ export function ProvideRights(props: IProps) { setUploadVisible(false)} multiple={false} finish={afterUpload} cancelled={cancelled} diff --git a/web/src/components/Sheet/ScriptureTable.tsx b/web/src/components/Sheet/ScriptureTable.tsx index 2aa6664ec..c2a1832da 100644 --- a/web/src/components/Sheet/ScriptureTable.tsx +++ b/web/src/components/Sheet/ScriptureTable.tsx @@ -637,10 +637,6 @@ export function ScriptureTable(props: Readonly) { }); }; - const handleUploadVisible = (v: boolean) => { - setUploadVisible(v); - }; - const handleUpload = (i: number) => () => { saveIfChanged(() => { showUpload(i); @@ -1503,7 +1499,7 @@ export function ScriptureTable(props: Readonly) { )} setUploadVisible(false)} multiple={false} finish={afterUpload} cancelled={cancelled} diff --git a/web/src/components/TitleTabs.tsx b/web/src/components/TitleTabs.tsx index 39bed8282..f5d43e9d5 100644 --- a/web/src/components/TitleTabs.tsx +++ b/web/src/components/TitleTabs.tsx @@ -249,7 +249,7 @@ const TitleTabs = (props: IProps) => { setFiles(files)} diff --git a/web/src/components/TitleUploader.tsx b/web/src/components/TitleUploader.tsx index 10f6fd5fc..a0ba05481 100644 --- a/web/src/components/TitleUploader.tsx +++ b/web/src/components/TitleUploader.tsx @@ -7,7 +7,7 @@ import { mediaTitleSelector } from '../selector'; interface IProps { isOpen: boolean; - onOpen: (visible: boolean) => void; + onClose: () => void; hasRights?: boolean; // required for upload cancelled: React.RefObject; uploadMethod: (files: File[]) => Promise; @@ -15,11 +15,12 @@ interface IProps { } export function TitleUploader(props: IProps) { - const { isOpen, onOpen, cancelled, hasRights, uploadMethod, onFiles } = props; + const { isOpen, onClose, cancelled, hasRights, uploadMethod, onFiles } = + props; const t: IMediaTitleStrings = useSelector(mediaTitleSelector, shallowEqual); const uploadCancel = () => { - onOpen(false); + onClose(); // eslint-disable-next-line react-hooks/immutability if (cancelled) cancelled.current = true; restoreScroll(); @@ -27,7 +28,7 @@ export function TitleUploader(props: IProps) { return isOpen ? ( void; + onClose: () => void; finish?: ((mediaRemoteIds?: string[]) => Promise) | undefined; // logic when upload complete cancelled: React.RefObject; multiple?: boolean | undefined; @@ -39,7 +39,7 @@ export const Uploader = (props: IProps) => { noBusy, skipImportExportWait, isOpen, - onOpen, + onClose, cancelled, multiple, importList, @@ -79,7 +79,7 @@ export const Uploader = (props: IProps) => { try { await finish?.(mediaRemoteIds); } finally { - onOpen(false); + onClose(); } }; @@ -110,7 +110,7 @@ export const Uploader = (props: IProps) => { }); const uploadCancel = () => { - onOpen(false); + onClose(); if (cancelled) cancelled.current = true; restoreScroll(); }; @@ -121,8 +121,8 @@ export const Uploader = (props: IProps) => { {!hasImport && ( void; - onOpen?: (visible: boolean) => void; + onClose?: (() => void) | undefined; } export const useCompression = ({ @@ -40,7 +40,7 @@ export const useCompression = ({ dimension, defaultFilename, finish, - onOpen, + onClose, }: CompressionProps) => { const t: IMediaTabStrings = useSelector(mediaTabSelector, shallowEqual); const [errorReporter] = useGlobal('errorReporter'); @@ -110,7 +110,7 @@ export const useCompression = ({ } } if (finish) finish(results); - onOpen?.(false); + onClose?.(); }; return { showFile, uploadMedia }; From 7ce628132eebf4448053ed8f9dcfedfa3b14d69b Mon Sep 17 00:00:00 2001 From: Noel Chou Date: Thu, 12 Nov 2026 18:28:46 -0500 Subject: [PATCH 2/5] refactor: Uploader speaker props match the other upload components Rename Uploader's performedBy/onSpeakerChange to speaker/onSpeaker, the names MediaUploadDialog, MediaUploadContent and the wizard already use. performedBy stays only as the useMediaUpload record field. Co-Authored-By: Claude Opus 5.5 --- web/src/components/AudioTab/AudioTab.tsx | 4 ++-- .../PassageDetail/PassageDetailItem.tsx | 2 +- .../PassageDetail/PassageDetailRecord.tsx | 4 ++-- web/src/components/ProvideRights.tsx | 2 +- web/src/components/Sheet/ScriptureTable.tsx | 4 ++-- web/src/components/Uploader.tsx | 18 +++++++----------- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/web/src/components/AudioTab/AudioTab.tsx b/web/src/components/AudioTab/AudioTab.tsx index 58735e49e..25814a34b 100644 --- a/web/src/components/AudioTab/AudioTab.tsx +++ b/web/src/components/AudioTab/AudioTab.tsx @@ -449,8 +449,8 @@ export function AudioTab() { multiple={true} finish={afterUpload} cancelled={cancelled} - performedBy={speaker} - onSpeakerChange={handleNameChange} + speaker={speaker} + onSpeaker={handleNameChange} /> ); diff --git a/web/src/components/PassageDetail/PassageDetailItem.tsx b/web/src/components/PassageDetail/PassageDetailItem.tsx index a390e825b..043eb0b15 100644 --- a/web/src/components/PassageDetail/PassageDetailItem.tsx +++ b/web/src/components/PassageDetail/PassageDetailItem.tsx @@ -592,7 +592,7 @@ export function PassageDetailItem(props: IProps) { sourceSegments={JSON.stringify(getCurrentSegment())} sourceMediaId={mediafileId} artifactState={artifactState} - performedBy={speaker} + speaker={speaker} topic={topic} /> diff --git a/web/src/components/PassageDetail/PassageDetailRecord.tsx b/web/src/components/PassageDetail/PassageDetailRecord.tsx index ac9070058..a2a5cbd06 100644 --- a/web/src/components/PassageDetail/PassageDetailRecord.tsx +++ b/web/src/components/PassageDetail/PassageDetailRecord.tsx @@ -471,8 +471,8 @@ export function PassageDetailRecord(props: IProps) { finish={afterUpload} cancelled={cancelled} passageId={passageId} - performedBy={speaker} - onSpeakerChange={handleNameChange} + speaker={speaker} + onSpeaker={handleNameChange} skipImportExportWait /> ) { related(uploadItem.current?.sharedResource, 'passage') ?? uploadItem.current?.passage?.id } - performedBy={speaker} - onSpeakerChange={handleNameChange} + speaker={speaker} + onSpeaker={handleNameChange} /> void) | undefined; + speaker?: string | undefined; + onSpeaker?: ((speaker: string) => void) | undefined; topic?: string | undefined; uploadType?: UploadType | undefined; audioOnly?: boolean | undefined; @@ -48,8 +48,8 @@ export const Uploader = (props: IProps) => { planId, sourceMediaId, sourceSegments, - performedBy, - onSpeakerChange, + speaker, + onSpeaker, topic, uploadType, audioOnly, @@ -69,10 +69,6 @@ export const Uploader = (props: IProps) => { return planId || plan; }, [passageId, planId, plan, memory]); - const handleSpeakerChange = (speaker: string) => { - onSpeakerChange && onSpeakerChange(speaker); - }; - // Close the dialog once the batch is done (even if `finish` throws), as the // pre-hook Uploader did; the dialog itself only clears its progress on failure. const finishAndClose = async (mediaRemoteIds?: string[]) => { @@ -92,7 +88,7 @@ export const Uploader = (props: IProps) => { localPlanId: resolvedLocalPlanId, sourceMediaId, sourceSegments, - performedBy, + performedBy: speaker, topic, }, uploadType, @@ -127,11 +123,11 @@ export const Uploader = (props: IProps) => { multiple={multiple} uploadMethod={uploadMedia} cancelMethod={uploadCancel} - speaker={performedBy} + speaker={speaker} onSpeaker={ !artifactState?.id && (uploadType || UploadType.Media) === UploadType.Media - ? handleSpeakerChange + ? onSpeaker : undefined } audioOnly={audioOnly} From 269ffd52f09e4180df22852f5b1554ba29d59ee8 Mon Sep 17 00:00:00 2001 From: Noel Chou Date: Thu, 12 Nov 2026 18:35:27 -0500 Subject: [PATCH 3/5] refactor: name the category save ref categorySaveRef everywhere The ref that saves a typed (possibly new) category at form submission was catCommitRef / editCatCommitRef / commitRef depending on the hop. Use categorySaveRef (editCategorySaveRef) throughout, and rename SelectArtifactCategory's commit()/committingRef to saveCategory()/savingRef. Co-Authored-By: Claude Opus 5.5 --- .../components/Discussions/DiscussionCard.tsx | 10 ++--- .../Internalization/AddResourceWizard.tsx | 2 +- .../PassageDetailArtifacts.tsx | 10 ++--- .../PassageDetailsArtifactsMobile.tsx | 10 ++--- .../Internalization/ResourceData.tsx | 6 +-- .../Internalization/useAddResourceWizard.ts | 12 +++--- .../ResourceEdit/ResourceCategory.tsx | 6 +-- .../ResourceEdit/ResourceOverview.tsx | 14 +++---- .../Sheet/SelectArtifactCategory.tsx | 38 +++++++++---------- 9 files changed, 54 insertions(+), 54 deletions(-) diff --git a/web/src/components/Discussions/DiscussionCard.tsx b/web/src/components/Discussions/DiscussionCard.tsx index 828e50729..8392c28fc 100644 --- a/web/src/components/Discussions/DiscussionCard.tsx +++ b/web/src/components/Discussions/DiscussionCard.tsx @@ -255,9 +255,9 @@ export const DiscussionCard = (props: IProps) => { const [myChanged, setMyChanged] = useState(false); const segSavingRef = useRef(false); const cardSavingRef = useRef(false); - // commit() handle for the category field; called at save so a newly typed + // saveCategory() handle for the category field; called at save so a newly typed // category is created on submission rather than on blur. - const catCommitRef = useRef<(() => Promise) | null>(null); + const categorySaveRef = useRef<(() => Promise) | null>(null); const [showMove, setShowMove] = useState(false); const [moveTo, setMoveTo] = useState(); const waitForRemoteQueue = useWaitForRemoteQueue(); @@ -756,8 +756,8 @@ export const DiscussionCard = (props: IProps) => { editSubject.length > 0 ? editSubject : tdcs.topic; // Create the category now (at save) if the user typed a new one; on blur it // was only resolved against existing categories. - const catId = catCommitRef.current - ? await catCommitRef.current() + const catId = categorySaveRef.current + ? await categorySaveRef.current() : editCategory; const ops: RecordOperation[] = []; const t = new RecordTransformBuilder(); @@ -1016,7 +1016,7 @@ export const DiscussionCard = (props: IProps) => { initCategory={editCategory} onCategoryChange={onCategoryChange} onNewDraft={onCategoryNewDraft} - commitRef={catCommitRef} + categorySaveRef={categorySaveRef} allowNew={userIsAdmin && (!offline || offlineOnly)} required={false} scripture={ArtCatScr.hide} diff --git a/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx b/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx index 2277af5e7..7722b30bb 100644 --- a/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx +++ b/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx @@ -107,7 +107,7 @@ export function AddResourceWizard({ uploadType={w.uploadType} initCategory="" onCategoryChange={w.handleCategory} - catCommitRef={w.catCommitRef} + categorySaveRef={w.categorySaveRef} initDescription={w.initDescription} onDescriptionChange={w.handleDescription} resourceKind={w.resourceKind} diff --git a/web/src/components/PassageDetail/Internalization/PassageDetailArtifacts.tsx b/web/src/components/PassageDetail/Internalization/PassageDetailArtifacts.tsx index 683a78d02..8a4213efd 100644 --- a/web/src/components/PassageDetail/Internalization/PassageDetailArtifacts.tsx +++ b/web/src/components/PassageDetail/Internalization/PassageDetailArtifacts.tsx @@ -162,9 +162,9 @@ export function PassageDetailArtifacts() { const mediaRef = useRef(undefined); const textRef = useRef(undefined); const catIdRef = useRef(undefined); - // commit() handle for the edit dialog's SelectArtifactCategory. Called at save + // saveCategory() handle for the edit dialog's SelectArtifactCategory. Called at save // to create a new category. - const editCatCommitRef = useRef<(() => Promise) | null>(null); + const editCategorySaveRef = useRef<(() => Promise) | null>(null); const descriptionRef = useRef(''); const [resourceKind, setResourceKindx] = useState( @@ -413,8 +413,8 @@ export function PassageDetailArtifacts() { const handleEditSave = async () => { // Create the category now (at save) if the user typed a new one; on blur it // was only resolved against existing categories. - if (editCatCommitRef.current) { - const catId = await editCatCommitRef.current(); + if (editCategorySaveRef.current) { + const catId = await editCategorySaveRef.current(); catIdRef.current = catId; } if (editResource) { @@ -794,7 +794,7 @@ export function PassageDetailArtifacts() { uploadType={uploadType} initCategory={catIdRef.current || ''} onCategoryChange={handleCategory} - catCommitRef={editCatCommitRef} + categorySaveRef={editCategorySaveRef} initDescription={descriptionRef.current} onDescriptionChange={handleDescription} resourceKind={resourceKind} diff --git a/web/src/components/PassageDetail/Internalization/PassageDetailsArtifactsMobile.tsx b/web/src/components/PassageDetail/Internalization/PassageDetailsArtifactsMobile.tsx index 6fc1c9340..af65401e7 100644 --- a/web/src/components/PassageDetail/Internalization/PassageDetailsArtifactsMobile.tsx +++ b/web/src/components/PassageDetail/Internalization/PassageDetailsArtifactsMobile.tsx @@ -144,9 +144,9 @@ export function PassageDetailArtifactsMobile() { const mediaRef = useRef(undefined); const textRef = useRef(undefined); const catIdRef = useRef(undefined); - // commit() handle for the edit dialog's SelectArtifactCategory. Called at save + // saveCategory() handle for the edit dialog's SelectArtifactCategory. Called at save // to create a new category. - const editCatCommitRef = useRef<(() => Promise) | null>(null); + const editCategorySaveRef = useRef<(() => Promise) | null>(null); const descriptionRef = useRef(''); const [resourceKind, setResourceKindx] = useState( @@ -413,8 +413,8 @@ export function PassageDetailArtifactsMobile() { const handleEditSave = async () => { // Create the category now (at save) if the user typed a new one; on blur it // was only resolved against existing categories. - if (editCatCommitRef.current) { - const catId = await editCatCommitRef.current(); + if (editCategorySaveRef.current) { + const catId = await editCategorySaveRef.current(); catIdRef.current = catId; } if (editResource) { @@ -795,7 +795,7 @@ export function PassageDetailArtifactsMobile() { uploadType={uploadType} initCategory={catIdRef.current || ''} onCategoryChange={handleCategory} - catCommitRef={editCatCommitRef} + categorySaveRef={editCategorySaveRef} initDescription={descriptionRef.current} onDescriptionChange={handleDescription} resourceKind={resourceKind} diff --git a/web/src/components/PassageDetail/Internalization/ResourceData.tsx b/web/src/components/PassageDetail/Internalization/ResourceData.tsx index fdf7816ef..ba6347344 100644 --- a/web/src/components/PassageDetail/Internalization/ResourceData.tsx +++ b/web/src/components/PassageDetail/Internalization/ResourceData.tsx @@ -62,7 +62,7 @@ interface IProps { allowGeneralResourceOption: boolean; // Forwarded to SelectArtifactCategory so the parent form can create a new // category at submission (rather than on blur). - catCommitRef?: RefObject<(() => Promise) | null> | undefined; + categorySaveRef?: RefObject<(() => Promise) | null> | undefined; wrapPreviewOverflow?: boolean; } export function ResourceData(props: IProps) { @@ -78,7 +78,7 @@ export function ResourceData(props: IProps) { uploadType, onTextChange, wrapPreviewOverflow, - catCommitRef, + categorySaveRef, } = props; // The TextField is uncontrolled (the parent owns the value via // onDescriptionChange); only emptiness is tracked here, for the error state, @@ -161,7 +161,7 @@ export function ResourceData(props: IProps) { required={false} scripture={ArtCatScr.highlight} type={ArtifactCategoryType.Resource} - commitRef={catCommitRef} + categorySaveRef={categorySaveRef} /> diff --git a/web/src/components/PassageDetail/Internalization/useAddResourceWizard.ts b/web/src/components/PassageDetail/Internalization/useAddResourceWizard.ts index 363e99f43..5317c7acd 100644 --- a/web/src/components/PassageDetail/Internalization/useAddResourceWizard.ts +++ b/web/src/components/PassageDetail/Internalization/useAddResourceWizard.ts @@ -175,7 +175,7 @@ export function useAddResourceWizard({ // The description's single copy (ResourceData's field is uncontrolled). A ref, // not state: it's only read at upload time, so typing needn't re-render. const descriptionRef = useRef(initDescription); - const catCommitRef = useRef<(() => Promise) | null>(null); + const categorySaveRef = useRef<(() => Promise) | null>(null); const pendingResourceSeqRef = useRef(0); const [projSelection, setProjSelection] = useState<{ @@ -342,13 +342,13 @@ export function useAddResourceWizard({ if (!advanced) onClose(); }; - // Commit the staged new category (if any) right before the real upload. + // Save the staged new category (if any) right before the real upload. const handleBeforeUpload = async () => { pendingResourceSeqRef.current = 0; - if (catCommitRef.current) { - categoryIdRef.current = await catCommitRef.current(); + if (categorySaveRef.current) { + categoryIdRef.current = await categorySaveRef.current(); // Cleared so a retry can't create a duplicate category. - catCommitRef.current = null; + categorySaveRef.current = null; } }; @@ -504,7 +504,7 @@ export function useAddResourceWizard({ candidateItems: projSelection.candidates, cancelled, artifactId, - catCommitRef, + categorySaveRef, controlsRef, // section-select initialItems, diff --git a/web/src/components/ResourceEdit/ResourceCategory.tsx b/web/src/components/ResourceEdit/ResourceCategory.tsx index 0e1eda30a..34081909e 100644 --- a/web/src/components/ResourceEdit/ResourceCategory.tsx +++ b/web/src/components/ResourceEdit/ResourceCategory.tsx @@ -5,11 +5,11 @@ import { ArtifactCategoryType } from '../../crud/useArtifactCategory'; interface IProps extends IResourceState { // Forwarded so the wizard can create a new category at save (not on blur). - commitRef?: RefObject<(() => Promise) | null> | undefined; + categorySaveRef?: RefObject<(() => Promise) | null> | undefined; } export const ResourceCategory = (props: IProps) => { - const { state, setState, commitRef } = props; + const { state, setState, categorySaveRef } = props; const { category, note } = state; const handleChange = (category: string) => { @@ -35,7 +35,7 @@ export const ResourceCategory = (props: IProps) => { onNewDraft={setState ? handleNewDraft : undefined} required={false} allowNew - commitRef={commitRef} + categorySaveRef={categorySaveRef} /> ); }; diff --git a/web/src/components/ResourceEdit/ResourceOverview.tsx b/web/src/components/ResourceEdit/ResourceOverview.tsx index 2e3a14c06..777730f3f 100644 --- a/web/src/components/ResourceEdit/ResourceOverview.tsx +++ b/web/src/components/ResourceEdit/ResourceOverview.tsx @@ -74,7 +74,7 @@ interface IProps extends IDialog { onLink?: (link: SharedResourceD) => Promise; onUnlink?: () => Promise | void; contentReadOnly?: boolean; - // Paint Saving and hold the sheet rebuild before category commit / orbit write. + // Paint Saving and hold the sheet rebuild before category save / orbit write. onSaving?: (saving: boolean) => void; } @@ -102,9 +102,9 @@ export default function ResourceOverview(props: IProps) { // (TT-7732). The ref blocks a click that lands before disabled paints. const savingRef = useRef(false); const [saving, setSaving] = React.useState(false); - // commit() handle for the category field; called at save so a newly typed + // saveCategory() handle for the category field; called at save so a newly typed // category is created on submission rather than on blur. - const catCommitRef = useRef<(() => Promise) | null>(null); + const categorySaveRef = useRef<(() => Promise) | null>(null); const { getOrgDefault, setOrgDefault, canSetOrgDefault } = useOrgDefaults(); const [findNote, setFindNote] = React.useState(false); const ts: ISharedStrings = useSelector(sharedSelector, shallowEqual); @@ -176,14 +176,14 @@ export default function ResourceOverview(props: IProps) { const handleAdd = async () => { if (savingRef.current) return; setAddBusy(true); - // Saving has to paint before category commit. A new category used to wait + // Saving has to paint before category save. A new category used to wait // on the remote queue here, so the snack never appeared (TT-7730). onSaving?.(true); try { // Create the category now (at save) if the user typed a new one; on blur it // was only resolved against existing categories. - const category = catCommitRef.current - ? await catCommitRef.current() + const category = categorySaveRef.current + ? await categorySaveRef.current() : state.category; await Promise.resolve(onCommit({ ...state, category })); } catch (err) { @@ -241,7 +241,7 @@ export default function ResourceOverview(props: IProps) { {!isNote ? ( diff --git a/web/src/components/Sheet/SelectArtifactCategory.tsx b/web/src/components/Sheet/SelectArtifactCategory.tsx index c88a87bda..2c6e8c469 100644 --- a/web/src/components/Sheet/SelectArtifactCategory.tsx +++ b/web/src/components/Sheet/SelectArtifactCategory.tsx @@ -30,13 +30,13 @@ interface IProps { scripture?: ArtCatScr | undefined; type: ArtifactCategoryType; disabled?: boolean | undefined; - // When provided, the parent gets a `commit()` here to run at form submission: + // When provided, the parent gets a `saveCategory()` here to run at form submission: // it resolves the current input to a category id (creating a new category // when the typed name matches none) and returns it. New categories are then - // created on commit rather than on blur. - commitRef?: RefObject<(() => Promise) | null> | undefined; + // created on save rather than on blur. + categorySaveRef?: RefObject<(() => Promise) | null> | undefined; // Fires as the user types in an allowNew field, i.e. whenever the field holds - // text that only commit() will resolve to a category id. Parents that gate + // text that only saveCategory() will resolve to a category id. Parents that gate // their Save button on a "changed" flag would otherwise never enable it for a // new-category-only edit; they use this to mark themselves dirty. onNewDraft?: (() => void) | undefined; @@ -67,7 +67,7 @@ export const SelectArtifactCategory = (props: IProps) => { scripture, type, disabled, - commitRef, + categorySaveRef, onNewDraft, } = props; const artifactCategories = @@ -87,7 +87,7 @@ export const SelectArtifactCategory = (props: IProps) => { IArtifactCategory[] >([]); const [gettingCategories, setGettingCategories] = useState(true); - const committingRef = useRef(false); + const savingRef = useRef(false); const currentName = artifactCategorys.find((c) => c.id === categoryId)?.category ?? ''; const [inputVal, setInputVal] = useState(currentName); @@ -135,7 +135,7 @@ export const SelectArtifactCategory = (props: IProps) => { // Resolve a chosen/typed category name to an existing category id. Called on // blur and on change. Deliberately does NOT create new categories — that is - // deferred to commit() (form submission) so navigating away without saving + // deferred to saveCategory() (form submission) so navigating away without saving // never leaves an orphaned category behind. const resolveExisting = (raw: string | null) => { const name = (raw ?? '').trim(); @@ -158,13 +158,13 @@ export const SelectArtifactCategory = (props: IProps) => { setInputVal(currentName); return; } - // allowNew + a new name: keep the typed text as-is and wait for commit(). + // allowNew + a new name: keep the typed text as-is and wait for saveCategory(). }; // Resolve the current input to a category id, creating a new category when // the typed name matches none. Intended to run at form submission via - // commitRef. Returns the resolved id (empty string when the field is blank). - const commit = async (): Promise => { + // categorySaveRef. Returns the resolved id (empty string when the field is blank). + const saveCategory = async (): Promise => { const name = inputVal.trim(); // Field unchanged from the committed category — keep its id as-is rather // than re-resolving by name. Re-resolving could silently drop the category @@ -190,8 +190,8 @@ export const SelectArtifactCategory = (props: IProps) => { setInputVal(currentName); return categoryId; } - if (committingRef.current) return categoryId; - committingRef.current = true; + if (savingRef.current) return categoryId; + savingRef.current = true; try { const newId = await addNewArtifactCategory(name, type); const cats = await getCategorys(); @@ -209,18 +209,18 @@ export const SelectArtifactCategory = (props: IProps) => { } return categoryId; } finally { - committingRef.current = false; + savingRef.current = false; } }; - // Expose commit() to the parent form. No dependency array: re-assign every - // render so the closure stays current; clear on unmount so a stale commit is + // Expose saveCategory() to the parent form. No dependency array: re-assign every + // render so the closure stays current; clear on unmount so a stale save is // never invoked once the field is gone. useEffect(() => { - if (!commitRef) return; - commitRef.current = commit; + if (!categorySaveRef) return; + categorySaveRef.current = saveCategory; return () => { - commitRef.current = null; + categorySaveRef.current = null; }; }); @@ -238,7 +238,7 @@ export const SelectArtifactCategory = (props: IProps) => { inputValue={inputVal} onInputChange={(_e, v, reason) => { setInputVal(v); - // A typed name isn't resolved to an id until commit(), so + // A typed name isn't resolved to an id until saveCategory(), so // onCategoryChange won't fire; tell the parent it's dirty so Save can // enable. Only real keystrokes count, not the programmatic 'reset' MUI // fires when the committed value changes; and without allowNew a typed From 191f3855d18abc71076ef31afbe159022ba2f65c Mon Sep 17 00:00:00 2001 From: Noel Chou Date: Thu, 12 Nov 2026 18:35:29 -0500 Subject: [PATCH 4/5] refactor: onPassResChange -> onResourceKindChange PassRes dates from when the choice was a passage-vs-section boolean; it now sets the three-way resourceKind. Rename ResourceData's onPassResChange to onResourceKindChange and the wizard's handlePassRes to handleResourceKind; the artifact screens' handlePassRes was a bare wrapper, so pass setResourceKind. Co-Authored-By: Claude Opus 5.5 --- .../Internalization/AddResourceWizard.test.tsx | 8 +++++--- .../PassageDetail/Internalization/AddResourceWizard.tsx | 2 +- .../Internalization/PassageDetailArtifacts.tsx | 6 +----- .../Internalization/PassageDetailsArtifactsMobile.tsx | 6 +----- .../PassageDetail/Internalization/ResourceData.tsx | 8 ++++---- .../PassageDetail/Internalization/useAddResourceWizard.ts | 4 ++-- 6 files changed, 14 insertions(+), 20 deletions(-) diff --git a/web/src/components/PassageDetail/Internalization/AddResourceWizard.test.tsx b/web/src/components/PassageDetail/Internalization/AddResourceWizard.test.tsx index faedfc3f7..e629a2f46 100644 --- a/web/src/components/PassageDetail/Internalization/AddResourceWizard.test.tsx +++ b/web/src/components/PassageDetail/Internalization/AddResourceWizard.test.tsx @@ -241,10 +241,10 @@ jest.mock('./ResourceData', () => { __esModule: true, default: ({ onDescriptionChange, - onPassResChange, + onResourceKindChange, }: { onDescriptionChange: (d: string) => void; - onPassResChange?: (k: number) => void; + onResourceKindChange?: (k: number) => void; }) => (
diff --git a/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx b/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx index 7722b30bb..e993083e8 100644 --- a/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx +++ b/web/src/components/PassageDetail/Internalization/AddResourceWizard.tsx @@ -111,7 +111,7 @@ export function AddResourceWizard({ initDescription={w.initDescription} onDescriptionChange={w.handleDescription} resourceKind={w.resourceKind} - onPassResChange={w.handlePassRes} + onResourceKindChange={w.handleResourceKind} allowGeneralResourceOption={w.isAddingAudioResource} /> } diff --git a/web/src/components/PassageDetail/Internalization/PassageDetailArtifacts.tsx b/web/src/components/PassageDetail/Internalization/PassageDetailArtifacts.tsx index 8a4213efd..25e659f64 100644 --- a/web/src/components/PassageDetail/Internalization/PassageDetailArtifacts.tsx +++ b/web/src/components/PassageDetail/Internalization/PassageDetailArtifacts.tsx @@ -632,10 +632,6 @@ export function PassageDetailArtifacts() { ); }; - const handlePassRes = (newValue: ResourceTypeEnum) => { - setResourceKind(newValue); - }; - const handleEnded = () => { setPlayItem(''); handleItemPlayEnd(); @@ -798,7 +794,7 @@ export function PassageDetailArtifacts() { initDescription={descriptionRef.current} onDescriptionChange={handleDescription} resourceKind={resourceKind} - onPassResChange={handlePassRes} + onResourceKindChange={setResourceKind} allowGeneralResourceOption={false} onTextChange={handleTextChange} /> diff --git a/web/src/components/PassageDetail/Internalization/PassageDetailsArtifactsMobile.tsx b/web/src/components/PassageDetail/Internalization/PassageDetailsArtifactsMobile.tsx index af65401e7..480c470f2 100644 --- a/web/src/components/PassageDetail/Internalization/PassageDetailsArtifactsMobile.tsx +++ b/web/src/components/PassageDetail/Internalization/PassageDetailsArtifactsMobile.tsx @@ -632,10 +632,6 @@ export function PassageDetailArtifactsMobile() { ); }; - const handlePassRes = (newValue: ResourceTypeEnum) => { - setResourceKind(newValue); - }; - const handleEnded = () => { setPlayItem(''); handleItemPlayEnd(); @@ -799,7 +795,7 @@ export function PassageDetailArtifactsMobile() { initDescription={descriptionRef.current} onDescriptionChange={handleDescription} resourceKind={resourceKind} - onPassResChange={handlePassRes} + onResourceKindChange={setResourceKind} allowGeneralResourceOption={false} onTextChange={handleTextChange} wrapPreviewOverflow diff --git a/web/src/components/PassageDetail/Internalization/ResourceData.tsx b/web/src/components/PassageDetail/Internalization/ResourceData.tsx index ba6347344..0690becf8 100644 --- a/web/src/components/PassageDetail/Internalization/ResourceData.tsx +++ b/web/src/components/PassageDetail/Internalization/ResourceData.tsx @@ -57,7 +57,7 @@ interface IProps { resourceKind?: ResourceTypeEnum | undefined; onCategoryChange: (artifactCategoryId: string) => void; onDescriptionChange: (desc: string) => void; - onPassResChange?: ((value: ResourceTypeEnum) => void) | undefined; + onResourceKindChange?: ((value: ResourceTypeEnum) => void) | undefined; onTextChange?: ((text: string) => void) | undefined; allowGeneralResourceOption: boolean; // Forwarded to SelectArtifactCategory so the parent form can create a new @@ -72,7 +72,7 @@ export function ResourceData(props: IProps) { resourceKind = ResourceTypeEnum.sectionResource, onCategoryChange, onDescriptionChange, - onPassResChange, + onResourceKindChange, allowGeneralResourceOption, media, uploadType, @@ -114,7 +114,7 @@ export function ResourceData(props: IProps) { ); const handleChange = (event: React.ChangeEvent) => { - onPassResChange?.(radioToResourceKind(event.target.value)); + onResourceKindChange?.(radioToResourceKind(event.target.value)); }; const handleChangeDescription = ( e: React.ChangeEvent @@ -165,7 +165,7 @@ export function ResourceData(props: IProps) { /> - {onPassResChange && ( + {onResourceKindChange && ( {t.tip1a} { + const handleResourceKind = (newValue: ResourceTypeEnum) => { setResourceKind(newValue); if (newValue === ResourceTypeEnum.projectResource) { setUploadType(UploadType.ProjectResource); @@ -519,7 +519,7 @@ export function useAddResourceWizard({ setResourceUploadFiles, handleDescription, handleCategory, - handlePassRes, + handleResourceKind, handleUploadStepNext, handleSectionsSelected, handleSelectSectionsBack, From a229c18074ff686043ae59d19086fd2efb3f4e28 Mon Sep 17 00:00:00 2001 From: Noel Chou Date: Thu, 12 Nov 2026 19:53:20 -0500 Subject: [PATCH 5/5] fix speaker with empty function --- web/src/components/Uploader.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/components/Uploader.tsx b/web/src/components/Uploader.tsx index d4117a72f..bec8d80d1 100644 --- a/web/src/components/Uploader.tsx +++ b/web/src/components/Uploader.tsx @@ -124,10 +124,13 @@ export const Uploader = (props: IProps) => { uploadMethod={uploadMedia} cancelMethod={uploadCancel} speaker={speaker} + // Always a function on a vernacular media upload, even when the host + // passes no onSpeaker: its presence is what makes MediaUploadContent + // show the speaker picker and gate the upload on speaker rights. onSpeaker={ !artifactState?.id && (uploadType || UploadType.Media) === UploadType.Media - ? onSpeaker + ? (onSpeaker ?? (() => {})) : undefined } audioOnly={audioOnly}