From 947f5ff773310ae76ba694f08d543a08c2822d09 Mon Sep 17 00:00:00 2001 From: Owaise Imdad Date: Sat, 1 Mar 2025 08:10:16 +0530 Subject: [PATCH 01/19] Added a new HOC in status bar in order to make sure it works on both the resolution, high and low. --- .../Charts/StatusPageBarChart/index.jsx | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/Components/Charts/StatusPageBarChart/index.jsx b/src/Components/Charts/StatusPageBarChart/index.jsx index 5acf4c3d6..46e8ae2a1 100644 --- a/src/Components/Charts/StatusPageBarChart/index.jsx +++ b/src/Components/Charts/StatusPageBarChart/index.jsx @@ -24,6 +24,21 @@ const StatusPageBarChart = ({ checks = [] }) => { checks = [...checks, ...placeholders]; } + const BarBox = ({ width, height, backgroundColor, borderRadius, children }) => ( + + {children} + + ); + return ( { /* TODO what is the purpose of this box? */ // CAIO_REVIEW the purpose of this box is to make sure there are always at least 25 bars // even if there are less than 25 checks - ) : ( { }, }} > - { transition: "height 600ms cubic-bezier(0.4, 0, 0.2, 1)", }} /> - + ) )} From 4f6c29cd9af842f32b018284d64fb4dfbfe792ad Mon Sep 17 00:00:00 2001 From: Aditya Date: Sun, 2 Mar 2025 09:13:30 +0530 Subject: [PATCH 02/19] feat(sidebar): Improve sidebar menu UI --- src/Components/Sidebar/index.jsx | 155 ++++++++++++++++++++++++------- 1 file changed, 120 insertions(+), 35 deletions(-) diff --git a/src/Components/Sidebar/index.jsx b/src/Components/Sidebar/index.jsx index ee0071d4f..bc915b371 100644 --- a/src/Components/Sidebar/index.jsx +++ b/src/Components/Sidebar/index.jsx @@ -63,35 +63,29 @@ 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: "Integrations", path: "integrations", icon: }, { name: "Settings", icon: , path: "settings", }, +]; + +const otherMenuItems = [ + { 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: }, +]; + +const accountMenuItems = [ + { name: "Profile", path: "account/profile", icon: }, + { name: "Password", path: "account/password", icon: }, + { name: "Team", path: "account/team", icon: }, ]; /* TODO this could be a key in nested Path would be the link */ @@ -133,12 +127,38 @@ function Sidebar() { (state) => state.ui.distributedUptimeEnabled ); - const accountMenuItem = menu.find((item) => item.name === "Account"); - if (user.role?.includes("demo") && accountMenuItem) { - accountMenuItem.nested = accountMenuItem.nested.filter((item) => { - return item.name !== "Password"; - }); - } + const renderAccountMenuItems = () => { + let filteredAccountMenuItems = [...accountMenuItems]; + + // If the user is in demo mode, remove the "Password" option + if (user.role?.includes("demo")) { + filteredAccountMenuItems = filteredAccountMenuItems.filter( + (item) => item.name !== "Password" + ); + } + + // If the user is NOT a superadmin, remove the "Team" option + if (user.role && !user.role.includes("superadmin")) { + filteredAccountMenuItems = filteredAccountMenuItems.filter( + (item) => item.name !== "Team" + ); + } + + return filteredAccountMenuItems.map((item) => ( + navigate(item.path)} + sx={{ + gap: theme.spacing(2), + borderRadius: theme.shape.borderRadius, + pl: theme.spacing(4), + }} + > + {item.icon} + {item.name} + + )); + }; const openPopup = (event, id) => { setAnchorEl(event.currentTarget); @@ -260,7 +280,6 @@ function Sidebar() { > {collapsed ? : } - {/* TODO Alignment done using padding. Use single source of truth to that*/} - + + {otherMenuItems.map((item) => { + return item.path ? ( + + { + const url = URL_MAP[item.path]; + if (url) { + window.open(url, "_blank", "noreferrer"); + } else { + navigate(`/${item.path}`); + } + }} + sx={{ + height: "37px", + gap: theme.spacing(4), + borderRadius: theme.shape.borderRadius, + px: theme.spacing(4), + }} + > + {item.icon} + {item.name} {" "} + + + ) : null; + })} + + {collapsed && ( - + {authState.user?.firstName} {authState.user?.lastName} - + {authState.user?.role} @@ -742,6 +826,7 @@ function Sidebar() { {/* TODO Do we need two dividers? */} {collapsed && } + {renderAccountMenuItems()} Date: Sun, 2 Mar 2025 12:51:36 +0530 Subject: [PATCH 03/19] FIX-1847 implemented the logic. --- src/Components/Inputs/Select/index.jsx | 15 +++++- .../Components/OptionsHeader/index.jsx | 49 ++++++++++++------- src/Utils/Input/utils.jsx | 27 ++++++++++ 3 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 src/Utils/Input/utils.jsx diff --git a/src/Components/Inputs/Select/index.jsx b/src/Components/Inputs/Select/index.jsx index f0a1d11c0..4be84b6e0 100644 --- a/src/Components/Inputs/Select/index.jsx +++ b/src/Components/Inputs/Select/index.jsx @@ -2,7 +2,7 @@ import PropTypes from "prop-types"; import { useTheme } from "@emotion/react"; import { MenuItem, Select as MuiSelect, Stack, Typography } from "@mui/material"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; - +import { renderTruncatedValue } from "../../../Utils/Input/utils"; import "./index.css"; /** @@ -50,8 +50,14 @@ const Select = ({ sx, name = "", labelControlSpacing = 2, + truncate = false, + maxTruncateLength = 15, }) => { const theme = useTheme(); + + const selectedItem = items.find((item) => item._id === value); + const displayName = selectedItem ? selectedItem.name : ""; + const itemStyles = { fontSize: "var(--env-var-font-size-medium)", color: theme.palette.primary.contrastTextTertiary, @@ -59,6 +65,10 @@ const Select = ({ margin: theme.spacing(2), }; + const renderShortValue = () => { + return renderTruncatedValue(displayName, truncate, maxTruncateLength, placeholder); + }; + return ( {placeholder && ( ; return ( @@ -27,17 +35,13 @@ const OptionsHeader = ({ direction="row" justifyContent="space-between" > - + - Incidents for + Incidents for: