feat: [AH-680]: fix not showing scan data on global artifact list page (#3646)

* feat: [AH-680]: resolve PR comments
* feat: [AH-680]: fix not showing scan data on global artifact list page
This commit is contained in:
Shivanand Sonnad 2025-04-08 11:17:53 +00:00 committed by Harness
parent e32b04b8ad
commit 4e9ce9d81a
3 changed files with 60 additions and 58 deletions

View File

@ -51,7 +51,7 @@
"@codemirror/view": "^6.9.6", "@codemirror/view": "^6.9.6",
"@harnessio/design-system": "^2.1.1", "@harnessio/design-system": "^2.1.1",
"@harnessio/icons": "^2.1.9", "@harnessio/icons": "^2.1.9",
"@harnessio/react-har-service-client": "^0.16.0", "@harnessio/react-har-service-client": "^0.17.0",
"@harnessio/react-ng-manager-client": "^1.40.0", "@harnessio/react-ng-manager-client": "^1.40.0",
"@harnessio/react-ssca-manager-client": "^0.65.0", "@harnessio/react-ssca-manager-client": "^0.65.0",
"@harnessio/uicore": "^4.1.2", "@harnessio/uicore": "^4.1.2",

View File

@ -14,16 +14,17 @@
* limitations under the License. * limitations under the License.
*/ */
import React, { useState } from 'react' import React from 'react'
import QueryString from 'qs'
import { defaultTo } from 'lodash-es' import { defaultTo } from 'lodash-es'
import { Link, useHistory } from 'react-router-dom' import { Link } from 'react-router-dom'
import { Menu, Position } from '@blueprintjs/core' import { Position } from '@blueprintjs/core'
import { Color, FontVariation } from '@harnessio/design-system' import { Color, FontVariation } from '@harnessio/design-system'
import { Button, ButtonVariation, Layout, Text } from '@harnessio/uicore' import { Button, ButtonVariation, Layout, Text } from '@harnessio/uicore'
import type { Cell, CellValue, ColumnInstance, Renderer, Row, TableInstance } from 'react-table' import type { Cell, CellValue, ColumnInstance, Renderer, Row, TableInstance } from 'react-table'
import type { ArtifactMetadata, StoDigestMetadata } from '@harnessio/react-har-service-client' import type { ArtifactMetadata, StoDigestMetadata } from '@harnessio/react-har-service-client'
import { useParentComponents, useRoutes } from '@ar/hooks' import { useRoutes } from '@ar/hooks'
import TableCells from '@ar/components/TableCells/TableCells' import TableCells from '@ar/components/TableCells/TableCells'
import { PageType, RepositoryPackageType } from '@ar/common/types' import { PageType, RepositoryPackageType } from '@ar/common/types'
import LabelsPopover from '@ar/components/LabelsPopover/LabelsPopover' import LabelsPopover from '@ar/components/LabelsPopover/LabelsPopover'
@ -126,65 +127,66 @@ export const ArtifactListPullCommandCell: CellType = ({ value, row }) => {
} }
} }
export const ArtifactListVulnerabilitiesCell: CellType = ({ row }) => { interface ScannedDigestListProps {
const { original } = row list: StoDigestMetadata[]
const { stoMetadata, registryIdentifier, name, version } = original metadata: ArtifactMetadata
const { scannedCount, totalCount, digestMetadata } = stoMetadata || {} }
const [isOptionsOpen, setIsOptionsOpen] = useState(false)
const { getString } = useStrings()
const { RbacMenuItem } = useParentComponents()
const routes = useRoutes()
const history = useHistory()
const handleRenderDigestMenuItem = (digest: StoDigestMetadata) => { const ScannedDigestList = (props: ScannedDigestListProps) => {
const { list, metadata } = props
const routes = useRoutes()
return ( return (
<RbacMenuItem <Layout.Vertical width={450}>
text={getString('artifactList.table.actions.VulnerabilityStatus.digestMenuItemText', { {list.map(each => (
archName: digest.osArch, <Layout.Horizontal
digest: getShortDigest(digest.digest || '') padding="small"
})} spacing="medium"
onClick={() => { flex={{ alignItems: 'center', justifyContent: 'space-between' }}
const url = routes.toARVersionDetailsTab({ key={each.digest}>
repositoryIdentifier: registryIdentifier, <TableCells.LinkCell
artifactIdentifier: name, linkTo={
versionIdentifier: version as string, routes.toARVersionDetailsTab({
versionTab: VersionDetailsTab.SECURITY_TESTS, repositoryIdentifier: metadata.registryIdentifier,
pipelineIdentifier: digest.stoPipelineId, artifactIdentifier: metadata.name,
executionIdentifier: digest.stoExecutionId versionIdentifier: metadata.version,
}) versionTab: VersionDetailsTab.OVERVIEW
history.push(`${url}?digest=${digest.digest}`) }) + `?${QueryString.stringify({ digest: each.digest }, { skipNulls: true })}`
}} }
label={getShortDigest(each.digest || '')}
/> />
<TableCells.TextCell value={each.osArch} />
<TableCells.VulnerabilityCell
critical={each.stoDetails?.critical}
high={each.stoDetails?.high}
low={each.stoDetails?.low}
medium={each.stoDetails?.medium}
/>
</Layout.Horizontal>
))}
</Layout.Vertical>
) )
} }
export const ArtifactListVulnerabilitiesCell: CellType = ({ row }) => {
const { original } = row
const { stoMetadata } = original
const { scannedCount, totalCount, digestMetadata } = stoMetadata || {}
const { getString } = useStrings()
if (!scannedCount) { if (!scannedCount) {
return <Text>{getString('artifactList.table.actions.VulnerabilityStatus.nonScanned')}</Text> return <Text>{getString('artifactList.table.actions.VulnerabilityStatus.nonScanned')}</Text>
} }
return ( return (
<Button <Button className={css.cellBtn} variation={ButtonVariation.LINK}>
className={css.cellBtn} <Text
tooltip={ font={{ variation: FontVariation.BODY }}
<Menu color={Color.PRIMARY_7}
className={css.optionsMenu}
onClick={e => {
e.stopPropagation()
setIsOptionsOpen(false)
}}>
{digestMetadata?.map(handleRenderDigestMenuItem)}
</Menu>
}
tooltipProps={{ tooltipProps={{
interactionKind: 'click', interactionKind: 'click',
onInteraction: nextOpenState => {
setIsOptionsOpen(nextOpenState)
},
isOpen: isOptionsOpen,
position: Position.BOTTOM position: Position.BOTTOM
}} }}
variation={ButtonVariation.LINK}> tooltip={<ScannedDigestList list={digestMetadata || []} metadata={original} />}>
<Text font={{ variation: FontVariation.BODY }} color={Color.PRIMARY_7}>
{getString('artifactList.table.actions.VulnerabilityStatus.partiallyScanned', { {getString('artifactList.table.actions.VulnerabilityStatus.partiallyScanned', {
total: defaultTo(totalCount, 0), total: defaultTo(totalCount, 0),
scanned: defaultTo(scannedCount, 0) scanned: defaultTo(scannedCount, 0)

View File

@ -1945,10 +1945,10 @@
yargs "^17.6.2" yargs "^17.6.2"
zod "^3.19.1" zod "^3.19.1"
"@harnessio/react-har-service-client@^0.16.0": "@harnessio/react-har-service-client@^0.17.0":
version "0.16.0" version "0.17.0"
resolved "https://registry.yarnpkg.com/@harnessio/react-har-service-client/-/react-har-service-client-0.16.0.tgz#5fca5fa25b003cb87f21fe03132c4888aa6ea6bb" resolved "https://registry.yarnpkg.com/@harnessio/react-har-service-client/-/react-har-service-client-0.17.0.tgz#0d292fd06a706469a850001af052055846c4e4a2"
integrity sha512-bf3lA5Yh3tpbn6kxeDrN+7ERp/btkZERYjO8oNe+SsM7tQttFRZyyAk1nFYcMc6oUOATLHN/wwYdsXuOLhcjiw== integrity sha512-NhSdpuFydxXaaxZJrjXuUfz61pXsWGy0qDqgoel6PRu6VuUHMxzl1n/8jhJh4gqCJAj7RHxbq2292NfhKlRcUA==
dependencies: dependencies:
"@harnessio/oats-cli" "^3.0.0" "@harnessio/oats-cli" "^3.0.0"