From 78164054d46fe367ceae15922f6eed2c5c8dfec7 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Wed, 1 Nov 2023 09:54:14 -0600 Subject: [PATCH] Updated HelpMenu components to use only mds subcomponents (#3119) Signed-off-by: Benjamin Perez --- portal-ui/src/common/MoreLink.tsx | 35 ++-- portal-ui/src/screens/Console/HelpItem.tsx | 32 ++-- portal-ui/src/screens/Console/HelpMenu.tsx | 198 ++++++++++----------- portal-ui/src/screens/shared/tabs.tsx | 40 ----- 4 files changed, 125 insertions(+), 180 deletions(-) delete mode 100644 portal-ui/src/screens/shared/tabs.tsx diff --git a/portal-ui/src/common/MoreLink.tsx b/portal-ui/src/common/MoreLink.tsx index e3c4df8f4..2ed53b939 100644 --- a/portal-ui/src/common/MoreLink.tsx +++ b/portal-ui/src/common/MoreLink.tsx @@ -15,7 +15,7 @@ // along with this program. If not, see . import React from "react"; -import { ArrowIcon } from "mds"; +import { ArrowIcon, Box } from "mds"; const MoreLink = ({ LeadingIcon, @@ -39,8 +39,8 @@ const MoreLink = ({ href={link} target={"_blank"} > -
{LeadingIcon && ( -
- {/*@ts-ignore*/} - -
+ + + )} -
+ {text} -
-
+ -
-
+ + ); }; diff --git a/portal-ui/src/screens/Console/HelpItem.tsx b/portal-ui/src/screens/Console/HelpItem.tsx index 6ee4b191c..18b21307b 100644 --- a/portal-ui/src/screens/Console/HelpItem.tsx +++ b/portal-ui/src/screens/Console/HelpItem.tsx @@ -31,37 +31,27 @@ const HelpItem = ({ item, displayImage = true }: IHelpItemProps) => { style={{ display: "flex", flexDirection: "row", - flexWrap: "nowrap", - marginBottom: 20, }} > {displayImage && ( -
+
-
- {item.title} -
+ />
)} -
+
. import React, { Fragment, useEffect, useRef, useState } from "react"; -import { MenuItem, Paper, Tab, Tabs } from "@mui/material"; -import HelpItem from "./HelpItem"; +import ReactMarkdown from "react-markdown"; +import styled from "styled-components"; +import get from "lodash/get"; import { AlertCloseIcon, Box, @@ -25,14 +26,42 @@ import { HelpIconFilled, IconButton, MinIOTierIcon, + TabItemProps, + Tabs, } from "mds"; import { useSelector } from "react-redux"; import { AppState, useAppDispatch } from "../../store"; -import { TabPanel } from "../shared/tabs"; import { setHelpTabName } from "../../systemSlice"; import { DocItem } from "./HelpMenu.types"; +import HelpItem from "./HelpItem"; import MoreLink from "../../common/MoreLink"; -import ReactMarkdown from "react-markdown"; + +const HelpMenuContainer = styled.div(({ theme }) => ({ + backgroundColor: get(theme, "bgColor", "#FFF"), + position: "absolute", + zIndex: "10", + border: `${get(theme, "borderColor", "#E2E2E2")} 1px solid`, + borderRadius: 4, + boxShadow: "rgba(0, 0, 0, 0.1) 0px 0px 10px", + width: 754, + "& .tabsPanels": { + padding: "15px 0 0", + }, + "& .helpContainer": { + maxHeight: 400, + overflowY: "auto", + "& .helpItemBlock": { + padding: 5, + "&:hover": { + backgroundColor: get( + theme, + "buttons.regular.hover.background", + "#E6EAEB", + ), + }, + }, + }, +})); const HelpMenu = () => { const helpTopics = require("../Console/helpTopics.json"); @@ -73,7 +102,7 @@ const HelpMenu = () => { }, [ref]); } - const wrapperRef = useRef(null); + const wrapperRef = useRef(null); useOutsideAlerter(wrapperRef); useEffect(() => { @@ -148,7 +177,7 @@ const HelpMenu = () => { ]); const helpContent = ( - + {headerDocs && (
@@ -159,9 +188,9 @@ const HelpMenu = () => { )} {helpItems && helpItems.map((aHelpItem, idx) => ( - + - + ))}
{ color={"#C5293F"} />
- + ); const helpContentVideo = ( - + {headerVideo && (
@@ -185,9 +214,9 @@ const HelpMenu = () => { )} {helpItemsVideo && helpItemsVideo.map((aHelpItem, idx) => ( - + - + ))}
{ color={"#C5293F"} />
- + ); const helpContentBlog = ( - + {headerBlog && (
@@ -211,9 +240,9 @@ const HelpMenu = () => { )} {helpItemsBlog && helpItemsBlog.map((aHelpItem, idx) => ( - + - + ))}
{ color={"#C5293F"} />
- + ); - function a11yProps(index: any) { - return { - id: `simple-tab-${index}`, - "aria-controls": `simple-tabpanel-${index}`, - style: { - fontWeight: "bold", - }, - }; - } + const constructHMTabs = () => { + const helpMenuElements: TabItemProps[] = []; + + if (helpItems.length !== 0) { + helpMenuElements.push({ + tabConfig: { label: "Documentation", id: "docs" }, + content: helpContent, + }); + } + + if (helpItemsVideo.length !== 0) { + helpMenuElements.push({ + tabConfig: { label: "Video", id: "video" }, + content: helpContentVideo, + }); + } + + if (helpItemsBlog.length !== 0) { + helpMenuElements.push({ + tabConfig: { label: "Blog", id: "blog" }, + content: helpContentBlog, + }); + } + + return helpMenuElements; + }; return ( {helpMenuOpen && ( -
- -
-
- -
-
- , newValue: string) => { - dispatch(setHelpTabName(newValue)); - }} - indicatorColor="primary" - textColor="primary" - aria-label="cluster-tabs" - variant="scrollable" - scrollButtons="auto" - > - {helpItems.length !== 0 && ( - - )} - {helpItemsVideo.length !== 0 && ( - - )} - {helpItemsBlog.length !== 0 && ( - - )} - -
-
+ + dispatch(setHelpTabName(item))} + optionsInitialComponent={ + + + + } + optionsEndComponent={ + { setHelpMenuOpen(false); @@ -301,32 +307,12 @@ const HelpMenu = () => { > -
-
- - {helpItems.length !== 0 && ( - - {helpContent} - - )} - {helpItemsVideo.length !== 0 && ( - - {helpContentVideo} - - )} - {helpItemsBlog.length !== 0 && ( - - {helpContentBlog} - - )} - -
-
+ + } + horizontalBarBackground + horizontal + /> + )}