src/App.js: Remove obsolotete APP_NAVIGATION listener
v6 of react-router-dom is now supported everywhere, and leaving the event listener can cause navigation bugs. See gkarat/ocp-advisor-frontend#101 as an example.
This commit is contained in:
parent
136a9ec0a2
commit
7df6ff7df3
3 changed files with 2 additions and 37 deletions
10
src/App.js
10
src/App.js
|
|
@ -3,25 +3,17 @@ import React, { useEffect } from 'react';
|
|||
import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome';
|
||||
import NotificationsPortal from '@redhat-cloud-services/frontend-components-notifications/NotificationPortal';
|
||||
import { useStore } from 'react-redux';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import '@patternfly/patternfly/patternfly-addons.css';
|
||||
|
||||
import { Router } from './Router';
|
||||
import { resolveRelPath } from './Utilities/path';
|
||||
|
||||
const App = (props) => {
|
||||
const navigate = useNavigate();
|
||||
const store = useStore();
|
||||
|
||||
const { hideGlobalFilter, on, updateDocumentTitle } = useChrome();
|
||||
const { hideGlobalFilter, updateDocumentTitle } = useChrome();
|
||||
|
||||
useEffect(() => {
|
||||
updateDocumentTitle('Image Builder | Red Hat Insights');
|
||||
hideGlobalFilter();
|
||||
const unregister = on('APP_NAVIGATION', () => navigate(resolveRelPath('')));
|
||||
return () => {
|
||||
unregister();
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,19 +1,5 @@
|
|||
function getBaseName(pathname) {
|
||||
let release = '/';
|
||||
const pathName = pathname.split('/');
|
||||
|
||||
pathName.shift();
|
||||
|
||||
if (pathName[0] === 'beta') {
|
||||
pathName.shift();
|
||||
release = `/beta/`;
|
||||
}
|
||||
|
||||
return `${release}`;
|
||||
}
|
||||
|
||||
function resolveRelPath(path = '') {
|
||||
return `/insights/image-builder${path.length > 0 ? `/${path}` : ''}`;
|
||||
}
|
||||
|
||||
export { getBaseName, resolveRelPath };
|
||||
export { resolveRelPath };
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
import { getBaseName } from './Utilities/path';
|
||||
|
||||
describe('Utilities/getBaseName', () => {
|
||||
it('should find the right base name on Stable ', () => {
|
||||
expect(getBaseName('/')).toEqual('/');
|
||||
expect(getBaseName('/rhcs/bar/bar/baz')).toEqual('/');
|
||||
});
|
||||
|
||||
it('should find the right base name on Beta ', () => {
|
||||
expect(getBaseName('/beta')).toEqual('/beta/');
|
||||
expect(getBaseName('/beta/foo/bar/baz')).toEqual('/beta/');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue