From 06993ba135816fe910f35d874ec0861109a7dc4f Mon Sep 17 00:00:00 2001 From: Rohit Date: Wed, 27 Nov 2024 12:00:42 -0500 Subject: [PATCH 1/2] Initial commit --- src/index.tsx | 4 +- .../UploadsCard/UploadsCard.tsx | 62 ++++++++++++++++--- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 2310773400..1ed8f16c5e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -22,8 +22,8 @@ if ( process.env.NODE_ENV === 'development' && process.env.REACT_APP_MSW_BROWSER ) { - const { worker } = require('./mocks/browser') - worker.start() + // const { worker } = require('./mocks/browser') + // worker.start() } ReactModal.setAppElement('#root') diff --git a/src/pages/CommitDetailPage/CommitCoverage/UploadsCard/UploadsCard.tsx b/src/pages/CommitDetailPage/CommitCoverage/UploadsCard/UploadsCard.tsx index 37c267b19e..ba2270db29 100644 --- a/src/pages/CommitDetailPage/CommitCoverage/UploadsCard/UploadsCard.tsx +++ b/src/pages/CommitDetailPage/CommitCoverage/UploadsCard/UploadsCard.tsx @@ -124,6 +124,39 @@ function UploadsCard() { const uploadErrorCount = flatMap(erroredUploads).length const flagErrorCount = flatMap(flagErrorUploads).length + const getUrlsFromUploads = async ( + provider: string, + groupedUploads: Record> + ) => { + const uploads = groupedUploads[provider] + if (!uploads?.length) return + + uploads.forEach(async (upload) => { + if (upload.downloadUrl) { + try { + const response = await fetch(upload.downloadUrl, { + headers: { + 'Content-Type': 'text/plain', + }, + }) + const blob = await response.blob() + const filename = upload.downloadUrl.split('/').pop() || 'download.txt' + + // Force download + const link = document.createElement('a') + link.href = window.URL.createObjectURL(blob) + link.setAttribute('download', filename) + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + window.URL.revokeObjectURL(link.href) + } catch (error) { + console.error('Download failed:', error) + } + } + }) + } + return ( <> @@ -174,15 +207,26 @@ function UploadsCard() { title === NONE && 'text-ds-gray-quaternary' )} > -
- handleSelectAllForProviderGroup(title)} - /> - - {title === NONE ? 'Provider not specified' : title} - +
+
+ handleSelectAllForProviderGroup(title)} + /> + + {title === NONE ? 'Provider not specified' : title} + +
+ {/* Download button moved to the right end */} +
{groupedUploads[title]?.map((upload, i) => ( From cd647d246edbe40dd84021dd9a5053a6cf4ed4e6 Mon Sep 17 00:00:00 2001 From: Rohit Vinnakota <148245014+rohitvinnakota-codecov@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:01:58 -0500 Subject: [PATCH 2/2] Update index.tsx --- src/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 1ed8f16c5e..2310773400 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -22,8 +22,8 @@ if ( process.env.NODE_ENV === 'development' && process.env.REACT_APP_MSW_BROWSER ) { - // const { worker } = require('./mocks/browser') - // worker.start() + const { worker } = require('./mocks/browser') + worker.start() } ReactModal.setAppElement('#root')