diff --git a/dashboard/src/main/home/onboarding/Routes.tsx b/dashboard/src/main/home/onboarding/Routes.tsx index 0d2924eab1..3b5d4aa06a 100644 --- a/dashboard/src/main/home/onboarding/Routes.tsx +++ b/dashboard/src/main/home/onboarding/Routes.tsx @@ -1,5 +1,6 @@ -import React from "react"; +import React, { useContext } from "react"; import { Route, Switch } from "react-router"; +import { Context } from "shared/Context"; import PorterErrorBoundary from "shared/error_handling/PorterErrorBoundary"; import { OFState } from "./state"; import ConnectRegistry from "./steps/ConnectRegistry/ConnectRegistry"; @@ -7,6 +8,9 @@ import ConnectSource from "./steps/ConnectSource"; import ProvisionResources from "./steps/ProvisionResources/ProvisionResources"; export const Routes = () => { + const context = useContext(Context); + const { currentProject } = context; + return ( <> { tags={{ scope: "onboarding" }} > - + OFState.actions.nextStep("continue", data)} /> @@ -36,4 +40,4 @@ export const Routes = () => { ); }; -export default Routes; +export default Routes; \ No newline at end of file diff --git a/dashboard/src/main/home/onboarding/state/StepHandler.ts b/dashboard/src/main/home/onboarding/state/StepHandler.ts index 583bf9aa87..a7c906452d 100644 --- a/dashboard/src/main/home/onboarding/state/StepHandler.ts +++ b/dashboard/src/main/home/onboarding/state/StepHandler.ts @@ -41,7 +41,7 @@ const flow: FlowType = { initial: "connect_source", steps: { connect_source: { - url: "/onboarding/source", + url: "/onboarding/source/", on: { continue: "connect_registry", }, @@ -288,7 +288,7 @@ export const useSteps = (isParentLoading?: boolean) => { const snap = useSnapshot(StepHandler); const location = useLocation(); const { pushFiltered } = useRouting(); - const { setHasFinishedOnboarding } = useContext(Context); + const { setHasFinishedOnboarding, currentProject } = useContext(Context); useEffect(() => { if (isParentLoading) { @@ -298,6 +298,12 @@ export const useSteps = (isParentLoading?: boolean) => { StepHandler.actions.clearState(); setHasFinishedOnboarding(true); } - pushFiltered(snap.currentStep.url, ["tab"]); + if (currentProject && currentProject.id) { + pushFiltered(`${snap.currentStep.url}?project_id=${currentProject.id}`, ["tab"]); + } else { + pushFiltered(snap.currentStep.url, ["tab"]); + } + }, [location.pathname, snap.currentStep?.url, isParentLoading]); }; + diff --git a/dashboard/src/shared/Context.tsx b/dashboard/src/shared/Context.tsx index bf2d06a1f9..30d746d896 100644 --- a/dashboard/src/shared/Context.tsx +++ b/dashboard/src/shared/Context.tsx @@ -116,12 +116,12 @@ class ContextProvider extends Component { currentProject: null, setCurrentProject: (currentProject: ProjectType, callback?: any) => { if (currentProject) { - localStorage.setItem("currentProject", currentProject.id.toString()); + sessionStorage.setItem("currentProject", currentProject.id.toString()); pushQueryParams(this.props, { project_id: currentProject.id.toString(), }); } else { - localStorage.removeItem("currentProject"); + sessionStorage.removeItem("currentProject"); } this.setState({ currentProject }, () => { callback && callback(); @@ -216,4 +216,4 @@ class ContextProvider extends Component { } } -export { Context, ContextProvider, ContextConsumer }; +export { Context, ContextProvider, ContextConsumer }; \ No newline at end of file