Skip to content

Commit

Permalink
Make the frontend a module for customview
Browse files Browse the repository at this point in the history
  • Loading branch information
syucream committed Nov 2, 2024
1 parent bb77939 commit 72e1e9d
Show file tree
Hide file tree
Showing 73 changed files with 279 additions and 128 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ static_root
node_modules
static/js/ui.js*
coverage
frontend/dist

# local django configuration
airone/settings.py
Expand Down
26 changes: 3 additions & 23 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import { ThemeProvider } from "@mui/material/styles";
import React, { FC } from "react";
import React from "react";
import { createRoot } from "react-dom/client";

import { AironeSnackbarProvider } from "AironeSnackbarProvider";
import { AppRouter } from "AppRouter";
import { CheckTermsService } from "CheckTermsService";
import { ErrorHandler } from "ErrorHandler";
import { theme } from "Theme";
import "i18n/config";

const App: FC = () => {
return (
<ThemeProvider theme={theme}>
<AironeSnackbarProvider>
<ErrorHandler>
<CheckTermsService>
<AppRouter />
</CheckTermsService>
</ErrorHandler>
</AironeSnackbarProvider>
</ThemeProvider>
);
};
import { AppBase } from "AppBase";

const container = document.getElementById("app");
if (container == null) {
throw new Error("failed to initializer React app.");
}
const root = createRoot(container);
root.render(<App />);
root.render(<AppBase />);
30 changes: 30 additions & 0 deletions frontend/src/AppBase.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ThemeProvider } from "@mui/material/styles";
import React, { FC } from "react";

import { AironeSnackbarProvider } from "AironeSnackbarProvider";
import { CheckTermsService } from "CheckTermsService";
import { ErrorHandler } from "ErrorHandler";
import { theme } from "Theme";
import { AppRouter } from "routes/AppRouter";
import "i18n/config";

interface Props {
customRoutes?: {
path: string;
element: React.ReactNode;
}[];
}

export const AppBase: FC<Props> = ({ customRoutes }) => {
return (
<ThemeProvider theme={theme}>
<AironeSnackbarProvider>
<ErrorHandler>
<CheckTermsService>
<AppRouter customRoutes={customRoutes} />
</CheckTermsService>
</ErrorHandler>
</AironeSnackbarProvider>
</ThemeProvider>
);
};
2 changes: 1 addition & 1 deletion frontend/src/ErrorHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
NonTermsServiceAgreement,
} from "./services/Exceptions";

import { topPath } from "Routes";
import { topPath } from "routes/Routes";

