From 8cd61cdcf22e0838e6be43f377631ff70174139a Mon Sep 17 00:00:00 2001 From: ahmadnadeem6236 Date: Tue, 7 Jan 2025 15:05:32 +0530 Subject: [PATCH 1/4] changes the sidebar --- Client/src/Components/Sidebar/index.jsx | 340 ++++++++++++++++++++++-- 1 file changed, 314 insertions(+), 26 deletions(-) diff --git a/Client/src/Components/Sidebar/index.jsx b/Client/src/Components/Sidebar/index.jsx index d5d69838d..77a480bc5 100644 --- a/Client/src/Components/Sidebar/index.jsx +++ b/Client/src/Components/Sidebar/index.jsx @@ -55,34 +55,38 @@ const menu = [ // { name: "Status pages", path: "status", icon: }, { name: "Maintenance", path: "maintenance", icon: }, // { name: "Integrations", path: "integrations", icon: }, - { - name: "Account", - icon: , - nested: [ - { name: "Profile", path: "account/profile", icon: }, - { name: "Password", path: "account/password", icon: }, - { name: "Team", path: "account/team", icon: }, - ], - }, + //{ + // name: "Account", + // icon: , + // nested: [ + // { name: "Profile", path: "account/profile", icon: }, + // { name: "Password", path: "account/password", icon: }, + // { name: "Team", path: "account/team", icon: }, + // ], + //}, { name: "Settings", icon: , path: "settings", }, + + // { + // name: "Other", + // icon: , + // nested: [ + // ], + // }, +]; + +const subMenu = [ + { name: "Support", path: "support", icon: }, { - name: "Other", - icon: , - nested: [ - { name: "Support", path: "support", icon: }, - { - name: "Discussions", - path: "discussions", - icon: , - }, - { name: "Docs", path: "docs", icon: }, - { name: "Changelog", path: "changelog", icon: }, - ], + name: "Discussions", + path: "discussions", + icon: , }, + { name: "Docs", path: "docs", icon: }, + { name: "Changelog", path: "changelog", icon: }, ]; /* TODO this could be a key in nested Path would be the link */ @@ -270,11 +274,253 @@ function Sidebar() { } sx={{ px: theme.spacing(6), + height: "30%", + }} + > + {menu.map((item) => + item.path ? ( + + navigate(`/${item.path}`)} + sx={{ + height: "37px", + gap: theme.spacing(4), + borderRadius: theme.shape.borderRadius, + px: theme.spacing(4), + }} + > + {item.icon} + {item.name} + + + ) : collapsed ? ( + /* TODO Do we ever get here? */ + + + openPopup(event, item.name)} + sx={{ + position: "relative", + gap: theme.spacing(4), + borderRadius: theme.shape.borderRadius, + px: theme.spacing(4), + }} + > + {item.icon} + {item.name} + + + {/* + {item.nested.map((child) => { + if ( + child.name === "Team" && + authState.user?.role && + !authState.user.role.includes("superadmin") + ) { + return null; + } + + return ( + { + const url = URL_MAP[child.path]; + if (url) { + window.open(url, "_blank", "noreferrer"); + } else { + navigate(`/${child.path}`); + } + closePopup(); + }} + sx={{ + gap: theme.spacing(4), + opacity: 0.9, + "& svg": { + "& path": { + stroke: theme.palette.other.icon, + strokeWidth: 1.1, + }, + }, + }} + > + {child.icon} + {child.name} + + ); + })} + */} + + ) : ( + + + setOpen((prev) => ({ + ...Object.fromEntries(Object.keys(prev).map((key) => [key, false])), + [item.name]: !prev[item.name], + })) + } + sx={{ + gap: theme.spacing(4), + borderRadius: theme.shape.borderRadius, + px: theme.spacing(4), + }} + > + {item.icon} + {item.name} + {open[`${item.name}`] ? : } + + + {/* + {item.nested.map((child) => { + if ( + child.name === "Team" && + authState.user?.role && + !authState.user.role.includes("superadmin") + ) { + return null; + } + + return ( + { + const url = URL_MAP[child.path]; + if (url) { + window.open(url, "_blank", "noreferrer"); + } else { + navigate(`/${child.path}`); + } + }} + sx={{ + gap: theme.spacing(4), + borderRadius: theme.shape.borderRadius, + pl: theme.spacing(4), + "&::before": { + content: `""`, + position: "absolute", + top: 0, + left: "-7px", + height: "100%", + borderLeft: 1, + borderLeftColor: theme.palette.other.line, + }, + "&:last-child::before": { + height: "50%", + }, + "&::after": { + content: `""`, + position: "absolute", + top: "45%", + left: "-8px", + height: "3px", + width: "3px", + borderRadius: "50%", + backgroundColor: theme.palette.other.line, + }, + "&.selected-path::after": { + backgroundColor: theme.palette.text.tertiary, + transform: "scale(1.2)", + }, + }} + > + {child.icon} + {child.name} + + ); + })} + */} + + + ) + )} + + - {menu.map((item) => + {subMenu.map((item) => item.path ? ( {item.name} - ); })} - + */} ) : ( @@ -573,7 +819,7 @@ function Sidebar() { mr: "-8px", "&:focus": { outline: "none" }, alignSelf: "center", - padding: '10px', + padding: "10px", "& svg": { width: "22px", @@ -639,7 +885,49 @@ function Sidebar() { )} {collapsed && } - + navigate("account/profile")} + sx={{ + gap: theme.spacing(4), + borderRadius: theme.shape.borderRadius, + pl: theme.spacing(4), + "& svg path": { + stroke: theme.palette.other.icon, + }, + }} + > + + Profile + + + navigate("account/password")} + sx={{ + gap: theme.spacing(4), + borderRadius: theme.shape.borderRadius, + pl: theme.spacing(4), + "& svg path": { + stroke: theme.palette.other.icon, + }, + }} + > + + Password + + navigate("account/team")} + sx={{ + gap: theme.spacing(4), + borderRadius: theme.shape.borderRadius, + pl: theme.spacing(4), + "& svg path": { + stroke: theme.palette.other.icon, + }, + }} + > + + Team + Date: Tue, 7 Jan 2025 15:22:58 +0530 Subject: [PATCH 2/4] refactor the code --- Client/src/Components/Sidebar/index.jsx | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Client/src/Components/Sidebar/index.jsx b/Client/src/Components/Sidebar/index.jsx index 77a480bc5..7e7347c8e 100644 --- a/Client/src/Components/Sidebar/index.jsx +++ b/Client/src/Components/Sidebar/index.jsx @@ -55,27 +55,11 @@ const menu = [ // { name: "Status pages", path: "status", icon: }, { name: "Maintenance", path: "maintenance", icon: }, // { name: "Integrations", path: "integrations", icon: }, - //{ - // name: "Account", - // icon: , - // nested: [ - // { name: "Profile", path: "account/profile", icon: }, - // { name: "Password", path: "account/password", icon: }, - // { name: "Team", path: "account/team", icon: }, - // ], - //}, { name: "Settings", icon: , path: "settings", }, - - // { - // name: "Other", - // icon: , - // nested: [ - // ], - // }, ]; const subMenu = [ From fe5802cfcf3a57bd7bfa7df8100c592f9d1efd66 Mon Sep 17 00:00:00 2001 From: ahmadnadeem6236 Date: Tue, 7 Jan 2025 15:40:36 +0530 Subject: [PATCH 3/4] fix the spacing --- Client/src/Components/Sidebar/index.jsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Client/src/Components/Sidebar/index.jsx b/Client/src/Components/Sidebar/index.jsx index 7e7347c8e..7185c382b 100644 --- a/Client/src/Components/Sidebar/index.jsx +++ b/Client/src/Components/Sidebar/index.jsx @@ -258,7 +258,7 @@ function Sidebar() { } sx={{ px: theme.spacing(6), - height: "30%", + height: "auto", }} > {menu.map((item) => @@ -331,7 +331,7 @@ function Sidebar() { {item.name} - {/* ); })} - */} + ) : ( @@ -499,8 +499,7 @@ function Sidebar() { disablePadding sx={{ px: theme.spacing(6), - pt: theme.spacing(60), - height: "100%", + pt: theme.spacing(35), overflow: "hidden", }} > @@ -574,7 +573,7 @@ function Sidebar() { {item.name} - {/* ); })} - */} + ) : ( From 31d9e13686abc32a11b10da056eb9b7678ba8001 Mon Sep 17 00:00:00 2001 From: ahmadnadeem6236 Date: Thu, 9 Jan 2025 02:01:04 +0530 Subject: [PATCH 4/4] deleted the commented code --- Client/src/Components/Sidebar/index.jsx | 69 +------------------------ 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/Client/src/Components/Sidebar/index.jsx b/Client/src/Components/Sidebar/index.jsx index 7185c382b..11019f41d 100644 --- a/Client/src/Components/Sidebar/index.jsx +++ b/Client/src/Components/Sidebar/index.jsx @@ -421,74 +421,7 @@ function Sidebar() { - {/* - {item.nested.map((child) => { - if ( - child.name === "Team" && - authState.user?.role && - !authState.user.role.includes("superadmin") - ) { - return null; - } - - return ( - { - const url = URL_MAP[child.path]; - if (url) { - window.open(url, "_blank", "noreferrer"); - } else { - navigate(`/${child.path}`); - } - }} - sx={{ - gap: theme.spacing(4), - borderRadius: theme.shape.borderRadius, - pl: theme.spacing(4), - "&::before": { - content: `""`, - position: "absolute", - top: 0, - left: "-7px", - height: "100%", - borderLeft: 1, - borderLeftColor: theme.palette.other.line, - }, - "&:last-child::before": { - height: "50%", - }, - "&::after": { - content: `""`, - position: "absolute", - top: "45%", - left: "-8px", - height: "3px", - width: "3px", - borderRadius: "50%", - backgroundColor: theme.palette.other.line, - }, - "&.selected-path::after": { - backgroundColor: theme.palette.text.tertiary, - transform: "scale(1.2)", - }, - }} - > - {child.icon} - {child.name} - - ); - })} - */} - + > ) )}