mirror of
https://github.com/harness/drone.git
synced 2025-05-04 00:10:07 +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.
|
||||
*/
|
||||
|
||||
import { defaultTo, isEmpty } from 'lodash-es'
|
||||
import type { ARRouteDefinitionsReturn } from '@ar/routes/RouteDefinitions'
|
||||
|
||||
export default function getARRouteDefinitions(routeParams: Record<string, string>): ARRouteDefinitionsReturn {
|
||||
return {
|
||||
// anything random, as this route will not be used in gitness
|
||||
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: () => '/',
|
||||
toARRepositoryDetails: params => `/${params?.repositoryIdentifier}`,
|
||||
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 type { RepositoryPackageType } from '@ar/common/types'
|
||||
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> & {
|
||||
column: ColumnInstance<D>
|
||||
@ -115,6 +116,7 @@ export const RegistryArtifactDownloadsCell: CellType = ({ value }) => {
|
||||
}
|
||||
|
||||
export const RegistryArtifactLatestUpdatedCell: CellType = ({ row }) => {
|
||||
const routes = useRoutes()
|
||||
const { getString } = useStrings()
|
||||
const { original } = row
|
||||
const { latestVersion, lastModified } = original || {}
|
||||
@ -127,9 +129,16 @@ export const RegistryArtifactLatestUpdatedCell: CellType = ({ row }) => {
|
||||
}
|
||||
return (
|
||||
<Layout.Vertical spacing="small">
|
||||
<Text lineClamp={1} color={Color.PRIMARY_7} font={{ size: 'small' }}>
|
||||
{latestVersion}
|
||||
</Text>
|
||||
<TableCells.LinkCell
|
||||
linkTo={routes.toARRedirect({
|
||||
registryId: original.registryIdentifier,
|
||||
packageType: original.packageType as RepositoryPackageType,
|
||||
artifactId: original.name,
|
||||
versionId: latestVersion,
|
||||
versionDetailsTab: VersionDetailsTab.OVERVIEW
|
||||
})}
|
||||
label={latestVersion}
|
||||
/>
|
||||
<TableCells.LastModifiedCell value={defaultTo(lastModified, 0)} />
|
||||
</Layout.Vertical>
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user