File tree 7 files changed +50
-8
lines changed
ra-ui-materialui/src/layout
7 files changed +50
-8
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
17
17
CustomRoutes ,
18
18
CatchAllComponent ,
19
19
LayoutComponent ,
20
+ LoadingComponent ,
20
21
CoreLayoutProps ,
21
22
ResourceProps ,
22
23
RenderResourcesFunction ,
@@ -28,7 +29,7 @@ export interface AdminRouterProps extends CoreLayoutProps {
28
29
catchAll : CatchAllComponent ;
29
30
children ?: AdminChildren ;
30
31
customRoutes ?: CustomRoutes ;
31
- loading : ComponentType ;
32
+ loading : LoadingComponent ;
32
33
ready ?: ComponentType ;
33
34
}
34
35
@@ -101,7 +102,7 @@ const CoreAdminRouter: FunctionComponent<AdminRouterProps> = props => {
101
102
children,
102
103
customRoutes,
103
104
dashboard,
104
- loading,
105
+ loading : LoadingPage ,
105
106
logout,
106
107
menu,
107
108
ready,
@@ -121,7 +122,13 @@ const CoreAdminRouter: FunctionComponent<AdminRouterProps> = props => {
121
122
( ! computedChildren || computedChildren . length === 0 )
122
123
) {
123
124
if ( oneSecondHasPassed ) {
124
- return < Route path = "/" key = "loading" component = { loading } /> ;
125
+ return (
126
+ < Route
127
+ path = "/"
128
+ key = "loading"
129
+ render = { ( ) => < LoadingPage theme = { theme } /> }
130
+ />
131
+ ) ;
125
132
} else {
126
133
return null ;
127
134
}
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
CatchAllComponent ,
14
14
CustomRoutes ,
15
15
DashboardComponent ,
16
+ LoadingComponent ,
16
17
} from '../types' ;
17
18
18
19
export type ChildrenFunction = ( ) => ComponentType [ ] ;
@@ -27,7 +28,7 @@ export interface AdminUIProps {
27
28
customRoutes ?: CustomRoutes ;
28
29
dashboard ?: DashboardComponent ;
29
30
layout ?: LayoutComponent ;
30
- loading ?: ComponentType ;
31
+ loading ?: LoadingComponent ;
31
32
loginPage ?: LoginComponent | boolean ;
32
33
logout ?: ComponentType ;
33
34
menu ?: ComponentType ;
Original file line number Diff line number Diff line change @@ -409,6 +409,11 @@ export interface CoreLayoutProps {
409
409
}
410
410
411
411
export type LayoutComponent = ComponentType < CoreLayoutProps > ;
412
+ export type LoadingComponent = ComponentType < {
413
+ theme ?: ThemeOptions ;
414
+ loadingPrimary ?: string ;
415
+ loadingSecondary ?: string ;
416
+ } > ;
412
417
413
418
export interface ResourceComponentInjectedProps {
414
419
basePath ?: string ;
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import PropTypes from 'prop-types' ;
3
+ import { ThemeProvider } from '@material-ui/styles' ;
4
+ import { createMuiTheme } from '@material-ui/core/styles' ;
5
+ import Loading from './Loading' ;
6
+
7
+ const LoadingPage = ( { theme, ...props } ) => (
8
+ < ThemeProvider theme = { theme } >
9
+ < Loading { ...props } />
10
+ </ ThemeProvider >
11
+ ) ;
12
+
13
+ LoadingPage . propTypes = {
14
+ theme : PropTypes . object ,
15
+ classes : PropTypes . object ,
16
+ className : PropTypes . string ,
17
+ loadingPrimary : PropTypes . string ,
18
+ loadingSecondary : PropTypes . string ,
19
+ } ;
20
+
21
+ LoadingPage . defaultProps = {
22
+ theme : createMuiTheme ( { } ) ,
23
+ loadingPrimary : 'ra.page.loading' ,
24
+ loadingSecondary : 'ra.message.loading' ,
25
+ } ;
26
+
27
+ export default LoadingPage ;
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import Error, { ErrorProps } from './Error';
8
8
import HideOnScroll , { HideOnScrollProps } from './HideOnScroll' ;
9
9
import Layout , { LayoutProps } from './Layout' ;
10
10
import Loading from './Loading' ;
11
+ import LoadingPage from './LoadingPage' ;
11
12
import LinearProgress from './LinearProgress' ;
12
13
import LoadingIndicator from './LoadingIndicator' ;
13
14
import Menu , { MenuProps } from './Menu' ;
@@ -32,6 +33,7 @@ export {
32
33
HideOnScroll ,
33
34
Layout ,
34
35
Loading ,
36
+ LoadingPage ,
35
37
LinearProgress ,
36
38
LoadingIndicator ,
37
39
Menu ,
Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
import { FC } from 'react' ;
3
3
import { CoreAdminRouter , AdminRouterProps } from 'ra-core' ;
4
- import { Loading } from 'ra-ui-materialui' ;
4
+ import { LoadingPage } from 'ra-ui-materialui' ;
5
5
6
6
const AdminRouter : FC < AdminRouterProps > = props => (
7
7
< CoreAdminRouter { ...props } />
8
8
) ;
9
9
10
10
AdminRouter . defaultProps = {
11
- loading : Loading ,
11
+ loading : LoadingPage ,
12
12
} ;
13
13
14
14
export default AdminRouter ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { FC } from 'react';
3
3
import { CoreAdminUI , AdminUIProps } from 'ra-core' ;
4
4
import {
5
5
Layout as DefaultLayout ,
6
- Loading ,
6
+ LoadingPage ,
7
7
Login ,
8
8
Logout ,
9
9
NotFound ,
@@ -14,7 +14,7 @@ const AdminUI: FC<AdminUIProps> = props => <CoreAdminUI {...props} />;
14
14
AdminUI . defaultProps = {
15
15
layout : DefaultLayout ,
16
16
catchAll : NotFound ,
17
- loading : Loading ,
17
+ loading : LoadingPage ,
18
18
loginPage : Login ,
19
19
logout : Logout ,
20
20
} ;
You can’t perform that action at this time.
0 commit comments