-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathApp.js
More file actions
73 lines (63 loc) · 2.29 KB
/
App.js
File metadata and controls
73 lines (63 loc) · 2.29 KB
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
67
68
69
70
71
72
73
// Copyright © 2025 Broadcom Inc. and its subsidiaries. All Rights Reserved.
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 { i18nProvider } from './i18n/i18nProvider';
import { useTheme } from './theme';
import { TestPage } from './TestPage';
import { useAppConfig } from './contexts/ConfigContext';
const App = () => {
const { APIHUB_URL, TENANT_NAME, ORIGIN_HUB_NAME } = useAppConfig();
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');
const { theme } = useTheme();
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}
theme={theme}
resetPasswordPage={<ResetPasswordPage />}
newPasswordPage={<NewPasswordPage />}
accountSetupPage={<AccountSetupPage />}
signUpPage={<SignUpPage />}
samlLoginConfirmPage={<SAMLLoginConfirmPage />}
// React Admin Settings
i18nProvider={i18nProvider(defaultLocaleFromPreferences)}
initialState={initialState}
customRoutes={[<Route path="/test" element={<TestPage />} />]}
customRoutesNoLayout={[
<Route path="/test2" element={<TestPage />} />,
]}
/>
);
};
export default App;