From ac461ec869e9ca660bfb386e5547c9ac6fe12d2e Mon Sep 17 00:00:00 2001 From: MiraGeowerkstatt Date: Thu, 18 Jul 2024 11:50:09 +0200 Subject: [PATCH 1/8] Add button tooltips to sidebar --- CHANGELOG.md | 2 +- src/client/public/icons/help.svg | 2 +- .../src/commons/menu/mainView/mainSideNav.tsx | 162 ++++++++++++++---- 3 files changed, 128 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7326a15c..731328d62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ - Added borehole geometry panel. - Added secondary header to borehole detail view. -- Added new codelist entries for `casing_type` and `backfill_material`. +- Added new codelist entries for `casing_type` and `backfill_material`.git ### Changed diff --git a/src/client/public/icons/help.svg b/src/client/public/icons/help.svg index 5efd24d9e..2c5d0a9a2 100644 --- a/src/client/public/icons/help.svg +++ b/src/client/public/icons/help.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/src/client/src/commons/menu/mainView/mainSideNav.tsx b/src/client/src/commons/menu/mainView/mainSideNav.tsx index c3c11c29c..a7ce41865 100644 --- a/src/client/src/commons/menu/mainView/mainSideNav.tsx +++ b/src/client/src/commons/menu/mainView/mainSideNav.tsx @@ -1,7 +1,7 @@ import { useContext, useEffect, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useHistory } from "react-router-dom"; -import { Badge, IconButton, Stack } from "@mui/material"; +import { Badge, IconButton, Stack, Typography } from "@mui/material"; import { ImportErrorModal } from "./menuComponents/importErrorModal"; import FilterIcon from "../../../../public/icons/filter.svg?react"; import AddIcon from "../../../../public/icons/add.svg?react"; @@ -16,13 +16,20 @@ import { DrawerContentTypes } from "../../../pages/editor/editorComponentInterfa import { ErrorResponse, MainSideNavProps } from "./menuComponents/menuComponentInterfaces"; import { ReduxRootState, User } from "../../../ReduxStateInterfaces"; import { FilterContext } from "../../../components/filter/filterContext"; +import { useTranslation } from "react-i18next"; const StyledIconButton = styled(IconButton)({ padding: "10px", marginBottom: "25px", color: theme.palette.neutral.contrastText, "&:hover": { - backgroundColor: theme.palette.background.lightgrey, + backgroundColor: `${theme.palette.secondary.main} !important`, + color: `${theme.palette.secondary.contrastText} !important`, + width: "fit-content", + whiteSpace: "nowrap", + zIndex: 6000, + paddingLeft: "16px", + justifyContent: "flex-start", }, borderRadius: "10px", }); @@ -44,6 +51,7 @@ const MainSideNav = ({ }: MainSideNavProps) => { const history = useHistory(); const menuRef = useRef(null); + const { t } = useTranslation(); const [creating, setCreating] = useState(false); const [modal, setModal] = useState(false); const [upload, setUpload] = useState(false); @@ -52,6 +60,7 @@ const MainSideNav = ({ const [selectedBoreholeAttachments, setSelectedBoreholeAttachments] = useState(null); const [selectedLithologyFile, setSelectedLithologyFile] = useState(null); const [errorsResponse, setErrorsResponse] = useState(null); + const [hoveredButtonId, setHoveredButtonId] = useState(null); const filterContext = useContext(FilterContext); // Redux state @@ -96,6 +105,99 @@ const MainSideNav = ({ const isLayersPanelVisible = drawerOpen && sideDrawerContent === DrawerContentTypes.CustomLayers; const activeFilterCount = filterContext.activeFilterLength + (filterContext.filterPolygon === null ? 0 : 1); + function getTooltipWrapper(content: JSX.Element) { + return ( + + {content} + + ); + } + + interface ButtonContentInterface { + id: string; + onClick: () => void; + sx: object; + defaultContent: JSX.Element; + hoverContent: JSX.Element; + } + + const topButtonData: ButtonContentInterface[] = [ + { + id: "show-filter-button", + onClick: handleToggleFilter, + sx: isFilterPanelVisible ? selectedButtonStyle : {}, + defaultContent: , + hoverContent: getTooltipWrapper( + <> + {t("searchfilters")} + , + ), + }, + { + id: "new-borehole-button", + onClick: handleToggleAdd, + sx: isAddPanelVisible ? selectedButtonStyle : {}, + defaultContent: , + hoverContent: getTooltipWrapper( + <> + {t("add")} + , + ), + }, + { + id: "import-borehole-button", + onClick: () => { + toggleDrawer(false); + setModal(true); + setUpload(true); + }, + sx: {}, + defaultContent: , + hoverContent: getTooltipWrapper( + <> + {t("upload")} + , + ), + }, + { + id: "layers-button", + onClick: handleToggleLayers, + sx: isLayersPanelVisible ? selectedButtonStyle : {}, + defaultContent: , + hoverContent: getTooltipWrapper( + <> + + {t("usersMap")} + , + ), + }, + ]; + + const bottomButtonData: ButtonContentInterface[] = [ + { + id: "settings-button", + onClick: () => history.push(`/setting`), + sx: {}, + defaultContent: , + hoverContent: getTooltipWrapper( + <> + {t("header_settings")} + , + ), + }, + { + id: "help-button", + onClick: () => window.open(`/help`), + sx: {}, + defaultContent: , + hoverContent: getTooltipWrapper( + <> + {t("header_help")} + , + ), + }, + ]; + return ( {activeFilterCount > 0 && } - - - - - - - { - setModal(true); - setUpload(true); - }} - disabled={user.data.roles.indexOf("EDIT") === -1}> - - - - - + {topButtonData.map(button => ( + setHoveredButtonId(button.id)} + onMouseLeave={() => setHoveredButtonId(null)} + sx={button.sx}> + {hoveredButtonId === button.id ? button.hoverContent : button.defaultContent} + + ))} - history.push(`/setting`)}> - - - - window.open(`/help`)} /> - + {bottomButtonData.map(button => ( + setHoveredButtonId(button.id)} + onMouseLeave={() => setHoveredButtonId(null)} + sx={button.sx}> + {hoveredButtonId === button.id ? button.hoverContent : button.defaultContent} + + ))} Date: Thu, 18 Jul 2024 11:51:12 +0200 Subject: [PATCH 2/8] Fix changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 731328d62..c081c1943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,8 @@ - Added borehole geometry panel. - Added secondary header to borehole detail view. -- Added new codelist entries for `casing_type` and `backfill_material`.git +- Added new codelist entries for `casing_type` and `backfill_material`. +- Added tooltips to main side navigation. ### Changed From 9193f705a771cf501443794d3d397ea452ad0f5a Mon Sep 17 00:00:00 2001 From: tschumpr Date: Fri, 19 Jul 2024 13:28:17 +0200 Subject: [PATCH 3/8] Disable buttons for view-only users --- src/client/src/commons/menu/mainView/mainSideNav.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/client/src/commons/menu/mainView/mainSideNav.tsx b/src/client/src/commons/menu/mainView/mainSideNav.tsx index a7ce41865..fab651e90 100644 --- a/src/client/src/commons/menu/mainView/mainSideNav.tsx +++ b/src/client/src/commons/menu/mainView/mainSideNav.tsx @@ -119,6 +119,7 @@ const MainSideNav = ({ sx: object; defaultContent: JSX.Element; hoverContent: JSX.Element; + disabled?: boolean; } const topButtonData: ButtonContentInterface[] = [ @@ -138,6 +139,7 @@ const MainSideNav = ({ onClick: handleToggleAdd, sx: isAddPanelVisible ? selectedButtonStyle : {}, defaultContent: , + disabled: user.data.roles.indexOf("EDIT") === -1, hoverContent: getTooltipWrapper( <> {t("add")} @@ -153,6 +155,7 @@ const MainSideNav = ({ }, sx: {}, defaultContent: , + disabled: user.data.roles.indexOf("EDIT") === -1, hoverContent: getTooltipWrapper( <> {t("upload")} @@ -222,6 +225,7 @@ const MainSideNav = ({ onClick={button.onClick} onMouseEnter={() => setHoveredButtonId(button.id)} onMouseLeave={() => setHoveredButtonId(null)} + disabled={button.disabled} sx={button.sx}> {hoveredButtonId === button.id ? button.hoverContent : button.defaultContent} From d94a906486c84c2eff9d38afa7fb792a683b7351 Mon Sep 17 00:00:00 2001 From: tschumpr Date: Fri, 19 Jul 2024 14:34:03 +0200 Subject: [PATCH 4/8] Add navButton component --- .../src/commons/menu/mainView/mainSideNav.tsx | 189 +++++------------- .../src/components/buttons/navButton.tsx | 53 +++++ 2 files changed, 100 insertions(+), 142 deletions(-) create mode 100644 src/client/src/components/buttons/navButton.tsx diff --git a/src/client/src/commons/menu/mainView/mainSideNav.tsx b/src/client/src/commons/menu/mainView/mainSideNav.tsx index fab651e90..9e79a8963 100644 --- a/src/client/src/commons/menu/mainView/mainSideNav.tsx +++ b/src/client/src/commons/menu/mainView/mainSideNav.tsx @@ -1,7 +1,7 @@ import { useContext, useEffect, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useHistory } from "react-router-dom"; -import { Badge, IconButton, Stack, Typography } from "@mui/material"; +import { Badge, Stack } from "@mui/material"; import { ImportErrorModal } from "./menuComponents/importErrorModal"; import FilterIcon from "../../../../public/icons/filter.svg?react"; import AddIcon from "../../../../public/icons/add.svg?react"; @@ -10,34 +10,13 @@ import SettingsIcon from "../../../../public/icons/settings.svg?react"; import HelpIcon from "../../../../public/icons/help.svg?react"; import LayersIcon from "../../../../public/icons/layers.svg?react"; import { theme } from "../../../AppTheme"; -import { styled } from "@mui/system"; import ImportModal from "./actions/importModal"; import { DrawerContentTypes } from "../../../pages/editor/editorComponentInterfaces"; import { ErrorResponse, MainSideNavProps } from "./menuComponents/menuComponentInterfaces"; import { ReduxRootState, User } from "../../../ReduxStateInterfaces"; import { FilterContext } from "../../../components/filter/filterContext"; import { useTranslation } from "react-i18next"; - -const StyledIconButton = styled(IconButton)({ - padding: "10px", - marginBottom: "25px", - color: theme.palette.neutral.contrastText, - "&:hover": { - backgroundColor: `${theme.palette.secondary.main} !important`, - color: `${theme.palette.secondary.contrastText} !important`, - width: "fit-content", - whiteSpace: "nowrap", - zIndex: 6000, - paddingLeft: "16px", - justifyContent: "flex-start", - }, - borderRadius: "10px", -}); - -const selectedButtonStyle = { - color: theme.palette.primary.contrastText, - backgroundColor: theme.palette.background.menuItemActive + " !important", -}; +import { NavButton } from "../../../components/buttons/navButton"; const MainSideNav = ({ toggleDrawer, @@ -105,102 +84,6 @@ const MainSideNav = ({ const isLayersPanelVisible = drawerOpen && sideDrawerContent === DrawerContentTypes.CustomLayers; const activeFilterCount = filterContext.activeFilterLength + (filterContext.filterPolygon === null ? 0 : 1); - function getTooltipWrapper(content: JSX.Element) { - return ( - - {content} - - ); - } - - interface ButtonContentInterface { - id: string; - onClick: () => void; - sx: object; - defaultContent: JSX.Element; - hoverContent: JSX.Element; - disabled?: boolean; - } - - const topButtonData: ButtonContentInterface[] = [ - { - id: "show-filter-button", - onClick: handleToggleFilter, - sx: isFilterPanelVisible ? selectedButtonStyle : {}, - defaultContent: , - hoverContent: getTooltipWrapper( - <> - {t("searchfilters")} - , - ), - }, - { - id: "new-borehole-button", - onClick: handleToggleAdd, - sx: isAddPanelVisible ? selectedButtonStyle : {}, - defaultContent: , - disabled: user.data.roles.indexOf("EDIT") === -1, - hoverContent: getTooltipWrapper( - <> - {t("add")} - , - ), - }, - { - id: "import-borehole-button", - onClick: () => { - toggleDrawer(false); - setModal(true); - setUpload(true); - }, - sx: {}, - defaultContent: , - disabled: user.data.roles.indexOf("EDIT") === -1, - hoverContent: getTooltipWrapper( - <> - {t("upload")} - , - ), - }, - { - id: "layers-button", - onClick: handleToggleLayers, - sx: isLayersPanelVisible ? selectedButtonStyle : {}, - defaultContent: , - hoverContent: getTooltipWrapper( - <> - - {t("usersMap")} - , - ), - }, - ]; - - const bottomButtonData: ButtonContentInterface[] = [ - { - id: "settings-button", - onClick: () => history.push(`/setting`), - sx: {}, - defaultContent: , - hoverContent: getTooltipWrapper( - <> - {t("header_settings")} - , - ), - }, - { - id: "help-button", - onClick: () => window.open(`/help`), - sx: {}, - defaultContent: , - hoverContent: getTooltipWrapper( - <> - {t("header_help")} - , - ), - }, - ]; - return ( {activeFilterCount > 0 && } - {topButtonData.map(button => ( - setHoveredButtonId(button.id)} - onMouseLeave={() => setHoveredButtonId(null)} - disabled={button.disabled} - sx={button.sx}> - {hoveredButtonId === button.id ? button.hoverContent : button.defaultContent} - - ))} + } + label={t("searchfilters")} + selected={isFilterPanelVisible} + onClick={handleToggleFilter} + /> + } + label={t("add")} + selected={isAddPanelVisible} + disabled={user.data.roles.indexOf("EDIT") === -1} + onClick={handleToggleAdd} + /> + } + label={t("upload")} + disabled={user.data.roles.indexOf("EDIT") === -1} + onClick={() => { + toggleDrawer(false); + setModal(true); + setUpload(true); + }} + /> + } + label={t("usersMap")} + selected={isLayersPanelVisible} + onClick={handleToggleLayers} + /> - {bottomButtonData.map(button => ( - setHoveredButtonId(button.id)} - onMouseLeave={() => setHoveredButtonId(null)} - sx={button.sx}> - {hoveredButtonId === button.id ? button.hoverContent : button.defaultContent} - - ))} + } + label={t("header_settings")} + onClick={() => history.push(`/setting`)} + /> + } + label={t("header_help")} + onClick={() => window.open(`/help`)} + /> ((props, ref) => { + const [isHovered, setIsHovered] = useState(false); + + const handleMouseEnter = () => setIsHovered(true); + const handleMouseLeave = () => setIsHovered(false); + + const defaultContent = props.icon; + const hoverContent = ( + <> + {props.icon} {props.label} + + ); + + return ( + + + {isHovered ? hoverContent : defaultContent} + + + ); +}); From 37ed5e9e3d3b04600a1ea200a758e17d0e5988af Mon Sep 17 00:00:00 2001 From: tschumpr Date: Fri, 19 Jul 2024 14:45:14 +0200 Subject: [PATCH 5/8] Remove unused code --- src/client/src/commons/menu/mainView/mainSideNav.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/client/src/commons/menu/mainView/mainSideNav.tsx b/src/client/src/commons/menu/mainView/mainSideNav.tsx index 9e79a8963..4a3ad3e19 100644 --- a/src/client/src/commons/menu/mainView/mainSideNav.tsx +++ b/src/client/src/commons/menu/mainView/mainSideNav.tsx @@ -39,7 +39,6 @@ const MainSideNav = ({ const [selectedBoreholeAttachments, setSelectedBoreholeAttachments] = useState(null); const [selectedLithologyFile, setSelectedLithologyFile] = useState(null); const [errorsResponse, setErrorsResponse] = useState(null); - const [hoveredButtonId, setHoveredButtonId] = useState(null); const filterContext = useContext(FilterContext); // Redux state From 6888e409b99941e1268e98906b207f56c70745ed Mon Sep 17 00:00:00 2001 From: tschumpr Date: Fri, 19 Jul 2024 15:00:48 +0200 Subject: [PATCH 6/8] Fix setting data-cy --- src/client/src/commons/menu/mainView/mainSideNav.tsx | 12 ++++++------ src/client/src/components/buttons/navButton.tsx | 6 ++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/client/src/commons/menu/mainView/mainSideNav.tsx b/src/client/src/commons/menu/mainView/mainSideNav.tsx index 4a3ad3e19..f21b501ca 100644 --- a/src/client/src/commons/menu/mainView/mainSideNav.tsx +++ b/src/client/src/commons/menu/mainView/mainSideNav.tsx @@ -101,14 +101,14 @@ const MainSideNav = ({ }}> {activeFilterCount > 0 && } } label={t("searchfilters")} selected={isFilterPanelVisible} onClick={handleToggleFilter} /> } label={t("add")} selected={isAddPanelVisible} @@ -116,7 +116,7 @@ const MainSideNav = ({ onClick={handleToggleAdd} /> } label={t("upload")} disabled={user.data.roles.indexOf("EDIT") === -1} @@ -127,7 +127,7 @@ const MainSideNav = ({ }} /> } label={t("usersMap")} selected={isLayersPanelVisible} @@ -140,13 +140,13 @@ const MainSideNav = ({ padding: "1em", }}> } label={t("header_settings")} onClick={() => history.push(`/setting`)} /> } label={t("header_help")} onClick={() => window.open(`/help`)} diff --git a/src/client/src/components/buttons/navButton.tsx b/src/client/src/components/buttons/navButton.tsx index c9aa83cfb..2fd5aee87 100644 --- a/src/client/src/components/buttons/navButton.tsx +++ b/src/client/src/components/buttons/navButton.tsx @@ -4,7 +4,8 @@ import { IconButton, Stack, Typography } from "@mui/material"; import { theme } from "../../AppTheme"; export interface NavButtonProps extends ButtonProps { - key: string; + label: string; + icon: JSX.Element; selected?: boolean; } @@ -20,13 +21,10 @@ export const NavButton = forwardRef((props, r {props.icon} {props.label} ); - return ( Date: Thu, 25 Jul 2024 11:02:17 +0200 Subject: [PATCH 7/8] Update badge style to match figma --- src/client/src/AppTheme.ts | 10 +++++++++- src/client/src/commons/menu/mainView/mainSideNav.tsx | 2 +- .../src/commons/search/editor/filterComponent.jsx | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/client/src/AppTheme.ts b/src/client/src/AppTheme.ts index 7ec3f81a2..9fffda9b8 100644 --- a/src/client/src/AppTheme.ts +++ b/src/client/src/AppTheme.ts @@ -43,7 +43,7 @@ export const theme = createTheme({ lightgrey: "#f1f3f5", darkgrey: "#787878", dark: "rgba(0, 0, 0, 0.5)", - menuItemActive: "#D92B04", + menuItemActive: "#A65462", filterItemActive: "#1C2834", }, @@ -135,5 +135,13 @@ export const theme = createTheme({ }, }, }, + MuiBadge: { + styleOverrides: { + badge: { + backgroundColor: "#FF0000", + color: "#FFFFFF", + }, + }, + }, }, }); diff --git a/src/client/src/commons/menu/mainView/mainSideNav.tsx b/src/client/src/commons/menu/mainView/mainSideNav.tsx index f21b501ca..225d47fd4 100644 --- a/src/client/src/commons/menu/mainView/mainSideNav.tsx +++ b/src/client/src/commons/menu/mainView/mainSideNav.tsx @@ -99,7 +99,7 @@ const MainSideNav = ({ padding: "1em", flex: "1 1 100%", }}> - {activeFilterCount > 0 && } + {activeFilterCount > 0 && } } diff --git a/src/client/src/commons/search/editor/filterComponent.jsx b/src/client/src/commons/search/editor/filterComponent.jsx index 14929512b..99af9ec6d 100644 --- a/src/client/src/commons/search/editor/filterComponent.jsx +++ b/src/client/src/commons/search/editor/filterComponent.jsx @@ -226,7 +226,7 @@ class FilterComponent extends React.Component { {t("polygon_selection")} {filterPolygon !== null && ( - + )} {this.state?.searchList?.map((filter, idx) => { @@ -248,7 +248,7 @@ class FilterComponent extends React.Component { }}> {t(filter?.translationId)}{" "} - + {filter?.name === "workgroup" && filter?.isSelected && ( From 40a508a397cbf0b02ec4116e3d5225a7ecf8161a Mon Sep 17 00:00:00 2001 From: tschumpr Date: Thu, 25 Jul 2024 15:16:53 +0200 Subject: [PATCH 8/8] Center badge number --- src/client/src/commons/search/editor/filterComponent.jsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/client/src/commons/search/editor/filterComponent.jsx b/src/client/src/commons/search/editor/filterComponent.jsx index 99af9ec6d..a16e32c38 100644 --- a/src/client/src/commons/search/editor/filterComponent.jsx +++ b/src/client/src/commons/search/editor/filterComponent.jsx @@ -24,6 +24,7 @@ import { FilterContext } from "../../../components/filter/filterContext.tsx"; class FilterComponent extends React.Component { static contextType = FilterContext; + constructor(props) { super(props); this.handleFilterReset = this.handleFilterReset.bind(this); @@ -226,7 +227,7 @@ class FilterComponent extends React.Component { {t("polygon_selection")} {filterPolygon !== null && ( - + )} {this.state?.searchList?.map((filter, idx) => { @@ -246,10 +247,8 @@ class FilterComponent extends React.Component { ), })); }}> - - {t(filter?.translationId)}{" "} - - + {t(filter?.translationId)} + {filter?.name === "workgroup" && filter?.isSelected && (