From fc996158759bb2fc53a17f80ab6b00e6572e09bf Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Tue, 17 Oct 2023 12:18:36 +0530 Subject: [PATCH] fix: sidebar collapse state not working (#2452) --- web/components/project/sidebar-list-item.tsx | 30 ++++++++++---------- web/components/project/sidebar-list.tsx | 10 +++---- web/components/workspace/help-section.tsx | 26 ++++++++--------- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/web/components/project/sidebar-list-item.tsx b/web/components/project/sidebar-list-item.tsx index 5f6f090f7..cab10e7bd 100644 --- a/web/components/project/sidebar-list-item.tsx +++ b/web/components/project/sidebar-list-item.tsx @@ -26,7 +26,6 @@ import { renderEmoji } from "helpers/emoji.helper"; import { IProject } from "types"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; -import { RootStore } from "store/root"; // components import { CustomMenu } from "components/ui"; import { LeaveProjectModal, DeleteProjectModal } from "components/project"; @@ -34,7 +33,6 @@ import { PublishProjectModal } from "components/project/publish-project"; type Props = { project: IProject; - sidebarCollapse: boolean; provided?: DraggableProvided; snapshot?: DraggableStateSnapshot; handleCopyText: () => void; @@ -75,9 +73,9 @@ const navigation = (workspaceSlug: string, projectId: string) => [ ]; export const ProjectSidebarListItem: React.FC = observer((props) => { - const { project, sidebarCollapse, provided, snapshot, handleCopyText, shortContextMenu = false } = props; + const { project, provided, snapshot, handleCopyText, shortContextMenu = false } = props; // store - const { projectPublish, project: projectStore }: RootStore = useMobxStore(); + const { projectPublish, project: projectStore, theme: themeStore } = useMobxStore(); // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -90,6 +88,8 @@ export const ProjectSidebarListItem: React.FC = observer((props) => { const isAdmin = project.member_role === 20; const isViewerOrGuest = project.member_role === 10 || project.member_role === 5; + const isCollapsed = themeStore.sidebarCollapsed; + const handleAddToFavorites = () => { if (!workspaceSlug) return; @@ -152,7 +152,7 @@ export const ProjectSidebarListItem: React.FC = observer((props) => { )} - +
{project.emoji ? ( @@ -187,11 +187,11 @@ export const ProjectSidebarListItem: React.FC = observer((props) => { )} - {!sidebarCollapse && ( + {!isCollapsed && (

{project.name}

)}
- {!sidebarCollapse && ( + {!isCollapsed && ( = observer((props) => {
- {!sidebarCollapse && ( + {!isCollapsed && ( = observer((props) => { leaveFrom="transform scale-100 opacity-100" leaveTo="transform scale-95 opacity-0" > - + {navigation(workspaceSlug as string, project?.id).map((item) => { if ( (item.name === "Cycles" && !project.cycle_view) || @@ -315,17 +315,17 @@ export const ProjectSidebarListItem: React.FC = observer((props) => { tooltipContent={`${project?.name}: ${item.name}`} position="right" className="ml-2" - disabled={!sidebarCollapse} + disabled={!isCollapsed} >
- {!sidebarCollapse && item.name} + {!isCollapsed && item.name}
diff --git a/web/components/project/sidebar-list.tsx b/web/components/project/sidebar-list.tsx index cd6eae038..8ff868689 100644 --- a/web/components/project/sidebar-list.tsx +++ b/web/components/project/sidebar-list.tsx @@ -83,6 +83,8 @@ export const ProjectSidebarList: FC = observer(() => { }); }; + const isCollapsed = themeStore.sidebarCollapsed || false; + /** * Implementing scroll animation styles based on the scroll length of the container */ @@ -126,7 +128,7 @@ export const ProjectSidebarList: FC = observer(() => { {({ open }) => ( <> - {!themeStore?.sidebarCollapsed && ( + {!isCollapsed && (
{ handleCopyText(project.id)} @@ -192,7 +193,7 @@ export const ProjectSidebarList: FC = observer(() => { {({ open }) => ( <> - {!themeStore?.sidebarCollapsed && ( + {!isCollapsed && (
{ handleCopyText(project.id)} @@ -266,7 +266,7 @@ export const ProjectSidebarList: FC = observer(() => { }} > - {!themeStore?.sidebarCollapsed && "Add Project"} + {!isCollapsed && "Add Project"} )}
diff --git a/web/components/workspace/help-section.tsx b/web/components/workspace/help-section.tsx index 03d0cef8b..da4b23bf1 100644 --- a/web/components/workspace/help-section.tsx +++ b/web/components/workspace/help-section.tsx @@ -51,27 +51,25 @@ export const WorkspaceHelpSection: React.FC = observe useOutsideClickDetector(helpOptionsRef, () => setIsNeedHelpOpen(false)); + const isCollapsed = themeStore.sidebarCollapsed || false; + return ( <>
- {!themeStore?.sidebarCollapsed && ( + {!isCollapsed && (
Free Plan
)} -
+
@@ -121,7 +119,7 @@ export const WorkspaceHelpSection: React.FC = observe >