Skip to content

Commit

Permalink
Fix routing on cluster detail card
Browse files Browse the repository at this point in the history
  • Loading branch information
jgyselov committed Sep 11, 2024
1 parent 5a35b21 commit 9539e88
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ import { usePullSecret } from '../../hooks';
import { Cluster } from '@openshift-assisted/types/assisted-installer-service';
import { useFeatureDetection } from '../../hooks/use-feature-detection';
import { OpenshiftVersionsContextProvider } from '../clusterWizard/OpenshiftVersionsContext';
import { BrowserRouter } from 'react-router-dom-v5-compat';
import {
unstable_HistoryRouter as HistoryRouter,
HistoryRouterProps,
BrowserRouter,
} from 'react-router-dom-v5-compat';

type AssistedInstallerDetailCardProps = {
aiClusterId: string;
allEnabledFeatures: FeatureListType;
history: HistoryRouterProps['history'];
basename: HistoryRouterProps['basename'];
permissions?: AssistedInstallerOCMPermissionTypesListType;
};

Expand Down Expand Up @@ -64,7 +70,7 @@ const ClusterLoadFailed = ({ clusterId, error }: { clusterId: Cluster['id']; err
<ErrorState
title="Failed to fetch the cluster"
fetchData={fetchCluster}
actions={[<BackButton key={'cancel'} to={'..'} />]}
actions={[<BackButton key={'cancel'} to={'/cluster-list'} />]}
content={error}
/>
</BrowserRouter>
Expand All @@ -84,7 +90,7 @@ const LoadingDefaultConfigFailedCard = () => (
<BrowserRouter>
<ErrorState
title="Failed to retrieve the default configuration"
actions={[<BackButton key={'cancel'} to={'..'} />]}
actions={[<BackButton key={'cancel'} to={'/cluster-list'} />]}
/>
</BrowserRouter>
</CardBody>
Expand All @@ -94,6 +100,8 @@ const LoadingDefaultConfigFailedCard = () => (
const AssistedInstallerDetailCard = ({
aiClusterId,
allEnabledFeatures,
history,
basename,
permissions,
}: AssistedInstallerDetailCardProps) => {
useFeatureDetection(allEnabledFeatures);
Expand Down Expand Up @@ -136,33 +144,36 @@ const AssistedInstallerDetailCard = ({
);

const isOutdatedClusterData = uiState === ResourceUIState.POLLING_ERROR;

return (
<AlertsContextProvider>
<OpenshiftVersionsContextProvider>
<SentryErrorMonitorContextProvider>
<ModalDialogsContextProvider>
<ClusterDefaultConfigurationProvider
loadingUI={<LoadingCard />}
errorUI={<LoadingDefaultConfigFailedCard />}
>
<NewFeatureSupportLevelProvider
loadingUi={<LoadingCard />}
cluster={cluster}
cpuArchitecture={infraEnv.cpuArchitecture as CpuArchitecture}
openshiftVersion={cluster.openshiftVersion}
platformType={cluster.platform?.type}
<HistoryRouter history={history} basename={basename}>
<AlertsContextProvider>
<OpenshiftVersionsContextProvider>
<SentryErrorMonitorContextProvider>
<ModalDialogsContextProvider>
<ClusterDefaultConfigurationProvider
loadingUI={<LoadingCard />}
errorUI={<LoadingDefaultConfigFailedCard />}
>
{content}
</NewFeatureSupportLevelProvider>
{isOutdatedClusterData && <ClusterPollingErrorModal />}
<CancelInstallationModal />
<ResetClusterModal />
<DiscoveryImageModal />
</ClusterDefaultConfigurationProvider>
</ModalDialogsContextProvider>
</SentryErrorMonitorContextProvider>
</OpenshiftVersionsContextProvider>
</AlertsContextProvider>
<NewFeatureSupportLevelProvider
loadingUi={<LoadingCard />}
cluster={cluster}
cpuArchitecture={infraEnv.cpuArchitecture as CpuArchitecture}
openshiftVersion={cluster.openshiftVersion}
platformType={cluster.platform?.type}
>
{content}
</NewFeatureSupportLevelProvider>
{isOutdatedClusterData && <ClusterPollingErrorModal />}
<CancelInstallationModal />
<ResetClusterModal />
<DiscoveryImageModal />
</ClusterDefaultConfigurationProvider>
</ModalDialogsContextProvider>
</SentryErrorMonitorContextProvider>
</OpenshiftVersionsContextProvider>
</AlertsContextProvider>
</HistoryRouter>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const ClusterWizardFooter = ({
const { alerts } = useAlerts();
const navigate = useNavigate();

const handleCancel = React.useCallback(() => navigate('..'), [navigate]);
const handleCancel = React.useCallback(() => navigate('/cluster-list'), [navigate]);

const alertsSection = alerts.length ? <Alerts /> : undefined;

Expand Down

0 comments on commit 9539e88

Please sign in to comment.