import React, { useCallback, useEffect, useState } from "react"; import { Stack, StackItem, TextContent, Text, Panel, PanelMain, PanelHeader, List, OrderType, ListItem, Icon, Alert, Button, AlertActionLink, } from "@patternfly/react-core"; import { chart_color_blue_300 as blueColor } from "@patternfly/react-tokens/dist/esm/chart_color_blue_300"; import { ClusterIcon, PlusCircleIcon } from "@patternfly/react-icons"; import { SourcesTable } from "#/migration-wizard/steps/connect/sources-table/SourcesTable"; import { useDiscoverySources } from "#/migration-wizard/contexts/discovery-sources/Context"; import { DiscoverySourceSetupModal } from "./sources-table/empty-state/DiscoverySourceSetupModal"; import { Source } from "@migration-planner-ui/api-client/models"; import { UploadInventoryAction } from "./sources-table/actions/UploadInventoryAction"; export const ConnectStep: React.FC = () => { const discoverySourcesContext = useDiscoverySources(); const [ shouldShowDiscoverySourceSetupModal, setShouldShowDiscoverySetupModal, ] = useState(false); const toggleDiscoverySourceSetupModal = useCallback((): void => { setShouldShowDiscoverySetupModal((lastState) => !lastState); }, []); const hasSources = discoverySourcesContext.sources && discoverySourcesContext.sources.length > 0; const [firstSource, ..._otherSources] = discoverySourcesContext.sources ?? []; const [sourceSelected,setSourceSelected] = React.useState(); useEffect(() => { if (discoverySourcesContext.sourceSelected) { const foundSource = discoverySourcesContext.sources.find( (source) => source.id === discoverySourcesContext.sourceSelected?.id ); if (foundSource) { setSourceSelected(foundSource); } else { if (firstSource) { setSourceSelected(firstSource); } else { setSourceSelected(undefined); } } } }, [discoverySourcesContext.sourceSelected, discoverySourcesContext.sources, firstSource]); return ( Connect your VMware environment Follow these steps to connect your environment and start the discovery process To add a new environment download and import a discovery OVA file to your VMware environment. A link will appear below once the VM is running. Use this link to enter credentials and connect your environment. When the connection is established, you will be able to proceed and see the discovery report. Environment {hasSources && ( )} {shouldShowDiscoverySourceSetupModal && ( { const form = event.currentTarget; const environmentName = form["discoveryEnvironmentName"].value as string; const sshKey = form["discoverySourceSshKey"].value as string; await discoverySourcesContext.downloadSource(environmentName,sshKey); toggleDiscoverySourceSetupModal(); await discoverySourcesContext.listSources(); }} /> )} {discoverySourcesContext.isDownloadingSource && ( The OVA image is downloading )} {discoverySourcesContext.errorDownloadingSource && ( {discoverySourcesContext.errorDownloadingSource.message} )} {sourceSelected?.agent && sourceSelected?.agent.status === "waiting-for-credentials" && ( {sourceSelected?.agent.credentialUrl} } > Click the link below to connect the Discovery Source to your VMware environment. )} {!sourceSelected?.agent && sourceSelected?.name !== "Example" && ( The selected environment is not connected, if you have a discovery file click the link below to upload it. )} ); }; ConnectStep.displayName = "ConnectStep";