mirror of
https://github.com/harness/drone.git
synced 2025-05-06 08:20:34 +08:00
feat: [AH-944]: support link to latest version in registry artifact list table (#3410)
* feat: [AH-944]: support link to latest version in registry artifact list table
This commit is contained in:
parent
11b4bb4afc
commit
1e619e8219
@ -14,13 +14,26 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { defaultTo, isEmpty } from 'lodash-es'
|
||||||
import type { ARRouteDefinitionsReturn } from '@ar/routes/RouteDefinitions'
|
import type { ARRouteDefinitionsReturn } from '@ar/routes/RouteDefinitions'
|
||||||
|
|
||||||
export default function getARRouteDefinitions(routeParams: Record<string, string>): ARRouteDefinitionsReturn {
|
export default function getARRouteDefinitions(routeParams: Record<string, string>): ARRouteDefinitionsReturn {
|
||||||
return {
|
return {
|
||||||
// anything random, as this route will not be used in gitness
|
// anything random, as this route will not be used in gitness
|
||||||
toAR: () => '/ar',
|
toAR: () => '/ar',
|
||||||
toARRedirect: () => '/ar', // currently not used for gitness
|
toARRedirect: params => {
|
||||||
|
if (!isEmpty(params)) {
|
||||||
|
const queryParams = new URLSearchParams({
|
||||||
|
packageType: defaultTo(params?.packageType, ''),
|
||||||
|
registryId: defaultTo(params?.registryId, ''),
|
||||||
|
artifactId: defaultTo(params?.artifactId, ''),
|
||||||
|
versionId: defaultTo(params?.versionId, ''),
|
||||||
|
versionDetailsTab: defaultTo(params?.versionDetailsTab, '')
|
||||||
|
})
|
||||||
|
return `/redirect?${queryParams.toString()}`
|
||||||
|
}
|
||||||
|
return '/redirect'
|
||||||
|
},
|
||||||
toARRepositories: () => '/',
|
toARRepositories: () => '/',
|
||||||
toARRepositoryDetails: params => `/${params?.repositoryIdentifier}`,
|
toARRepositoryDetails: params => `/${params?.repositoryIdentifier}`,
|
||||||
toARRepositoryDetailsTab: params => `/${params?.repositoryIdentifier}/${params?.tab}`,
|
toARRepositoryDetailsTab: params => `/${params?.repositoryIdentifier}/${params?.tab}`,
|
||||||
|
@ -30,6 +30,7 @@ import LabelsPopover from '@ar/components/LabelsPopover/LabelsPopover'
|
|||||||
import RepositoryIcon from '@ar/frameworks/RepositoryStep/RepositoryIcon'
|
import RepositoryIcon from '@ar/frameworks/RepositoryStep/RepositoryIcon'
|
||||||
import type { RepositoryPackageType } from '@ar/common/types'
|
import type { RepositoryPackageType } from '@ar/common/types'
|
||||||
import { RepositoryDetailsTab } from '@ar/pages/repository-details/constants'
|
import { RepositoryDetailsTab } from '@ar/pages/repository-details/constants'
|
||||||
|
import { VersionDetailsTab } from '@ar/pages/version-details/components/VersionDetailsTabs/constants'
|
||||||
|
|
||||||
type CellTypeWithActions<D extends Record<string, any>, V = any> = TableInstance<D> & {
|
type CellTypeWithActions<D extends Record<string, any>, V = any> = TableInstance<D> & {
|
||||||
column: ColumnInstance<D>
|
column: ColumnInstance<D>
|
||||||
@ -115,6 +116,7 @@ export const RegistryArtifactDownloadsCell: CellType = ({ value }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const RegistryArtifactLatestUpdatedCell: CellType = ({ row }) => {
|
export const RegistryArtifactLatestUpdatedCell: CellType = ({ row }) => {
|
||||||
|
const routes = useRoutes()
|
||||||
const { getString } = useStrings()
|
const { getString } = useStrings()
|
||||||
const { original } = row
|
const { original } = row
|
||||||
const { latestVersion, lastModified } = original || {}
|
const { latestVersion, lastModified } = original || {}
|
||||||
@ -127,9 +129,16 @@ export const RegistryArtifactLatestUpdatedCell: CellType = ({ row }) => {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Layout.Vertical spacing="small">
|
<Layout.Vertical spacing="small">
|
||||||
<Text lineClamp={1} color={Color.PRIMARY_7} font={{ size: 'small' }}>
|
<TableCells.LinkCell
|
||||||
{latestVersion}
|
linkTo={routes.toARRedirect({
|
||||||
</Text>
|
registryId: original.registryIdentifier,
|
||||||
|
packageType: original.packageType as RepositoryPackageType,
|
||||||
|
artifactId: original.name,
|
||||||
|
versionId: latestVersion,
|
||||||
|
versionDetailsTab: VersionDetailsTab.OVERVIEW
|
||||||
|
})}
|
||||||
|
label={latestVersion}
|
||||||
|
/>
|
||||||
<TableCells.LastModifiedCell value={defaultTo(lastModified, 0)} />
|
<TableCells.LastModifiedCell value={defaultTo(lastModified, 0)} />
|
||||||
</Layout.Vertical>
|
</Layout.Vertical>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user