Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): include home tab in sidebar on project page #1076

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions web/src/components/atoms/InnerContents/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,21 @@
import { Children, ReactNode } from "react";

import Content from "@reearth-cms/components/atoms/Content";
import Icon from "@reearth-cms/components/atoms/Icon";

type Props = {
title?: string;
subtitle?: string;
flexChildren?: boolean;
children?: ReactNode;
onHomeNavigation?: () => void;
};

const BasicInnerContents: React.FC<Props> = ({
title,
subtitle,
flexChildren,
children,
onHomeNavigation,
}) => {
const BasicInnerContents: React.FC<Props> = ({ title, subtitle, flexChildren, children }) => {

Check warning on line 13 in web/src/components/atoms/InnerContents/basic.tsx

View check run for this annotation

Codecov / codecov/patch

web/src/components/atoms/InnerContents/basic.tsx#L13

Added line #L13 was not covered by tests
const childrenArray = Children.toArray(children);
return (
<PaddedContent>
{title && (
<Header>
<Title>
{onHomeNavigation && <Icon icon="arrowLeft" size={16} onClick={onHomeNavigation} />}
{title}
</Title>
<Title>{title}</Title>

Check warning on line 19 in web/src/components/atoms/InnerContents/basic.tsx

View check run for this annotation

Codecov / codecov/patch

web/src/components/atoms/InnerContents/basic.tsx#L19

Added line #L19 was not covered by tests
{subtitle && <Subtitle>{subtitle}</Subtitle>}
</Header>
)}
Expand Down Expand Up @@ -58,9 +47,6 @@
font-size: 20px;
line-height: 28px;
margin: 0;
display: flex;
align-items: baseline;
gap: 16px;
`;

const Subtitle = styled.p`
Expand Down
5 changes: 3 additions & 2 deletions web/src/components/molecules/Common/ProjectMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
const t = useT();

const topItems: ItemType[] = [
{ label: t("Overview"), key: "home", icon: <Icon icon="dashboard" /> },
{ label: t("Home"), key: "home", icon: <Icon icon="home" /> },
{ label: t("Overview"), key: "overview", icon: <Icon icon="dashboard" /> },

Check warning on line 19 in web/src/components/molecules/Common/ProjectMenu/index.tsx

View check run for this annotation

Codecov / codecov/patch

web/src/components/molecules/Common/ProjectMenu/index.tsx#L18-L19

Added lines #L18 - L19 were not covered by tests
{ label: t("Schema"), key: "schema", icon: <Icon icon="unorderedList" /> },
{ label: t("Content"), key: "content", icon: <Icon icon="table" /> },
{ label: t("Asset"), key: "asset", icon: <Icon icon="file" /> },
{ label: t("Request"), key: "request", icon: <Icon icon="pullRequest" /> },
];
const [selected, changeSelected] = useState([defaultSelectedKey ?? "home"]);
const [selected, changeSelected] = useState([defaultSelectedKey ?? "overview"]);

Check warning on line 25 in web/src/components/molecules/Common/ProjectMenu/index.tsx

View check run for this annotation

Codecov / codecov/patch

web/src/components/molecules/Common/ProjectMenu/index.tsx#L25

Added line #L25 was not covered by tests

useEffect(() => {
if (defaultSelectedKey && defaultSelectedKey !== selected[0]) {
Expand Down
8 changes: 1 addition & 7 deletions web/src/components/molecules/ProjectOverview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
projectDescription?: string;
models?: Model[];
onModelModalOpen: () => void;
onHomeNavigation: () => void;
onSchemaNavigate: (modelId: string) => void;
onContentNavigate: (modelId: string) => void;
onModelDeletionModalOpen: (model: Model) => Promise<void>;
Expand All @@ -26,7 +25,6 @@
projectDescription,
models,
onModelModalOpen,
onHomeNavigation,
onSchemaNavigate,
onContentNavigate,
onModelDeletionModalOpen,
Expand All @@ -35,11 +33,7 @@
const t = useT();

return (
<InnerContent
title={projectName}
subtitle={projectDescription}
flexChildren
onHomeNavigation={onHomeNavigation}>
<InnerContent title={projectName} subtitle={projectDescription} flexChildren>

Check warning on line 36 in web/src/components/molecules/ProjectOverview/index.tsx

View check run for this annotation

Codecov / codecov/patch

web/src/components/molecules/ProjectOverview/index.tsx#L36

Added line #L36 was not covered by tests
<ContentSection
title={t("Models")}
headerActions={
Expand Down
22 changes: 6 additions & 16 deletions web/src/components/organisms/CMSWrapper/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

const [, secondaryRoute, subRoute] = useMemo(() => splitPathname(pathname), [pathname]);

const selectedKey = useMemo(() => subRoute ?? "home", [subRoute]);

const username = useMemo(() => data?.me?.name || "", [data?.me?.name]);

setCurrentUserId(data?.me?.id);
Expand Down Expand Up @@ -127,20 +125,12 @@

const handleProjectMenuNavigate = useCallback(
(info: MenuInfo) => {
if (info.key === "schema") {
navigate(`/workspace/${workspaceId}/project/${projectId}/schema`);
} else if (info.key === "content") {
navigate(`/workspace/${workspaceId}/project/${projectId}/content`);
} else if (info.key === "asset") {
navigate(`/workspace/${workspaceId}/project/${projectId}/asset`);
} else if (info.key === "request") {
navigate(`/workspace/${workspaceId}/project/${projectId}/request`);
} else if (info.key === "accessibility") {
navigate(`/workspace/${workspaceId}/project/${projectId}/accessibility`);
} else if (info.key === "settings") {
navigate(`/workspace/${workspaceId}/project/${projectId}/settings`);
} else {
if (info.key === "home") {
navigate(`/workspace/${workspaceId}`);
} else if (info.key === "overview") {

Check warning on line 130 in web/src/components/organisms/CMSWrapper/hooks.ts

View check run for this annotation

Codecov / codecov/patch

web/src/components/organisms/CMSWrapper/hooks.ts#L128-L130

Added lines #L128 - L130 were not covered by tests
navigate(`/workspace/${workspaceId}/project/${projectId}`);
} else {
navigate(`/workspace/${workspaceId}/project/${projectId}/${info.key}`);

Check warning on line 133 in web/src/components/organisms/CMSWrapper/hooks.ts

View check run for this annotation

Codecov / codecov/patch

web/src/components/organisms/CMSWrapper/hooks.ts#L132-L133

Added lines #L132 - L133 were not covered by tests
}
},
[navigate, workspaceId, projectId],
Expand Down Expand Up @@ -175,7 +165,7 @@
currentWorkspace,
workspaceModalShown,
currentProject,
selectedKey,
selectedKey: subRoute,

Check warning on line 168 in web/src/components/organisms/CMSWrapper/hooks.ts

View check run for this annotation

Codecov / codecov/patch

web/src/components/organisms/CMSWrapper/hooks.ts#L168

Added line #L168 was not covered by tests
secondaryRoute,
collapsed,
handleCollapse,
Expand Down
5 changes: 0 additions & 5 deletions web/src/components/organisms/Project/Overview/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ export default () => {
[updateNewModel, handleModelModalClose, t],
);

const handleHomeNavigation = useCallback(() => {
navigate(`/workspace/${currentWorkspace?.id}`);
}, [currentWorkspace?.id, navigate]);

const handleSchemaNavigation = useCallback(
(modelId: string) => {
navigate(
Expand Down Expand Up @@ -140,7 +136,6 @@ export default () => {
modelModalShown,
selectedModel,
modelDeletionModalShown,
handleHomeNavigation,
handleSchemaNavigation,
handleContentNavigation,
handleModelKeyCheck,
Expand Down
2 changes: 0 additions & 2 deletions web/src/components/organisms/Project/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const ProjectOverview: React.FC = () => {
modelModalShown,
selectedModel,
modelDeletionModalShown,
handleHomeNavigation,
handleSchemaNavigation,
handleContentNavigation,
handleModelKeyCheck,
Expand All @@ -31,7 +30,6 @@ const ProjectOverview: React.FC = () => {
projectName={currentProject?.name}
projectDescription={currentProject?.description}
models={models}
onHomeNavigation={handleHomeNavigation}
onSchemaNavigate={handleSchemaNavigation}
onContentNavigate={handleContentNavigation}
onModelModalOpen={handleModelModalOpen}
Expand Down
Loading