From ee771dfa050866a0c3dcbb47c76e014a3cd7fdba Mon Sep 17 00:00:00 2001 From: Montse Ortega Date: Tue, 24 Dec 2024 10:26:10 +0100 Subject: [PATCH] Defining custom fotter for the wizard Signed-off-by: Montse Ortega --- .../src/migration-wizard/MigrationWizard.tsx | 109 +++++++++++++++--- 1 file changed, 94 insertions(+), 15 deletions(-) diff --git a/apps/demo/src/migration-wizard/MigrationWizard.tsx b/apps/demo/src/migration-wizard/MigrationWizard.tsx index 9d00b94..448f424 100644 --- a/apps/demo/src/migration-wizard/MigrationWizard.tsx +++ b/apps/demo/src/migration-wizard/MigrationWizard.tsx @@ -1,5 +1,11 @@ import React from "react"; -import { Wizard, WizardStep } from "@patternfly/react-core"; +import { + Button, + useWizardContext, + Wizard, + WizardFooterWrapper, + WizardStep, +} from "@patternfly/react-core"; import { ConnectStep } from "./steps/connect/ConnectStep"; import { DiscoveryStep } from "./steps/discovery/DiscoveryStep"; import { useComputedHeightFromPageHeader } from "./hooks/UseComputedHeightFromPageHeader"; @@ -7,42 +13,115 @@ import { useDiscoverySources } from "./contexts/discovery-sources/Context"; import { PrepareMigrationStep } from "./steps/prepare-migration/PrepareMigrationStep"; const openAssistedInstaller = (): void => { - window.open("https://console.dev.redhat.com/openshift/assisted-installer/clusters/~new?source=assisted_migration", "_blank"); + window.open( + "https://console.dev.redhat.com/openshift/assisted-installer/clusters/~new?source=assisted_migration", + "_blank" + ); +}; + +type CustomWizardFooterPropType = { + isCancelHidden?: boolean; + isNextDisabled?: boolean; + isBackDisabled?: boolean; + nextButtonText?: string; + onNext?: () => void; +}; + +export const CustomWizardFooter: React.FC = ({ + isCancelHidden, + isBackDisabled, + isNextDisabled, + nextButtonText, + onNext, +}): JSX.Element => { + const { goToNextStep, goToPrevStep, goToStepById } = useWizardContext(); + return ( + <> + + + + {!isCancelHidden && ( + + )} + + + ); }; export const MigrationWizard: React.FC = () => { const computedHeight = useComputedHeightFromPageHeader(); const discoverSourcesContext = useDiscoverySources(); - const isDiscoverySourceUpToDate = discoverSourcesContext.agentSelected?.status === "up-to-date"; - + const isDiscoverySourceUpToDate = + discoverSourcesContext.agentSelected?.status === "up-to-date"; + return ( + } > } + isDisabled={ + discoverSourcesContext.agentSelected?.status !== "up-to-date" || + discoverSourcesContext.sourceSelected === null + } > + } + isDisabled={ + discoverSourcesContext.agentSelected?.status !== "up-to-date" || + discoverSourcesContext.sourceSelected === null + } >