From 150e9f57d9230db087d086cdb3306decdec3a670 Mon Sep 17 00:00:00 2001 From: Kazuma Tsuchiya Date: Wed, 21 Feb 2024 17:55:04 +0900 Subject: [PATCH 1/2] revert: go back home button --- .../components/atoms/InnerContents/basic.tsx | 18 ++---------------- .../molecules/ProjectOverview/index.tsx | 8 +------- .../organisms/Project/Overview/hooks.ts | 5 ----- .../organisms/Project/Overview/index.tsx | 2 -- 4 files changed, 3 insertions(+), 30 deletions(-) diff --git a/web/src/components/atoms/InnerContents/basic.tsx b/web/src/components/atoms/InnerContents/basic.tsx index 9f746f961f..430c664844 100644 --- a/web/src/components/atoms/InnerContents/basic.tsx +++ b/web/src/components/atoms/InnerContents/basic.tsx @@ -2,32 +2,21 @@ import styled from "@emotion/styled"; 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 = ({ - title, - subtitle, - flexChildren, - children, - onHomeNavigation, -}) => { +const BasicInnerContents: React.FC = ({ title, subtitle, flexChildren, children }) => { const childrenArray = Children.toArray(children); return ( {title && (
- - {onHomeNavigation && <Icon icon="arrowLeft" size={16} onClick={onHomeNavigation} />} - {title} - + {title} {subtitle && {subtitle}}
)} @@ -58,9 +47,6 @@ const Title = styled.p` font-size: 20px; line-height: 28px; margin: 0; - display: flex; - align-items: baseline; - gap: 16px; `; const Subtitle = styled.p` diff --git a/web/src/components/molecules/ProjectOverview/index.tsx b/web/src/components/molecules/ProjectOverview/index.tsx index 986677319d..56839d3ef8 100644 --- a/web/src/components/molecules/ProjectOverview/index.tsx +++ b/web/src/components/molecules/ProjectOverview/index.tsx @@ -14,7 +14,6 @@ type Props = { projectDescription?: string; models?: Model[]; onModelModalOpen: () => void; - onHomeNavigation: () => void; onSchemaNavigate: (modelId: string) => void; onContentNavigate: (modelId: string) => void; onModelDeletionModalOpen: (model: Model) => Promise; @@ -26,7 +25,6 @@ const ProjectOverview: React.FC = ({ projectDescription, models, onModelModalOpen, - onHomeNavigation, onSchemaNavigate, onContentNavigate, onModelDeletionModalOpen, @@ -35,11 +33,7 @@ const ProjectOverview: React.FC = ({ const t = useT(); return ( - + { [updateNewModel, handleModelModalClose, t], ); - const handleHomeNavigation = useCallback(() => { - navigate(`/workspace/${currentWorkspace?.id}`); - }, [currentWorkspace?.id, navigate]); - const handleSchemaNavigation = useCallback( (modelId: string) => { navigate( @@ -140,7 +136,6 @@ export default () => { modelModalShown, selectedModel, modelDeletionModalShown, - handleHomeNavigation, handleSchemaNavigation, handleContentNavigation, handleModelKeyCheck, diff --git a/web/src/components/organisms/Project/Overview/index.tsx b/web/src/components/organisms/Project/Overview/index.tsx index 675a9b6dd5..7cd765fc4d 100644 --- a/web/src/components/organisms/Project/Overview/index.tsx +++ b/web/src/components/organisms/Project/Overview/index.tsx @@ -11,7 +11,6 @@ const ProjectOverview: React.FC = () => { modelModalShown, selectedModel, modelDeletionModalShown, - handleHomeNavigation, handleSchemaNavigation, handleContentNavigation, handleModelKeyCheck, @@ -31,7 +30,6 @@ const ProjectOverview: React.FC = () => { projectName={currentProject?.name} projectDescription={currentProject?.description} models={models} - onHomeNavigation={handleHomeNavigation} onSchemaNavigate={handleSchemaNavigation} onContentNavigate={handleContentNavigation} onModelModalOpen={handleModelModalOpen} From 725edc1f03900f1a5da705859214e4ae704c459d Mon Sep 17 00:00:00 2001 From: Kazuma Tsuchiya Date: Wed, 21 Feb 2024 18:19:01 +0900 Subject: [PATCH 2/2] add: home tab on project page --- .../molecules/Common/ProjectMenu/index.tsx | 5 +++-- .../components/organisms/CMSWrapper/hooks.ts | 22 +++++-------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/web/src/components/molecules/Common/ProjectMenu/index.tsx b/web/src/components/molecules/Common/ProjectMenu/index.tsx index 7dea98eaeb..3036f589af 100644 --- a/web/src/components/molecules/Common/ProjectMenu/index.tsx +++ b/web/src/components/molecules/Common/ProjectMenu/index.tsx @@ -15,13 +15,14 @@ const ProjectMenu: React.FC = ({ inlineCollapsed, defaultSelectedKey, onN const t = useT(); const topItems: ItemType[] = [ - { label: t("Overview"), key: "home", icon: }, + { label: t("Home"), key: "home", icon: }, + { label: t("Overview"), key: "overview", icon: }, { label: t("Schema"), key: "schema", icon: }, { label: t("Content"), key: "content", icon: }, { label: t("Asset"), key: "asset", icon: }, { label: t("Request"), key: "request", icon: }, ]; - const [selected, changeSelected] = useState([defaultSelectedKey ?? "home"]); + const [selected, changeSelected] = useState([defaultSelectedKey ?? "overview"]); useEffect(() => { if (defaultSelectedKey && defaultSelectedKey !== selected[0]) { diff --git a/web/src/components/organisms/CMSWrapper/hooks.ts b/web/src/components/organisms/CMSWrapper/hooks.ts index 86d4715f33..3e80c9ee00 100644 --- a/web/src/components/organisms/CMSWrapper/hooks.ts +++ b/web/src/components/organisms/CMSWrapper/hooks.ts @@ -35,8 +35,6 @@ export default () => { 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); @@ -127,20 +125,12 @@ export default () => { 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") { navigate(`/workspace/${workspaceId}/project/${projectId}`); + } else { + navigate(`/workspace/${workspaceId}/project/${projectId}/${info.key}`); } }, [navigate, workspaceId, projectId], @@ -175,7 +165,7 @@ export default () => { currentWorkspace, workspaceModalShown, currentProject, - selectedKey, + selectedKey: subRoute, secondaryRoute, collapsed, handleCollapse,