-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.tsx
108 lines (100 loc) · 4.27 KB
/
index.tsx
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import * as React from "react";
import * as ReactDOM from "react-dom";
import buildStore from "./store";
import { Provider } from "react-redux";
import { Router, Route, browserHistory } from "react-router";
import ContextProvider from "./components/ContextProvider";
import { TOSContextProvider } from "./components/TOSContext";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import CatalogPage from "./components/CatalogPage";
import CustomListPage from "./components/CustomListPage";
import LanePage from "./components/LanePage";
import DashboardPage from "./components/DashboardPage";
import QuicksightDashboardPage from "./components/QuicksightDashboardPage";
import ConfigPage from "./components/ConfigPage";
import AccountPage from "./components/AccountPage";
import SetupPage from "./components/SetupPage";
import ManagePatrons from "./components/ManagePatrons";
import TroubleshootingPage from "./components/TroubleshootingPage";
import { ConfigurationSettings } from "./interfaces";
import { defaultFeatureFlags } from "./utils/featureFlags";
/** The main admin interface application. Create an instance of this class
to render the app and set up routing. */
class CirculationAdmin {
constructor(config: ConfigurationSettings) {
const div = document.createElement("div");
div.id = "opds-catalog";
div.className = "palace";
document.getElementsByTagName("body")[0].appendChild(div);
const catalogEditorPath =
"/admin/web(/collection/:collectionUrl)(/book/:bookUrl)(/tab/:tab)";
const customListPagePath =
"/admin/web/lists(/:library)(/:editOrCreate)(/:identifier)";
const lanePagePath =
"/admin/web/lanes(/:library)(/:editOrCreate)(/:identifier)";
const quicksightPagePath = "/admin/web/quicksight";
const queryClient = new QueryClient();
const store = buildStore();
config.featureFlags = { ...defaultFeatureFlags, ...config.featureFlags };
config.quicksightPagePath = quicksightPagePath;
const appElement = "opds-catalog";
const app = config.settingUp ? (
<Provider store={store}>
<ContextProvider {...config} store={store}>
<SetupPage />
</ContextProvider>
</Provider>
) : (
<Provider store={store}>
<ContextProvider {...config} store={store}>
<TOSContextProvider
value={...[config.tos_link_text, config.tos_link_href]}
>
<QueryClientProvider client={queryClient}>
<Router history={browserHistory}>
<Route path={catalogEditorPath} component={CatalogPage} />
<Route path={customListPagePath} component={CustomListPage} />
<Route path={lanePagePath} component={LanePage} />
<Route
path="/admin/web/dashboard(/:library)"
component={DashboardPage}
/>
<Route
path={quicksightPagePath}
component={QuicksightDashboardPage}
/>
<Route
path="/admin/web/config(/:tab)(/:editOrCreate)(/:identifier)"
component={ConfigPage}
/>
<Route path="/admin/web/account" component={AccountPage} />
<Route
path="/admin/web/patrons/:library(/:tab)"
component={ManagePatrons}
/>
<Route
path="/admin/web/troubleshooting(/:tab)(/:subtab)"
component={TroubleshootingPage}
/>
</Router>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
</TOSContextProvider>
</ContextProvider>
</Provider>
);
// `react-axe` should only run in development and testing mode.
// Running this is resource intensive and should only be used to test
// for accessibility and not during active development.
if (process.env.TEST_AXE === "true") {
import("react-axe").then((axe) => {
axe(React, ReactDOM, 1000);
ReactDOM.render(app, document.getElementById(appElement));
});
} else {
ReactDOM.render(app, document.getElementById(appElement));
}
}
}
export = CirculationAdmin;