Router: Replace landing with catch-all route

This also mitigates the issue where clicking the image-builder nav link
would redirect you to `image-builder/image-builder` if image-builder was
already opened. And `/` didn't catch that path.
This commit is contained in:
Sanne Raymaekers 2021-11-30 15:25:28 +01:00 committed by jkozol
parent 4d987eb05e
commit 6567323ef6
3 changed files with 6 additions and 7 deletions

View file

@ -117,7 +117,7 @@ const CreateImageWizard = () => {
})();
}, []);
return user ? <ImageCreator
onClose={ () => navigate('/landing') }
onClose={ () => navigate('/') }
onSubmit={ ({ values, setIsSaving }) => {
setIsSaving(() => true);
const requests = onSave(values);
@ -129,7 +129,7 @@ const CreateImageWizard = () => {
}, true));
})))
.then(() => {
navigate('/landing');
navigate('/');
dispatch(addNotification({
variant: 'success',
title: 'Your image is being created',

View file

@ -1,5 +1,5 @@
import React, { lazy } from 'react';
import { Route, Routes, Navigate } from 'react-router-dom';
import { Route, Routes } from 'react-router-dom';
const LandingPage = lazy(() => import('./Components/LandingPage/LandingPage'));
const CreateImageWizard = lazy(() => import('./Components/CreateImageWizard/CreateImageWizard'));
@ -7,9 +7,8 @@ const CreateImageWizard = lazy(() => import('./Components/CreateImageWizard/Crea
export const Router = () => {
return (
<Routes>
<Route path='/landing/*' element={ <LandingPage /> } />
<Route path='/imagewizard/*' element={ <CreateImageWizard /> } />
<Route path='/' element={ <Navigate replace to='/landing' /> } />
<Route path='*' element={ <LandingPage /> } />
</Routes>
);
};

View file

@ -23,7 +23,7 @@ function verifyButtons() {
function verifyCancelButton(cancel, history) {
cancel.click();
expect(history.location.pathname).toBe('/landing');
expect(history.location.pathname).toBe('/');
}
// packages
@ -860,7 +860,7 @@ describe('Click through all steps', () => {
await expect(composeImage).toHaveBeenCalledTimes(3);
// returns back to the landing page
await waitFor(() => expect(history.location.pathname).toBe('/landing'));
await waitFor(() => expect(history.location.pathname).toBe('/'));
expect(store.getStore().getState().composes.allIds).toEqual(ids);
});