1
- //@ts -nocheck
2
-
3
- import React , { useMemo } from 'react'
1
+ // @ts -nocheck - @TODO: Remove this by fixing the type issues
2
+ import React , { useEffect , useMemo , useState } from 'react'
4
3
import { Link } from 'react-router-dom'
5
4
import { URLS } from '../../../../config'
6
5
import { EnvSelector } from './AppDetails'
@@ -11,7 +10,7 @@ import { Nodes, SourceInfoType } from '../../types'
11
10
import Tippy from '@tippyjs/react'
12
11
import { ReactComponent as LinkIcon } from '../../../../assets/icons/ic-link.svg'
13
12
import { ReactComponent as Trash } from '../../../../assets/icons/ic-delete-dots.svg'
14
- import { ConditionalWrap , DeploymentAppTypes } from '@devtron-labs/devtron-fe-common-lib'
13
+ import { ConditionalWrap , DeploymentAppTypes , showError } from '@devtron-labs/devtron-fe-common-lib'
15
14
import DeploymentStatusCard from './DeploymentStatusCard'
16
15
import { importComponentFromFELibrary } from '../../../common/helpers/Helpers'
17
16
import DeploymentTypeIcon from '../../../common/DeploymentTypeIcon/DeploymentTypeIcon'
@@ -20,6 +19,7 @@ import DeployedCommitCard from './DeployedCommitCard'
20
19
import IssuesCard from './IssuesCard'
21
20
import SecurityVulnerabilityCard from './SecurityVulnerabilityCard'
22
21
import AppStatusCard from './AppStatusCard'
22
+ import { getLastExecutionByArtifactId } from '../../../../services/service'
23
23
24
24
const AppDetailsDownloadCard = importComponentFromFELibrary ( 'AppDetailsDownloadCard' )
25
25
@@ -45,6 +45,7 @@ export function SourceInfo({
45
45
ciArtifactId,
46
46
setErrorsList,
47
47
} : SourceInfoType ) {
48
+ const [ showVulnerabilitiesCard , setShowVulnerabilitiesCard ] = useState < boolean > ( false )
48
49
const isdeploymentAppDeleting = appDetails ?. deploymentAppDeleteRequest || false
49
50
const isArgoCdApp = appDetails ?. deploymentAppType === DeploymentAppTypes . GITOPS
50
51
const status = appDetails ?. resourceTree ?. status || ''
@@ -63,6 +64,30 @@ export function SourceInfo({
63
64
message = Rollout [ 0 ] . health . message
64
65
}
65
66
67
+ const getScannedStatus = async ( ) => {
68
+ const { appId, ciArtifactId } = appDetails
69
+ try {
70
+ const {
71
+ result : { scanEnabled, scanned } ,
72
+ } = await getLastExecutionByArtifactId ( appId , ciArtifactId )
73
+ if ( scanEnabled && scanned ) {
74
+ // If scanEnabled and scanned is true, then show the vulnerabilities card
75
+ setShowVulnerabilitiesCard ( true )
76
+ } else {
77
+ setShowVulnerabilitiesCard ( false )
78
+ }
79
+ } catch ( error ) {
80
+ setShowVulnerabilitiesCard ( false )
81
+ showError ( error )
82
+ }
83
+ }
84
+
85
+ useEffect ( ( ) => {
86
+ if ( appDetails ?. ciArtifactId && appDetails ?. appId ) {
87
+ getScannedStatus ( )
88
+ }
89
+ } , [ appDetails ?. ciArtifactId , appDetails ?. appId ] )
90
+
66
91
const onClickShowCommitInfo = ( ) : void => {
67
92
showCommitInfo ( true )
68
93
}
@@ -218,17 +243,21 @@ export function SourceInfo({
218
243
isVirtualEnvironment = { isVirtualEnvironment }
219
244
refetchDeploymentStatus = { refetchDeploymentStatus }
220
245
/>
221
- < DeployedCommitCard
222
- cardLoading = { cardLoading }
223
- showCommitInfoDrawer = { onClickShowCommitInfo }
224
- envId = { envId }
225
- ciArtifactId = { ciArtifactId }
226
- />
227
- < SecurityVulnerabilityCard
228
- cardLoading = { cardLoading }
229
- severityCount = { severityCount }
230
- showVulnerabilitiesModal = { showVulnerabilitiesModal }
231
- />
246
+ { appDetails ?. dataSource !== 'EXTERNAL' && (
247
+ < DeployedCommitCard
248
+ cardLoading = { cardLoading }
249
+ showCommitInfoDrawer = { onClickShowCommitInfo }
250
+ envId = { envId }
251
+ ciArtifactId = { ciArtifactId }
252
+ />
253
+ ) }
254
+ { ! appDetails ?. deploymentAppDeleteRequest && showVulnerabilitiesCard && (
255
+ < SecurityVulnerabilityCard
256
+ cardLoading = { cardLoading }
257
+ severityCount = { severityCount }
258
+ showVulnerabilitiesModal = { showVulnerabilitiesModal }
259
+ />
260
+ ) }
232
261
< div className = "flex right ml-auto" >
233
262
{ appDetails ?. appStoreChartId && (
234
263
< >
0 commit comments