Skip to content

Commit

Permalink
Added page component for AliasEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
userlocalhost committed Dec 12, 2024
1 parent 41504a4 commit d13d4b1
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/src/components/entity/EntityControlMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
editEntityPath,
entitiesPath,
restoreEntryPath,
listAliasPath,
topPath,
entityEntriesPath,
aclHistoryPath,
Expand Down Expand Up @@ -94,6 +95,9 @@ export const EntityControlMenu: FC<Props> = ({
<MenuItem component={Link} to={entityEntriesPath(entityId)}>
<Typography>アイテム一覧</Typography>
</MenuItem>
<MenuItem component={Link} to={listAliasPath(entityId)}>
<Typography>エイリアス一覧</Typography>
</MenuItem>
<MenuItem component={Link} to={editEntityPath(entityId)}>
<Typography>編集</Typography>
</MenuItem>
Expand Down
88 changes: 88 additions & 0 deletions frontend/src/pages/ListAliasEntryPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import AppsIcon from "@mui/icons-material/Apps";
import { Box, Container, IconButton, Grid } from "@mui/material";
import { useSnackbar } from "notistack";
import React, { FC, useState } from "react";
import { useNavigate } from "react-router-dom";

import { EntityControlMenu } from "components/entity/EntityControlMenu";

Check failure on line 7 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

There should be at least one empty line between import groups

Check failure on line 7 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

`components/entity/EntityControlMenu` import should occur after import of `components/entity/EntityBreadcrumbs`
import { useAsyncWithThrow } from "../hooks/useAsyncWithThrow";
import { useTypedParams } from "../hooks/useTypedParams";

Check failure on line 9 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

There should be at least one empty line between import groups
import { EntryImportModal } from "components/entry/EntryImportModal";

Check failure on line 10 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

There should be no empty line within import group

Check failure on line 10 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

`components/entry/EntryImportModal` import should occur after import of `components/entity/EntityBreadcrumbs`

import { Loading } from "components/common/Loading";

Check failure on line 12 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

'Loading' is defined but never used

Check failure on line 12 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

'Loading' is defined but never used
import { PageHeader } from "components/common/PageHeader";
import { SubmitButton } from "components/common/SubmitButton";

Check failure on line 14 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

'SubmitButton' is defined but never used

Check failure on line 14 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

'SubmitButton' is defined but never used
import {

Check failure on line 15 in frontend/src/pages/ListAliasEntryPage.tsx

View workflow job for this annotation

GitHub Actions / lint

`components/entry/CopyForm` import should occur after import of `components/entity/EntityBreadcrumbs`
CopyForm as DefaultCopyForm,
CopyFormProps,
} from "components/entry/CopyForm";
import { EntryBreadcrumbs } from "components/entry/EntryBreadcrumbs";
import { usePrompt } from "hooks/usePrompt";
import { aironeApiClient } from "repository/AironeApiClient";
import { entityEntriesPath, entryDetailsPath } from "routes/Routes";
import { EntityBreadcrumbs } from "components/entity/EntityBreadcrumbs";

interface Props {
CopyForm?: FC<CopyFormProps>;
}

export const ListAliasEntryPage: FC<Props> = ({ CopyForm = DefaultCopyForm }) => {
const navigate = useNavigate();
const { enqueueSnackbar } = useSnackbar();

const [entityAnchorEl, setEntityAnchorEl] =
useState<HTMLButtonElement | null>(null);
const [openImportModal, setOpenImportModal] = React.useState(false);

const { entityId } = useTypedParams<{
entityId: number;
}>();

const entity = useAsyncWithThrow(async () => {
return await aironeApiClient.getEntity(entityId);
}, [entityId]);

// (TODO) get all corresponding aliases of entity

return (
<Box>
<EntityBreadcrumbs entity={entity.value} title="エイリアス設定" />

<PageHeader title={entity.value?.name ?? ""} description="エイリアス設定">
<Box width="50px">
<IconButton
id="entity_menu"
onClick={(e) => {
setEntityAnchorEl(e.currentTarget);
}}
>
<AppsIcon />
</IconButton>
<EntityControlMenu
entityId={entityId}
anchorElem={entityAnchorEl}
handleClose={() => setEntityAnchorEl(null)}
setOpenImportModal={setOpenImportModal}
/>
</Box>
</PageHeader>

<Container>
{/* show all Aliases that are associated with each Items */}
<Grid container spacing={2}>
<Grid item xs={4} sx={{ height: "500px" }}>
<>xs=8</>
</Grid>
<Grid item xs={8} sx={{ height: "500px" }}>
<>xs=4</>
</Grid>
</Grid>
</Container>

<EntryImportModal
openImportModal={openImportModal}
closeImportModal={() => setOpenImportModal(false)}
/>
</Box>
);
};
6 changes: 6 additions & 0 deletions frontend/src/routes/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "react-router-dom";

import { ACLHistoryPage } from "../pages/ACLHistoryPage";
import { ListAliasEntryPage } from "../pages/ListAliasEntryPage";
import { EntryCopyPage } from "../pages/EntryCopyPage";
import { EntryDetailsPage } from "../pages/EntryDetailsPage";
import { EntryRestorePage } from "../pages/EntryRestorePage";
Expand Down Expand Up @@ -52,6 +53,7 @@ import {
groupsPath,
jobsPath,
loginPath,
listAliasPath,
newEntityPath,
newEntryPath,
newGroupPath,
Expand Down Expand Up @@ -133,6 +135,10 @@ export const AppRouter: FC<Props> = ({ customRoutes }) => {
path={entityHistoryPath(":entityId")}
element={<EntityHistoryPage />}
/>
<Route
path={listAliasPath(":entityId")}
element={<ListAliasEntryPage />}
/>
<Route path={newEntityPath()} element={<EntityEditPage />} />
<Route
path={editEntityPath(":entityId")}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/routes/Routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const showEntryHistoryPath = (
// entities
export const entityHistoryPath = (entityId: number | string) =>
basePath + `entities/${entityId}/history`;
export const listAliasPath = (entityId: number | string) =>
basePath + `entities/${entityId}/alias`;
export const newEntityPath = () => basePath + "entities/new";
export const editEntityPath = (entityId: number | string) =>
basePath + `entities/${entityId}`;
Expand Down

0 comments on commit d13d4b1

Please sign in to comment.