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

View File

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

View File

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

View File

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