1
1
import React from 'react' ;
2
- import {
3
- Admin as RaAdmin ,
4
- AdminProps as RaAdminProps ,
5
- Resource ,
6
- } from 'react-admin' ;
2
+ import { Admin as RaAdmin , AdminProps , Resource } from 'react-admin' ;
7
3
import localStorageDataProvider from 'ra-data-local-storage' ;
8
4
import { Create , Edit , List } from './builders' ;
9
5
import {
10
6
useResourcesConfiguration ,
11
7
ResourceConfigurationProvider ,
12
8
} from './ResourceConfiguration' ;
13
9
import { Layout , Ready } from './ui' ;
14
- import { Application } from './ApplicationsDashboard ' ;
10
+ import { useApplication } from './ApplicationContext ' ;
15
11
16
- export const Admin = ( { application, ...props } : AdminProps ) => {
12
+ export const Admin = ( props : Omit < AdminProps , 'dataProvider' > ) => {
13
+ const { application } = useApplication ( ) ;
14
+ if ( ! application ) {
15
+ return null ;
16
+ }
17
17
const dataProvider = localStorageDataProvider ( {
18
18
localStorageKey : `@@ra-no-code/${ application . name } /data` ,
19
19
} ) ;
@@ -22,12 +22,16 @@ export const Admin = ({ application, ...props }: AdminProps) => {
22
22
dataProvider = { dataProvider }
23
23
storageKey = { `@@ra-no-code/${ application . name } ` }
24
24
>
25
- < InnerAdmin { ...props } dataProvider = { dataProvider } />
25
+ < InnerAdmin
26
+ { ...props }
27
+ title = { application . name }
28
+ dataProvider = { dataProvider }
29
+ />
26
30
</ ResourceConfigurationProvider >
27
31
) ;
28
32
} ;
29
33
30
- const InnerAdmin = ( props : RaAdminProps ) => {
34
+ const InnerAdmin = ( props : AdminProps ) => {
31
35
const [ resources ] = useResourcesConfiguration ( ) ;
32
36
const hasResources = ! ! resources && Object . keys ( resources ) . length > 0 ;
33
37
return (
@@ -47,7 +51,3 @@ const InnerAdmin = (props: RaAdminProps) => {
47
51
</ RaAdmin >
48
52
) ;
49
53
} ;
50
-
51
- interface AdminProps extends Omit < RaAdminProps , 'dataProvider' > {
52
- application : Application ;
53
- }
0 commit comments