const ErrorDescription = styled(Box)(({ theme }) => ({
marginTop: theme.spacing(2),
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/acl/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./ACLForm";
export * from "./ACLHistoryList";
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import React, { FC, MouseEvent, useMemo, useState } from "react";
import { Link } from "react-router-dom";
import { useInterval } from "react-use";

import { useTranslation } from "../hooks/useTranslation";
import { useTranslation } from "../../hooks/useTranslation";

import { SearchBox } from "components/common/SearchBox";
import { useSimpleSearch } from "hooks/useSimpleSearch";
import { aironeApiClient } from "repository/AironeApiClient";
import {
advancedSearchPath,
entitiesPath,
Expand All @@ -36,10 +39,7 @@ import {
triggersPath,
userPath,
usersPath,
} from "Routes";
import { SearchBox } from "components/common/SearchBox";
import { useSimpleSearch } from "hooks/useSimpleSearch";
import { aironeApiClient } from "repository/AironeApiClient";
} from "routes/Routes";
import {
JobOperations,
JobRefreshIntervalMilliSec,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/common/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { styled } from "@mui/material/styles";
import React, { FC } from "react";
import { Link } from "react-router-dom";

import { jobsPath } from "Routes";
import { jobsPath } from "routes/Routes";

const Frame = styled(Box)({
width: "100%",
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/components/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export * from "./AironeBreadcrumbs";
export * from "./AironeModal";
export * from "./AironeTableHeadCell";
export * from "./AironeTableHeadRow";
export * from "./AutocompleteWithAllSelector";
export * from "./ClipboardCopyButton";
export * from "./Confirmable";
export * from "./FlexBox";
export * from "./ImportForm";
export * from "./Loading";
export * from "./PageHeader";
export * from "./PaginationFooter";
export * from "./RateLimitedClickable";
export * from "./SearchBox";
export * from "./SubmitButton";
2 changes: 1 addition & 1 deletion frontend/src/components/entity/EntityBreadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Typography } from "@mui/material";
import React, { FC } from "react";
import { Link } from "react-router-dom";

import { topPath, entitiesPath, entityEntriesPath } from "Routes";
import { AironeBreadcrumbs } from "components/common/AironeBreadcrumbs";
import { FlexBox } from "components/common/FlexBox";
import { topPath, entitiesPath, entityEntriesPath } from "routes/Routes";

interface Props {
entity?: EntityDetail;
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/entity/EntityControlMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { Link, useNavigate } from "react-router-dom";

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

import { Confirmable } from "components/common/Confirmable";
import { aironeApiClient } from "repository/AironeApiClient";
import {
aclPath,
entityHistoryPath,
Expand All @@ -21,9 +23,7 @@ import {
topPath,
entityEntriesPath,
aclHistoryPath,
} from "Routes";
import { Confirmable } from "components/common/Confirmable";
import { aironeApiClient } from "repository/AironeApiClient";
} from "routes/Routes";

type ExportFormatType = "YAML" | "CSV";

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entity/EntityList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Link } from "react-router-dom";

import { EntityListCard } from "./EntityListCard";

import { newEntityPath } from "Routes";
import { PaginationFooter } from "components/common/PaginationFooter";
import { SearchBox } from "components/common/SearchBox";
import { newEntityPath } from "routes/Routes";
import { EntityList as ConstEntityList } from "services/Constants";
import { normalizeToMatch } from "services/StringUtil";

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entity/EntityListCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { Link } from "react-router-dom";

import { EntityControlMenu } from "./EntityControlMenu";

import { entityEntriesPath } from "Routes";
import { ClipboardCopyButton } from "components/common/ClipboardCopyButton";
import { EntryImportModal } from "components/entry/EntryImportModal";
import { entityEntriesPath } from "routes/Routes";

const EntityNote = styled(Typography)(({ theme }) => ({
color: theme.palette.text.secondary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Link } from "react-router-dom";
import { AttributeNoteModal } from "./AttributeNoteModal";
import { Schema } from "./EntityFormSchema";

import { aclPath } from "Routes";
import { aclPath } from "routes/Routes";
import { AttributeTypes } from "services/Constants";

const StyledBox = styled(Box)(({ theme }) => ({
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/entity/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// FIXME rethink export scope

export * from "./EntityBreadcrumbs";
export * from "./EntityControlMenu";
2 changes: 1 addition & 1 deletion frontend/src/components/entry/AttributeValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as React from "react";
import { FC } from "react";
import { Link } from "react-router-dom";

import { groupsPath, rolePath, entryDetailsPath } from "Routes";
import { groupsPath, rolePath, entryDetailsPath } from "routes/Routes";

const StyledBox = styled(Box)(() => ({
display: "flex",
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/entry/EntryBreadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { Typography } from "@mui/material";
import React, { FC } from "react";
import { Link } from "react-router-dom";

import { AironeBreadcrumbs } from "components/common/AironeBreadcrumbs";
import { FlexBox } from "components/common/FlexBox";
import {
topPath,
entitiesPath,
entityEntriesPath,
entryDetailsPath,
} from "Routes";
import { AironeBreadcrumbs } from "components/common/AironeBreadcrumbs";
import { FlexBox } from "components/common/FlexBox";
} from "routes/Routes";

interface Props {
entry?: EntryRetrieve;
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/entry/EntryControlMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { useSnackbar } from "notistack";
import React, { FC } from "react";
import { Link, useNavigate } from "react-router-dom";

import { Confirmable } from "components/common/Confirmable";
import { aironeApiClient } from "repository/AironeApiClient";
import {
entryEditPath,
aclPath,
Expand All @@ -20,9 +22,7 @@ import {
topPath,
entryDetailsPath,
aclHistoryPath,
} from "Routes";
import { Confirmable } from "components/common/Confirmable";
import { aironeApiClient } from "repository/AironeApiClient";
} from "routes/Routes";

interface EntryControlProps {
entityId: number;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entry/EntryHistoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { useNavigate } from "react-router-dom";

import { AttributeValue } from "./AttributeValue";

import { showEntryHistoryPath, topPath } from "Routes";
import { Confirmable } from "components/common/Confirmable";
import { PaginationFooter } from "components/common/PaginationFooter";
import { aironeApiClient } from "repository/AironeApiClient";
import { showEntryHistoryPath, topPath } from "routes/Routes";
import { EntryHistoryList as ConstEntryHistoryList } from "services/Constants";
import { formatDateTime } from "services/DateUtil";

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entry/EntryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { Link, useNavigate, useLocation } from "react-router-dom";

import { EntryListCard } from "./EntryListCard";

import { newEntryPath } from "Routes";
import { Loading } from "components/common/Loading";
import { PaginationFooter } from "components/common/PaginationFooter";
import { SearchBox } from "components/common/SearchBox";
import { useAsyncWithThrow } from "hooks/useAsyncWithThrow";
import { usePage } from "hooks/usePage";
import { aironeApiClient } from "repository/AironeApiClient";
import { newEntryPath } from "routes/Routes";
import { EntryList as ConstEntryList } from "services/Constants";
import { normalizeToMatch } from "services/StringUtil";

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entry/EntryListCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { styled } from "@mui/material/styles";
import React, { FC, useState } from "react";
import { Link } from "react-router-dom";

import { entryDetailsPath } from "Routes";
import { ClipboardCopyButton } from "components/common/ClipboardCopyButton";
import { EntryControlMenu } from "components/entry/EntryControlMenu";
import { entryDetailsPath } from "routes/Routes";

const StyledCard = styled(Card)(({}) => ({
height: "100%",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entry/EntryReferral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { aironeApiClient } from "../../repository/AironeApiClient";
import { EntryReferralList } from "../../services/Constants";
import { normalizeToMatch } from "../../services/StringUtil";

import { entryDetailsPath } from "Routes";
import { SearchBox } from "components/common/SearchBox";
import { entryDetailsPath } from "routes/Routes";

const ReferralCount = styled(Typography)(({}) => ({
fontSize: "16px",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entry/RestorableEntryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import { useNavigate, useLocation } from "react-router-dom";

import { EntryAttributes } from "./EntryAttributes";

import { restoreEntryPath, topPath } from "Routes";
import { Confirmable } from "components/common/Confirmable";
import { Loading } from "components/common/Loading";
import { PaginationFooter } from "components/common/PaginationFooter";
import { SearchBox } from "components/common/SearchBox";
import { useAsyncWithThrow } from "hooks/useAsyncWithThrow";
import { usePage } from "hooks/usePage";
import { aironeApiClient } from "repository/AironeApiClient";
import { restoreEntryPath, topPath } from "routes/Routes";
import { EntryList as ConstEntryList } from "services/Constants";
import { formatDateTime } from "services/DateUtil";
import { normalizeToMatch } from "services/StringUtil";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entry/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { Link } from "react-router-dom";

import { SearchResultsTableHead } from "./SearchResultsTableHead";

import { entryDetailsPath } from "Routes";
import { PaginationFooter } from "components/common/PaginationFooter";
import { AttributeValue } from "components/entry/AttributeValue";
import { entryDetailsPath } from "routes/Routes";
import { AdvancedSerarchResultList } from "services/Constants";
import { AttrsFilter } from "services/entry/AdvancedSearch";

Expand Down
10 changes: 10 additions & 0 deletions frontend/src/components/entry/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// FIXME rethink export scope

export * from "./CopyForm";
export * from "./EntryBreadcrumbs";
export * from "./EntryControlMenu";
export * from "./EntryImportModal";
export * from "./EntryListCard";

export * from "./entryForm/EntryFormSchema";
export * from "./entryForm/AttributeValueField";
2 changes: 1 addition & 1 deletion frontend/src/components/group/GroupControlMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { useSnackbar } from "notistack";
import React, { FC, useCallback } from "react";
import { Link, useNavigate } from "react-router-dom";

import { groupPath, groupsPath, topPath } from "Routes";
import { Confirmable } from "components/common/Confirmable";
import { aironeApiClient } from "repository/AironeApiClient";
import { groupPath, groupsPath, topPath } from "routes/Routes";

interface Props {
groupId: number;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/group/GroupTreeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Checkbox, IconButton, ListItem, Typography } from "@mui/material";
import React, { FC } from "react";
import { Link } from "react-router-dom";

import { groupPath } from "../../Routes";
import { GroupTree } from "../../repository/AironeApiClient";
import { groupPath } from "../../routes/Routes";
import { ServerContext } from "../../services/ServerContext";

const CHILDREN_INDENT_WIDTH = 16;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/group/GroupTreeRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { styled } from "@mui/material/styles";
import React, { FC } from "react";
import { Link } from "react-router-dom";

import { groupPath } from "../../Routes";
import { GroupTree } from "../../repository/AironeApiClient";
import { groupPath } from "../../routes/Routes";
import { ServerContext } from "../../services/ServerContext";

import { GroupTreeItem } from "./GroupTreeItem";
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./acl";
export * from "./common";
export * from "./entity";
export * from "./entry";
2 changes: 1 addition & 1 deletion frontend/src/components/job/JobList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { styled } from "@mui/material/styles";
import React, { FC, useState } from "react";
import { Link, useNavigate } from "react-router-dom";

import { entityEntriesPath } from "../../Routes";
import { aironeApiClient } from "../../repository/AironeApiClient";
import { entityEntriesPath } from "../../routes/Routes";
import { JobOperations, JobStatuses } from "../../services/Constants";
import { formatDateTime } from "../../services/DateUtil";
import { jobOperationLabel, jobStatusLabel } from "../../services/JobUtil";
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/role/RoleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { aironeApiClient } from "../../repository/AironeApiClient";
import { Confirmable } from "../common/Confirmable";
import { Loading } from "../common/Loading";

import { rolePath, rolesPath, topPath } from "Routes";
import { rolePath, rolesPath, topPath } from "routes/Routes";

const StyledList = styled(List)(() => ({
padding: "0",
Expand Down
Loading

0 comments on commit 72e1e9d

Please sign in to comment.