-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathApp.js
executable file
·66 lines (56 loc) · 2.02 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React from 'react';
import { ApiHubAdmin, readApiHubPreference } from 'layer7-apihub';
import { Route } from 'react-router-dom';
import {
LoginPage,
ResetPasswordPage,
NewPasswordPage,
AccountSetupPage,
SignUpPage,
SAMLLoginConfirmPage,
} from './authentication';
import { Layout, HomePage } from './layout';
import { themeReducer } from './theme';
import { i18nProvider } from './i18n/i18nProvider';
import { TestPage } from './TestPage';
const App = () => {
const { APIHUB_URL, TENANT_NAME, ORIGIN_HUB_NAME } = global.APIHUB_CONFIG;
if (!ORIGIN_HUB_NAME) {
throw new Error(
'Please provide a value for the ORIGIN_HUB_NAME parameter in your configuration file'
);
}
const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)')
.matches;
const themeModePreference = readApiHubPreference(
'themeMode',
prefersDarkMode ? 'dark' : 'light'
);
const initialState = {
theme: themeModePreference,
};
const defaultLocaleFromPreferences = readApiHubPreference('locale');
return (
<ApiHubAdmin
// ApiHub Settings
url={APIHUB_URL} // Will be guessed by ApiHubAdmin if not defined
tenantName={TENANT_NAME} // Will be guessed by ApiHubAdmin if not defined
originHubName={ORIGIN_HUB_NAME}
// Custom Pages and Layout
dashboard={HomePage}
layout={Layout}
loginPage={LoginPage}
resetPasswordPage={ResetPasswordPage}
newPasswordPage={NewPasswordPage}
accountSetupPage={AccountSetupPage}
signUpPage={SignUpPage}
samlLoginConfirmPage={SAMLLoginConfirmPage}
// React Admin Settings
customReducers={{ theme: themeReducer }}
i18nProvider={i18nProvider(defaultLocaleFromPreferences)}
initialState={initialState}
customRoutes={[<Route path="/test" component={TestPage} />]}
/>
);
};
export default App;