Skip to content

Commit f747a93

Browse files
committed
Make the frontend a module for customview
1 parent bb77939 commit f747a93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+279
-128
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ static_root
171171
node_modules
172172
static/js/ui.js*
173173
coverage
174+
frontend/dist
174175

175176
# local django configuration
176177
airone/settings.py

frontend/src/App.tsx

+3-23
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
1-
import { ThemeProvider } from "@mui/material/styles";
2-
import React, { FC } from "react";
1+
import React from "react";
32
import { createRoot } from "react-dom/client";
43

5-
import { AironeSnackbarProvider } from "AironeSnackbarProvider";
6-
import { AppRouter } from "AppRouter";
7-
import { CheckTermsService } from "CheckTermsService";
8-
import { ErrorHandler } from "ErrorHandler";
9-
import { theme } from "Theme";
10-
import "i18n/config";
11-
12-
const App: FC = () => {
13-
return (
14-
<ThemeProvider theme={theme}>
15-
<AironeSnackbarProvider>
16-
<ErrorHandler>
17-
<CheckTermsService>
18-
<AppRouter />
19-
</CheckTermsService>
20-
</ErrorHandler>
21-
</AironeSnackbarProvider>
22-
</ThemeProvider>
23-
);
24-
};
4+
import { AppBase } from "AppBase";
255

266
const container = document.getElementById("app");
277
if (container == null) {
288
throw new Error("failed to initializer React app.");
299
}
3010
const root = createRoot(container);
31-
root.render(<App />);
11+
root.render(<AppBase />);

frontend/src/AppBase.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { ThemeProvider } from "@mui/material/styles";
2+
import React, { FC } from "react";
3+
4+
import { AironeSnackbarProvider } from "AironeSnackbarProvider";
5+
import { CheckTermsService } from "CheckTermsService";
6+
import { ErrorHandler } from "ErrorHandler";
7+
import { theme } from "Theme";
8+
import { AppRouter } from "routes/AppRouter";
9+
import "i18n/config";
10+
11+
interface Props {
12+
customRoutes?: {
13+
path: string;
14+
element: React.ReactNode;
15+
}[];
16+
}
17+
18+
export const AppBase: FC<Props> = ({ customRoutes }) => {
19+
return (
20+
<ThemeProvider theme={theme}>
21+
<AironeSnackbarProvider>
22+
<ErrorHandler>
23+
<CheckTermsService>
24+
<AppRouter customRoutes={customRoutes} />
25+
</CheckTermsService>
26+
</ErrorHandler>
27+
</AironeSnackbarProvider>
28+
</ThemeProvider>
29+
);
30+
};

frontend/src/ErrorHandler.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
NonTermsServiceAgreement,
2323
} from "./services/Exceptions";
2424

25-
import { topPath } from "Routes";
25+
import { topPath } from "routes/Routes";
2626

