feat: [AH-853]: Implement Maven Artifact Details Page (#3317)

* feat: [AH-856]: Support Maven Artifact in global artifact list table
* feat: [AH-853]: Implement Maven Artifact Details Page
This commit is contained in:
Shivanand Sonnad 2025-01-24 13:29:13 +00:00 committed by Harness
parent 30df15d021
commit 58e0787663
3 changed files with 84 additions and 0 deletions

View File

@ -107,6 +107,7 @@ export const ArtifactListPullCommandCell: CellType = ({ value, row }) => {
const { packageType } = original
const { getString } = useStrings()
switch (packageType) {
case RepositoryPackageType.MAVEN:
case RepositoryPackageType.GENERIC:
return (
<TableCells.LinkCell

View File

@ -29,6 +29,7 @@ import {
import { MavenVersionListPage } from './pages/list/MavenVersionListPage'
import { VersionDetailsTab } from '../components/VersionDetailsTabs/constants'
import MavenArtifactOverviewPage from './pages/overview/MavenArtifactOverviewPage'
import MavenArtifactDetailsPage from './pages/artifact-details/MavenArtifactDetailsPage'
import VersionDetailsHeaderContent from '../components/VersionDetailsHeaderContent/VersionDetailsHeaderContent'
export class GenericVersionType extends VersionStep<ArtifactVersionSummary> {
@ -51,6 +52,8 @@ export class GenericVersionType extends VersionStep<ArtifactVersionSummary> {
switch (props.tab) {
case VersionDetailsTab.OVERVIEW:
return <MavenArtifactOverviewPage />
case VersionDetailsTab.ARTIFACT_DETAILS:
return <MavenArtifactDetailsPage />
default:
return <String stringID="tabNotFound" />
}

View File

@ -0,0 +1,80 @@
/*
* Copyright 2024 Harness, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react'
import { Page } from '@harnessio/uicore'
import { useGetArtifactFilesQuery } from '@harnessio/react-har-service-client'
import { DEFAULT_PAGE_INDEX } from '@ar/constants'
import type { VersionDetailsPathParams } from '@ar/routes/types'
import { useDecodedParams, useGetSpaceRef, useParentHooks } from '@ar/hooks'
import {
type ArtifactFileListPageQueryParams,
useArtifactFileListQueryParamOptions
} from '@ar/pages/version-details/components/ArtifactFileListTable/utils'
import ArtifactFileListTable from '@ar/pages/version-details/components/ArtifactFileListTable/ArtifactFileListTable'
import versionDetailsPageCss from '../../MavenVersion.module.scss'
export default function MavenArtifactDetailsPage() {
const registryRef = useGetSpaceRef()
const { useQueryParams, useUpdateQueryParams } = useParentHooks()
const { updateQueryParams } = useUpdateQueryParams<Partial<ArtifactFileListPageQueryParams>>()
const pathParams = useDecodedParams<VersionDetailsPathParams>()
const queryParamOptions = useArtifactFileListQueryParamOptions()
const queryParams = useQueryParams<ArtifactFileListPageQueryParams>(queryParamOptions)
const { searchTerm, page, size, sort } = queryParams
const [sortField, sortOrder] = sort || []
const {
isFetching: loading,
error,
data,
refetch
} = useGetArtifactFilesQuery({
registry_ref: registryRef,
artifact: pathParams.artifactIdentifier,
version: pathParams.versionIdentifier,
queryParams: {
searchTerm,
page,
size,
sortField,
sortOrder
}
})
const response = data?.content
return (
<Page.Body
className={versionDetailsPageCss.pageBody}
loading={loading}
error={error?.message || error}
retryOnError={() => refetch()}>
{response && (
<ArtifactFileListTable
data={response}
gotoPage={pageNumber => updateQueryParams({ page: pageNumber })}
setSortBy={sortArr => {
updateQueryParams({ sort: sortArr, page: DEFAULT_PAGE_INDEX })
}}
sortBy={sort}
/>
)}
</Page.Body>
)
}