Skip to content

Commit c460156

Browse files
committed
Merge branch 'main' of https://github.com/devtron-labs/devtron-fe-common-lib into feat/use-download-global
2 parents 7c286e6 + d4b195a commit c460156

File tree

4 files changed

+30
-35
lines changed

4 files changed

+30
-35
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.1.8-beta-16",
3+
"version": "0.1.9-beta-1",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/CICDHistory/Artifacts.tsx

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ const Artifacts = ({
162162
if (status.toLowerCase() === TERMINAL_STATUS_MAP.RUNNING || status.toLowerCase() === TERMINAL_STATUS_MAP.STARTING) {
163163
return <CIProgressView />
164164
}
165-
if (isJobView && !blobStorageEnabled) {
165+
if (!blobStorageEnabled) {
166166
return (
167167
<div className="flex column p-24 w-100 h-100">
168168
<GenericEmptyState
@@ -188,15 +188,6 @@ const Artifacts = ({
188188
</div>
189189
)
190190
}
191-
if (isJobView && !isArtifactUploaded) {
192-
return (
193-
<GenericEmptyState
194-
title={EMPTY_STATE_STATUS.ARTIFACTS_EMPTY_STATE_TEXTS.NoFilesFound}
195-
subTitle={EMPTY_STATE_STATUS.ARTIFACTS_EMPTY_STATE_TEXTS.NoFilesGenerated}
196-
image={noartifact}
197-
/>
198-
)
199-
}
200191
if (status.toLowerCase() === TERMINAL_STATUS_MAP.FAILED || status.toLowerCase() === TERMINAL_STATUS_MAP.CANCELLED) {
201192
if (isJobCI) {
202193
return (
@@ -214,7 +205,7 @@ const Artifacts = ({
214205
/>
215206
)
216207
}
217-
if (!artifactId && status.toLowerCase() === TERMINAL_STATUS_MAP.SUCCEEDED) {
208+
if (!artifactId && status.toLowerCase() === TERMINAL_STATUS_MAP.SUCCEEDED && !isJobView) {
218209
return (
219210
<GenericEmptyState
220211
title={EMPTY_STATE_STATUS.ARTIFACTS_EMPTY_STATE_TEXTS.NoArtifactsFound}
@@ -254,26 +245,28 @@ const Artifacts = ({
254245
</div>
255246
</CIListItem>
256247
)}
257-
{blobStorageEnabled && downloadArtifactUrl && (type === HistoryComponentType.CD || isArtifactUploaded) && (
258-
<CIListItem
259-
type="report"
260-
hideImageTaggingHardDelete={hideImageTaggingHardDelete}
261-
isSuperAdmin={isSuperAdmin}
262-
renderCIListHeader={renderCIListHeader}
263-
>
264-
<div className="flex column left">
265-
<div className="cn-9 fs-14">Reports.zip</div>
266-
<button
267-
type="button"
268-
onClick={handleArtifact}
269-
className="anchor p-0 cb-5 fs-12 flex left pointer"
270-
>
271-
Download
272-
<Download className="ml-5 icon-dim-16" />
273-
</button>
274-
</div>
275-
</CIListItem>
276-
)}
248+
{blobStorageEnabled &&
249+
downloadArtifactUrl &&
250+
(type === HistoryComponentType.CD || isArtifactUploaded || isJobView) && (
251+
<CIListItem
252+
type="report"
253+
hideImageTaggingHardDelete={hideImageTaggingHardDelete}
254+
isSuperAdmin={isSuperAdmin}
255+
renderCIListHeader={renderCIListHeader}
256+
>
257+
<div className="flex column left">
258+
<div className="cn-9 fs-14">Reports.zip</div>
259+
<button
260+
type="button"
261+
onClick={handleArtifact}
262+
className="anchor p-0 cb-5 fs-12 flex left pointer"
263+
>
264+
Download
265+
<Download className="ml-5 icon-dim-16" />
266+
</button>
267+
</div>
268+
</CIListItem>
269+
)}
277270
</div>
278271
)
279272
}

src/Shared/Hooks/UseDownload/UseDownload.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { HandleDownloadProps } from './types'
99

1010
const useDownload = () => {
1111
const [isDownloading, setIsDownloading] = useState<boolean>(false)
12+
const [downloadError, setDownloadError] = useState(null)
1213

1314
/**
1415
* @param downloadUrl - API url for downloading file
@@ -77,13 +78,14 @@ const useDownload = () => {
7778
throw new ServerErrors(jsonResponseError)
7879
}
7980
} catch (error) {
81+
setDownloadError(error)
8082
showError(error)
8183
} finally {
8284
setIsDownloading(false)
8385
}
8486
}
8587

86-
return { handleDownload, isDownloading }
88+
return { handleDownload, isDownloading, downloadError }
8789
}
8890

8991
export default useDownload

0 commit comments

Comments
 (0)