2727
const ErrorDescription = styled(Box)(({ theme }) => ({
2828
marginTop: theme.spacing(2),

frontend/src/components/acl/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./ACLForm";
2+
export * from "./ACLHistoryList";

frontend/src/components/Header.tsx frontend/src/components/common/Header.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ import React, { FC, MouseEvent, useMemo, useState } from "react";
2323
import { Link } from "react-router-dom";
2424
import { useInterval } from "react-use";
2525

26-
import { useTranslation } from "../hooks/useTranslation";
26+
import { useTranslation } from "../../hooks/useTranslation";
2727

28+
import { SearchBox } from "components/common/SearchBox";
29+
import { useSimpleSearch } from "hooks/useSimpleSearch";
30+
import { aironeApiClient } from "repository/AironeApiClient";
2831
import {
2932
advancedSearchPath,
3033
entitiesPath,
@@ -36,10 +39,7 @@ import {
3639
triggersPath,
3740
userPath,
3841
usersPath,
39-
} from "Routes";
40-
import { SearchBox } from "components/common/SearchBox";
41-
import { useSimpleSearch } from "hooks/useSimpleSearch";
42-
import { aironeApiClient } from "repository/AironeApiClient";
42+
} from "routes/Routes";
4343
import {
4444
JobOperations,
4545
JobRefreshIntervalMilliSec,

frontend/src/components/common/PageHeader.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { styled } from "@mui/material/styles";
44
import React, { FC } from "react";
55
import { Link } from "react-router-dom";
66

7-
import { jobsPath } from "Routes";
7+
import { jobsPath } from "routes/Routes";
88

99
const Frame = styled(Box)({
1010
width: "100%",
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export * from "./AironeBreadcrumbs";
2+
export * from "./AironeModal";
3+
export * from "./AironeTableHeadCell";
4+
export * from "./AironeTableHeadRow";
5+
export * from "./AutocompleteWithAllSelector";
6+
export * from "./ClipboardCopyButton";
7+
export * from "./Confirmable";
8+
export * from "./FlexBox";
9+
export * from "./ImportForm";
10+
export * from "./Loading";
11+
export * from "./PageHeader";
12+
export * from "./PaginationFooter";
13+
export * from "./RateLimitedClickable";
14+
export * from "./SearchBox";
15+
export * from "./SubmitButton";

frontend/src/components/entity/EntityBreadcrumbs.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { Typography } from "@mui/material";
44
import React, { FC } from "react";
55
import { Link } from "react-router-dom";
66

7-
import { topPath, entitiesPath, entityEntriesPath } from "Routes";
87
import { AironeBreadcrumbs } from "components/common/AironeBreadcrumbs";
98
import { FlexBox } from "components/common/FlexBox";
9+
import { topPath, entitiesPath, entityEntriesPath } from "routes/Routes";
1010

1111
interface Props {
1212
entity?: EntityDetail;

frontend/src/components/entity/EntityControlMenu.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { Link, useNavigate } from "react-router-dom";
1212

1313
import { RateLimitedClickable } from "../common/RateLimitedClickable";
1414

15+
import { Confirmable } from "components/common/Confirmable";
16+
import { aironeApiClient } from "repository/AironeApiClient";
1517
import {
1618
aclPath,
1719
entityHistoryPath,
@@ -21,9 +23,7 @@ import {
2123
topPath,
2224
entityEntriesPath,
2325
aclHistoryPath,
24-
} from "Routes";
25-
import { Confirmable } from "components/common/Confirmable";
26-
import { aironeApiClient } from "repository/AironeApiClient";
26+
} from "routes/Routes";
2727

2828
type ExportFormatType = "YAML" | "CSV";
2929

frontend/src/components/entity/EntityList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { Link } from "react-router-dom";
66

77
import { EntityListCard } from "./EntityListCard";
88

9-
import { newEntityPath } from "Routes";
109
import { PaginationFooter } from "components/common/PaginationFooter";
1110
import { SearchBox } from "components/common/SearchBox";
11+
import { newEntityPath } from "routes/Routes";
1212
import { EntityList as ConstEntityList } from "services/Constants";
1313
import { normalizeToMatch } from "services/StringUtil";
1414

frontend/src/components/entity/EntityListCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import { Link } from "react-router-dom";
1515

1616
import { EntityControlMenu } from "./EntityControlMenu";
1717

18-
import { entityEntriesPath } from "Routes";
1918
import { ClipboardCopyButton } from "components/common/ClipboardCopyButton";
2019
import { EntryImportModal } from "components/entry/EntryImportModal";
20+
import { entityEntriesPath } from "routes/Routes";
2121

2222
const EntityNote = styled(Typography)(({ theme }) => ({
2323
color: theme.palette.text.secondary,

frontend/src/components/entity/entityForm/AttributeField.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { Link } from "react-router-dom";
2525
import { AttributeNoteModal } from "./AttributeNoteModal";
2626
import { Schema } from "./EntityFormSchema";
2727

28-
import { aclPath } from "Routes";
28+
import { aclPath } from "routes/Routes";
2929
import { AttributeTypes } from "services/Constants";
3030

3131
const StyledBox = styled(Box)(({ theme }) => ({
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// FIXME rethink export scope
2+
3+
export * from "./EntityBreadcrumbs";
4+
export * from "./EntityControlMenu";

frontend/src/components/entry/AttributeValue.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as React from "react";
1212
import { FC } from "react";
1313
import { Link } from "react-router-dom";
1414

15-
import { groupsPath, rolePath, entryDetailsPath } from "Routes";
15+
import { groupsPath, rolePath, entryDetailsPath } from "routes/Routes";
1616

1717
const StyledBox = styled(Box)(() => ({
1818
display: "flex",

frontend/src/components/entry/EntryBreadcrumbs.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { Typography } from "@mui/material";
44
import React, { FC } from "react";
55
import { Link } from "react-router-dom";
66

7+
import { AironeBreadcrumbs } from "components/common/AironeBreadcrumbs";
8+
import { FlexBox } from "components/common/FlexBox";
79
import {
810
topPath,
911
entitiesPath,
1012
entityEntriesPath,
1113
entryDetailsPath,
12-
} from "Routes";
13-
import { AironeBreadcrumbs } from "components/common/AironeBreadcrumbs";
14-
import { FlexBox } from "components/common/FlexBox";
14+
} from "routes/Routes";
1515

1616
interface Props {
1717
entry?: EntryRetrieve;

frontend/src/components/entry/EntryControlMenu.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { useSnackbar } from "notistack";
1111
import React, { FC } from "react";
1212
import { Link, useNavigate } from "react-router-dom";
1313

14+
import { Confirmable } from "components/common/Confirmable";
15+
import { aironeApiClient } from "repository/AironeApiClient";
1416
import {
1517
entryEditPath,
1618
aclPath,
@@ -20,9 +22,7 @@ import {
2022
topPath,
2123
entryDetailsPath,
2224
aclHistoryPath,
23-
} from "Routes";
24-
import { Confirmable } from "components/common/Confirmable";
25-
import { aironeApiClient } from "repository/AironeApiClient";
25+
} from "routes/Routes";
2626

2727
interface EntryControlProps {
2828
entityId: number;

frontend/src/components/entry/EntryHistoryList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import { useNavigate } from "react-router-dom";
1616

1717
import { AttributeValue } from "./AttributeValue";
1818

19-
import { showEntryHistoryPath, topPath } from "Routes";
2019
import { Confirmable } from "components/common/Confirmable";
2120
import { PaginationFooter } from "components/common/PaginationFooter";
2221
import { aironeApiClient } from "repository/AironeApiClient";
22+
import { showEntryHistoryPath, topPath } from "routes/Routes";
2323
import { EntryHistoryList as ConstEntryHistoryList } from "services/Constants";
2424
import { formatDateTime } from "services/DateUtil";
2525

frontend/src/components/entry/EntryList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { Link, useNavigate, useLocation } from "react-router-dom";
55

66
import { EntryListCard } from "./EntryListCard";
77

8-
import { newEntryPath } from "Routes";
98
import { Loading } from "components/common/Loading";
109
import { PaginationFooter } from "components/common/PaginationFooter";
1110
import { SearchBox } from "components/common/SearchBox";
1211
import { useAsyncWithThrow } from "hooks/useAsyncWithThrow";
1312
import { usePage } from "hooks/usePage";
1413
import { aironeApiClient } from "repository/AironeApiClient";
14+
import { newEntryPath } from "routes/Routes";
1515
import { EntryList as ConstEntryList } from "services/Constants";
1616
import { normalizeToMatch } from "services/StringUtil";
1717

frontend/src/components/entry/EntryListCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { styled } from "@mui/material/styles";
1212
import React, { FC, useState } from "react";
1313
import { Link } from "react-router-dom";
1414

15-
import { entryDetailsPath } from "Routes";
1615
import { ClipboardCopyButton } from "components/common/ClipboardCopyButton";
1716
import { EntryControlMenu } from "components/entry/EntryControlMenu";
17+
import { entryDetailsPath } from "routes/Routes";
1818

1919
const StyledCard = styled(Card)(({}) => ({
2020
height: "100%",

frontend/src/components/entry/EntryReferral.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { aironeApiClient } from "../../repository/AironeApiClient";
1818
import { EntryReferralList } from "../../services/Constants";
1919
import { normalizeToMatch } from "../../services/StringUtil";
2020

21-
import { entryDetailsPath } from "Routes";
2221
import { SearchBox } from "components/common/SearchBox";
22+
import { entryDetailsPath } from "routes/Routes";
2323

2424
const ReferralCount = styled(Typography)(({}) => ({
2525
fontSize: "16px",

frontend/src/components/entry/RestorableEntryList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import { useNavigate, useLocation } from "react-router-dom";
2424

2525
import { EntryAttributes } from "./EntryAttributes";
2626

27-
import { restoreEntryPath, topPath } from "Routes";
2827
import { Confirmable } from "components/common/Confirmable";
2928
import { Loading } from "components/common/Loading";
3029
import { PaginationFooter } from "components/common/PaginationFooter";
3130
import { SearchBox } from "components/common/SearchBox";
3231
import { useAsyncWithThrow } from "hooks/useAsyncWithThrow";
3332
import { usePage } from "hooks/usePage";
3433
import { aironeApiClient } from "repository/AironeApiClient";
34+
import { restoreEntryPath, topPath } from "routes/Routes";
3535
import { EntryList as ConstEntryList } from "services/Constants";
3636
import { formatDateTime } from "services/DateUtil";
3737
import { normalizeToMatch } from "services/StringUtil";

frontend/src/components/entry/SearchResults.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import { Link } from "react-router-dom";
2121

2222
import { SearchResultsTableHead } from "./SearchResultsTableHead";
2323

24-
import { entryDetailsPath } from "Routes";
2524
import { PaginationFooter } from "components/common/PaginationFooter";
2625
import { AttributeValue } from "components/entry/AttributeValue";
26+
import { entryDetailsPath } from "routes/Routes";
2727
import { AdvancedSerarchResultList } from "services/Constants";
2828
import { AttrsFilter } from "services/entry/AdvancedSearch";
2929

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// FIXME rethink export scope
2+
3+
export * from "./CopyForm";
4+
export * from "./EntryBreadcrumbs";
5+
export * from "./EntryControlMenu";
6+
export * from "./EntryImportModal";
7+
export * from "./EntryListCard";
8+
9+
export * from "./entryForm/EntryFormSchema";
10+
export * from "./entryForm/AttributeValueField";

frontend/src/components/group/GroupControlMenu.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { useSnackbar } from "notistack";
1111
import React, { FC, useCallback } from "react";
1212
import { Link, useNavigate } from "react-router-dom";
1313

14-
import { groupPath, groupsPath, topPath } from "Routes";
1514
import { Confirmable } from "components/common/Confirmable";
1615
import { aironeApiClient } from "repository/AironeApiClient";
16+
import { groupPath, groupsPath, topPath } from "routes/Routes";
1717

1818
interface Props {
1919
groupId: number;

frontend/src/components/group/GroupTreeItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Checkbox, IconButton, ListItem, Typography } from "@mui/material";
33
import React, { FC } from "react";
44
import { Link } from "react-router-dom";
55

6-
import { groupPath } from "../../Routes";
76
import { GroupTree } from "../../repository/AironeApiClient";
7+
import { groupPath } from "../../routes/Routes";
88
import { ServerContext } from "../../services/ServerContext";
99

1010
const CHILDREN_INDENT_WIDTH = 16;

frontend/src/components/group/GroupTreeRoot.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { styled } from "@mui/material/styles";
1010
import React, { FC } from "react";
1111
import { Link } from "react-router-dom";
1212

13-
import { groupPath } from "../../Routes";
1413
import { GroupTree } from "../../repository/AironeApiClient";
14+
import { groupPath } from "../../routes/Routes";
1515
import { ServerContext } from "../../services/ServerContext";
1616

1717
import { GroupTreeItem } from "./GroupTreeItem";

frontend/src/components/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from "./acl";
2+
export * from "./common";
3+
export * from "./entity";
4+
export * from "./entry";

frontend/src/components/job/JobList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { styled } from "@mui/material/styles";
1515
import React, { FC, useState } from "react";
1616
import { Link, useNavigate } from "react-router-dom";
1717

18-
import { entityEntriesPath } from "../../Routes";
1918
import { aironeApiClient } from "../../repository/AironeApiClient";
19+
import { entityEntriesPath } from "../../routes/Routes";
2020
import { JobOperations, JobStatuses } from "../../services/Constants";
2121
import { formatDateTime } from "../../services/DateUtil";
2222
import { jobOperationLabel, jobStatusLabel } from "../../services/JobUtil";

frontend/src/components/role/RoleList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { aironeApiClient } from "../../repository/AironeApiClient";
2525
import { Confirmable } from "../common/Confirmable";
2626
import { Loading } from "../common/Loading";
2727

28-
import { rolePath, rolesPath, topPath } from "Routes";
28+
import { rolePath, rolesPath, topPath } from "routes/Routes";
2929

3030
const StyledList = styled(List)(() => ({
3131
padding: "0",

0 commit comments

Comments
 (0)