|
1 |
| -import React from 'react'; |
| 1 | +import React, { lazy, Suspense } from 'react'; |
2 | 2 | import { Route, Switch, Redirect } from 'react-router-dom';
|
3 | 3 | import { getUrl } from '../util/browser/BrowserProvider';
|
4 | 4 |
|
| 5 | +import { BusyIndicator } from '@ui5/webcomponents-react/lib/BusyIndicator'; |
5 | 6 | import RouteWithAuthorizationRestriction from '../auth/RouteWithAuthorizationRestriction';
|
6 |
| -import TodoList from '../pages/Todo/List/TodoList'; |
7 |
| -import TodoEdit from '../pages/Todo/Edit/TodoEdit'; |
8 |
| -import NotFound from '../pages/Fallback/NotFound'; |
9 |
| -import Buggy from '../pages/Fallback/Buggy'; |
| 7 | + |
| 8 | +const TodoList = lazy(() => import('../pages/Todo/List/TodoList')); |
| 9 | +const TodoEdit = lazy(() => import('../pages/Todo/Edit/TodoEdit')); |
| 10 | +const NotFound = lazy(() => import('../pages/Fallback/NotFound')); |
| 11 | +const Buggy = lazy(() => import('../pages/Fallback/Buggy')); |
10 | 12 |
|
11 | 13 | const Routes = () => {
|
12 | 14 | return (
|
13 |
| - <Switch> |
14 |
| - <Redirect path={getUrl('HOME')} exact to={getUrl('TODO_LIST')} /> |
15 |
| - <RouteWithAuthorizationRestriction allowedAuthorities={['canAccessTodoListPage']} authorityKey="permissions" path={getUrl('TODO_LIST')} component={TodoList} /> |
16 |
| - <RouteWithAuthorizationRestriction allowedAuthorities={['canAccessTodoEditPage']} authorityKey="permissions" path={getUrl('TODO_EDIT')} component={TodoEdit} /> |
17 |
| - <Route path={getUrl('BUGGY')} exact component={Buggy} /> |
18 |
| - <Route path={getUrl('NOT_FOUND')} exact component={NotFound} /> |
19 |
| - <Route path={getUrl('ANY')} component={NotFound} /> |
20 |
| - </Switch> |
| 15 | + <Suspense fallback={<BusyIndicator active />}> |
| 16 | + <Switch> |
| 17 | + <Redirect path={getUrl('HOME')} exact to={getUrl('TODO_LIST')} /> |
| 18 | + <RouteWithAuthorizationRestriction allowedAuthorities={['canAccessTodoListPage']} authorityKey="permissions" path={getUrl('TODO_LIST')} component={TodoList} /> |
| 19 | + <RouteWithAuthorizationRestriction allowedAuthorities={['canAccessTodoEditPage']} authorityKey="permissions" path={getUrl('TODO_EDIT')} component={TodoEdit} /> |
| 20 | + <Route path={getUrl('BUGGY')} exact component={Buggy} /> |
| 21 | + <Route path={getUrl('NOT_FOUND')} exact component={NotFound} /> |
| 22 | + <Route path={getUrl('ANY')} component={NotFound} /> |
| 23 | + </Switch> |
| 24 | + </Suspense> |
21 | 25 | );
|
22 | 26 | };
|
23 | 27 |
|
|
0 commit comments