diff --git a/src/components/BuildConfigDetailPage/BuilConfigRevisionPage.tsx b/src/components/BuildConfigDetailPage/BuilConfigRevisionPage.tsx index fa14df82..fe309b16 100644 --- a/src/components/BuildConfigDetailPage/BuilConfigRevisionPage.tsx +++ b/src/components/BuildConfigDetailPage/BuilConfigRevisionPage.tsx @@ -1,4 +1,5 @@ import { useEffect } from 'react'; +import { useOutletContext } from 'react-router-dom'; import { useParamsRequired } from 'hooks/useParamsRequired'; import { useServiceContainer } from 'hooks/useServiceContainer'; @@ -7,8 +8,13 @@ import { BuildConfigDetail } from 'components/BuildConfigDetailPage/BuildConfigD import * as buildConfigApi from 'services/buildConfigApi'; +interface IOutletContext { + isCurrentRevision: boolean; +} + export const BuildConfigRevisionPage = () => { const { buildConfigId, revisionId } = useParamsRequired(); + const { isCurrentRevision } = useOutletContext(); const serviceContainerBuildConfigRevision = useServiceContainer(buildConfigApi.getRevision); const serviceContainerBuildConfigRevisionRunner = serviceContainerBuildConfigRevision.run; @@ -17,5 +23,13 @@ export const BuildConfigRevisionPage = () => { serviceContainerBuildConfigRevisionRunner({ serviceData: { buildConfigId, buildConfigRev: Number(revisionId) } }); }, [serviceContainerBuildConfigRevisionRunner, buildConfigId, revisionId]); - return ; + return ( + + ); }; diff --git a/src/components/BuildConfigDetailPage/BuildConfigDetail.tsx b/src/components/BuildConfigDetailPage/BuildConfigDetail.tsx index 1b56e1c8..7d18d3c5 100644 --- a/src/components/BuildConfigDetailPage/BuildConfigDetail.tsx +++ b/src/components/BuildConfigDetailPage/BuildConfigDetail.tsx @@ -34,12 +34,14 @@ interface IBuildConfigDetailProps { serviceContainerBuildConfig: IServiceContainerState; serviceContainerProductVersion?: IServiceContainerState; isRevisionVariant?: boolean; + isCurrentRevision?: boolean; } export const BuildConfigDetail = ({ serviceContainerBuildConfig, serviceContainerProductVersion, isRevisionVariant = false, + isCurrentRevision = true, }: IBuildConfigDetailProps) => { const [isRestoreModalOpen, setIsRestoreModalOpen] = useState(false); const toggleRestoreModal = () => setIsRestoreModalOpen((isRestoreModalOpen) => !isRestoreModalOpen); @@ -60,7 +62,7 @@ export const BuildConfigDetail = ({ {isRevisionVariant && ( - + )} diff --git a/src/components/BuildConfigRestoreModal/BuildConfigRestoreModalButton.tsx b/src/components/BuildConfigRestoreModal/BuildConfigRestoreModalButton.tsx index 99d06056..a0fb4d29 100644 --- a/src/components/BuildConfigRestoreModal/BuildConfigRestoreModalButton.tsx +++ b/src/components/BuildConfigRestoreModal/BuildConfigRestoreModalButton.tsx @@ -4,12 +4,15 @@ import { ProtectedComponent } from 'components/ProtectedContent/ProtectedCompone interface IBuildConfigRestoreModalButtonProps { toggleModal: () => void; + isDisabled?: boolean; } -export const BuildConfigRestoreModalButton = ({ toggleModal }: IBuildConfigRestoreModalButtonProps) => ( +export const BuildConfigRestoreModalButton = ({ toggleModal, isDisabled = false }: IBuildConfigRestoreModalButtonProps) => ( - +
+ +
); diff --git a/src/components/BuildConfigRevisionPages/BuildConfigRevisionPages.tsx b/src/components/BuildConfigRevisionPages/BuildConfigRevisionPages.tsx index 9c5437fa..76fedc06 100644 --- a/src/components/BuildConfigRevisionPages/BuildConfigRevisionPages.tsx +++ b/src/components/BuildConfigRevisionPages/BuildConfigRevisionPages.tsx @@ -1,5 +1,5 @@ import { Grid, GridItem } from '@patternfly/react-core'; -import { useCallback } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { Outlet, useLocation, useNavigate, useParams } from 'react-router-dom'; import { useParamsRequired } from 'hooks/useParamsRequired'; @@ -10,6 +10,8 @@ import { BuildConfigRevisionsList } from 'components/BuildConfigRevisionsList/Bu import * as buildConfigApi from 'services/buildConfigApi'; +import { getComponentQueryParamValue } from 'utils/queryParamsHelper'; + interface IBuildConfigDetailPageProps { componentId?: string; } @@ -23,6 +25,8 @@ export const BuildConfigRevisionPages = ({ componentId = 'r1' }: IBuildConfigDet const serviceContainerBuildConfigRevisions = useServiceContainer(buildConfigApi.getRevisions); const serviceContainerBuildConfigRevisionsRunner = serviceContainerBuildConfigRevisions.run; + const [isCurrentRevision, setIsCurrentRevision] = useState(false); + if (!revisionId && serviceContainerBuildConfigRevisions.data?.content?.length) { navigate(serviceContainerBuildConfigRevisions.data.content.at(0)?.rev + search, { replace: true }); } @@ -36,13 +40,23 @@ export const BuildConfigRevisionPages = ({ componentId = 'r1' }: IBuildConfigDet { componentId, mandatoryQueryParams: listMandatoryQueryParams.pagination } ); + useEffect(() => { + const pageIndex = getComponentQueryParamValue(search, 'pageIndex', componentId); + if (serviceContainerBuildConfigRevisions.data?.content?.length && pageIndex === '1') { + const latestRev = serviceContainerBuildConfigRevisions.data.content[0]?.rev; + setIsCurrentRevision(String(latestRev) === revisionId); + } else { + setIsCurrentRevision(false); + } + }, [serviceContainerBuildConfigRevisions.data, revisionId, search, componentId]); + return ( - + );