Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions portal-ui/src/screens/Console/Common/VerticalTabs/VerticalTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from "react";
import React, { useState, useEffect } from "react";
import { Box, Tab, TabProps } from "@mui/material";
import { TabContext, TabList, TabPanel } from "@mui/lab";
import withStyles from "@mui/styles/withStyles";
import { Theme, useTheme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
import useMediaQuery from "@mui/material/useMediaQuery";
import { useLocation } from "react-router-dom";

export type TabItemProps = {
tabConfig: TabProps | any;
Expand Down Expand Up @@ -91,25 +92,39 @@ const VerticalTabs = ({
routes,
isRouteTabs,
}: VerticalTabsProps) => {
const [value, setValue] = React.useState(selectedTab);

const theme = useTheme();
const { pathname = "" } = useLocation();

const isSmallScreen = useMediaQuery(theme.breakpoints.down("md"));

const handleChange = (event: React.SyntheticEvent, newValue: string) => {
setValue(newValue);
};
const [value, setValue] = useState(selectedTab);

const headerList: TabProps[] = [];
const contentList: React.ReactNode[] = [];

useEffect(() => {
if (isRouteTabs) {
const tabConfigElement = children.find(
(item) => item.tabConfig.to === pathname
);

if (tabConfigElement) {
setValue(tabConfigElement.tabConfig.value);
}
}
}, [isRouteTabs, children, pathname]);

if (!children) return null;

children.forEach((child) => {
headerList.push(child.tabConfig);
contentList.push(child.content);
});

const handleChange = (event: React.SyntheticEvent, newValue: string) => {
setValue(newValue);
};

return (
<TabContext value={`${value}`}>
<Box className={classes.tabsContainer}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const TenantListItem = ({ tenant, classes }: ITenantListItem) => {
})
);
dispatch(getTenantAsync());
navigate(`/namespaces/${tenant.namespace}/tenants/${tenant.name}`);
navigate(`/namespaces/${tenant.namespace}/tenants/${tenant.name}/summary`);
};

return (
Expand Down