fix(ui): entity details pages are not loading correctly (#15567)

* fix(ui): entity details pages are not loading correctly

* fix tests
This commit is contained in:
Chirag Madlani 2024-03-14 20:38:18 +05:30 committed by GitHub
parent 957e087937
commit bbdacc695b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 12 deletions

View File

@ -18,8 +18,8 @@ import { useTranslation } from 'react-i18next';
import { Redirect, Route, Switch } from 'react-router-dom';
import { ROUTES } from '../../constants/constants';
import SignUpPage from '../../pages/SignUp/SignUpPage';
import applicationRoutesClass from '../../utils/ApplicationRoutesClassBase';
import Appbar from '../AppBar/Appbar';
import AuthenticatedAppRouter from '../AppRouter/AuthenticatedAppRouter';
import { useAuthContext } from '../Auth/AuthProviders/AuthProvider';
import LeftSidebar from '../MyData/LeftSidebar/LeftSidebar.component';
import './app-container.less';
@ -28,6 +28,7 @@ const AppContainer = () => {
const { i18n } = useTranslation();
const { Header, Sider, Content } = Layout;
const { currentUser } = useAuthContext();
const AuthenticatedRouter = applicationRoutesClass.getRouteElements();
const isDirectionRTL = useMemo(() => i18n.dir() === 'rtl', [i18n]);
@ -51,7 +52,7 @@ const AppContainer = () => {
</Header>
<Layout>
<Content className="main-content">
<AuthenticatedAppRouter />
<AuthenticatedRouter />
</Content>
</Layout>
</Layout>

View File

@ -15,14 +15,11 @@ import { Redirect, Route, Switch, useParams } from 'react-router-dom';
import { ROUTES } from '../../constants/constants';
import { EntityType } from '../../enums/entity.enum';
import EntityVersionPage from '../../pages/EntityVersionPage/EntityVersionPage.component';
import applicationRoutesClass from '../../utils/ApplicationRoutesClassBase';
import entityUtilClassBase from '../../utils/EntityUtilClassBase';
const EntityRouter = () => {
const { entityType } = useParams<{ entityType: EntityType }>();
const RouteElements = applicationRoutesClass.getRouteElements();
const Component = useMemo(
() => entityUtilClassBase.getEntityDetailComponent(entityType),
[entityType]
@ -30,7 +27,6 @@ const EntityRouter = () => {
return (
<Switch>
{RouteElements && <RouteElements />}
<Route
exact
component={EntityVersionPage}

View File

@ -11,18 +11,19 @@
* limitations under the License.
*/
import { FC } from 'react';
import AuthenticatedAppRouter from '../components/AppRouter/AuthenticatedAppRouter';
import { ApplicationRoutesClassBase } from './ApplicationRoutesClassBase';
describe('ApplicationRoutesClassCollate', () => {
describe('ApplicationRoutesClassBase', () => {
let applicationRoutesClassBase: ApplicationRoutesClassBase;
beforeEach(() => {
applicationRoutesClassBase = new ApplicationRoutesClassBase();
});
it('should return CollateRouter from getRouteElements', () => {
const result: FC | null = applicationRoutesClassBase.getRouteElements();
it('should return AuthenticatedAppRouter from getRouteElements', () => {
const result: FC = applicationRoutesClassBase.getRouteElements();
expect(result).toBeNull();
expect(result).toBe(AuthenticatedAppRouter);
});
});

View File

@ -12,10 +12,11 @@
*/
import { FC } from 'react';
import AuthenticatedAppRouter from '../components/AppRouter/AuthenticatedAppRouter';
class ApplicationRoutesClassBase {
public getRouteElements(): FC | null {
return null;
public getRouteElements(): FC {
return AuthenticatedAppRouter;
}
}