Skip to content

Commit e091265

Browse files
committed
fix: include project id when uploading captures
1 parent d0e0f38 commit e091265

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ui/src/data-services/hooks/captures/useUploadCapture.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getAuthHeader } from 'data-services/utils'
55
import { useUser } from 'utils/user/userContext'
66

77
interface UploadCaptureFieldValues {
8+
projectId: string
89
deploymentId: string
910
file: File
1011
}
@@ -16,6 +17,9 @@ export const useUploadCapture = (onSuccess?: (id: string) => void) => {
1617
const { mutate, isLoading, error, isSuccess } = useMutation({
1718
mutationFn: (fieldValues: UploadCaptureFieldValues) => {
1819
const data = new FormData()
20+
if (fieldValues.projectId) {
21+
data.append('project_id', fieldValues.projectId)
22+
}
1923
if (fieldValues.deploymentId) {
2024
data.append('deployment', fieldValues.deploymentId)
2125
}

ui/src/pages/deployment-details/deployment-details-form/section-example-captures/section-example-captures.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Icon, IconTheme, IconType } from 'design-system/components/icon/icon'
1616
import { LoadingSpinner } from 'design-system/components/loading-spinner/loading-spinner'
1717
import { Tooltip } from 'design-system/components/tooltip/tooltip'
1818
import { ReactNode, useEffect, useState } from 'react'
19+
import { useParams } from 'react-router-dom'
1920
import { API_MAX_UPLOAD_SIZE } from 'utils/constants'
2021
import { STRING, translate } from 'utils/language'
2122
import { bytesToMB } from 'utils/numberFormats'
@@ -190,6 +191,7 @@ const AddedExampleCapture = ({
190191
onCancel: () => void
191192
onSuccess: (id: string) => void
192193
}) => {
194+
const { projectId } = useParams()
193195
const { uploadCapture, error } = useUploadCapture(onSuccess)
194196
const { isValid, errorMessage, allowRetry } = useCaptureError({
195197
error,
@@ -203,7 +205,7 @@ const AddedExampleCapture = ({
203205
}
204206

205207
// Trigger capture upload on component mount
206-
uploadCapture({ deploymentId, file })
208+
uploadCapture({ projectId: projectId as string, deploymentId, file })
207209
}, [])
208210

209211
return (
@@ -221,7 +223,11 @@ const AddedExampleCapture = ({
221223
label={translate(STRING.RETRY)}
222224
theme={ButtonTheme.Error}
223225
onClick={() => {
224-
uploadCapture({ deploymentId, file })
226+
uploadCapture({
227+
projectId: projectId as string,
228+
deploymentId,
229+
file,
230+
})
225231
}}
226232
/>
227233
) : (

0 commit comments

Comments
 (0)