diff --git a/ui/src/FeastUISansProviders.test.tsx b/ui/src/FeastUISansProviders.test.tsx index 4b1446f889..94bd2dfbe3 100644 --- a/ui/src/FeastUISansProviders.test.tsx +++ b/ui/src/FeastUISansProviders.test.tsx @@ -89,7 +89,7 @@ test("routes are reachable", async () => { const routeRegExp = new RegExp(routeName, "i"); - await user.click(screen.getByRole("button", { name: routeRegExp })); + await user.click(screen.getByRole("link", { name: routeRegExp })); // Should land on a page with the heading screen.getByRole("heading", { @@ -112,7 +112,7 @@ test("features are reachable", async () => { await screen.findByText(/Explore this Project/i); const routeRegExp = new RegExp("Feature Views", "i"); - await user.click(screen.getByRole("button", { name: routeRegExp })); + await user.click(screen.getByRole("link", { name: routeRegExp })); screen.getByRole("heading", { name: "Feature Views", diff --git a/ui/src/pages/Sidebar.tsx b/ui/src/pages/Sidebar.tsx index fbd1a8cf22..de98b21324 100644 --- a/ui/src/pages/Sidebar.tsx +++ b/ui/src/pages/Sidebar.tsx @@ -1,7 +1,7 @@ import React, { useContext, useState } from "react"; import { EuiIcon, EuiSideNav, htmlIdGenerator } from "@elastic/eui"; -import { useNavigate, useParams } from "react-router-dom"; +import { Link, useParams } from "react-router-dom"; import { useMatchSubpath } from "../hooks/useMatchSubpath"; import useLoadRegistry from "../queries/useLoadRegistry"; import RegistryPathContext from "../contexts/RegistryPathContext"; @@ -19,8 +19,6 @@ const SideNav = () => { const [isSideNavOpenOnMobile, setisSideNavOpenOnMobile] = useState(false); - const navigate = useNavigate(); - const toggleOpenOnMobile = () => { setisSideNavOpenOnMobile(!isSideNavOpenOnMobile); }; @@ -57,57 +55,45 @@ const SideNav = () => { const baseUrl = `${process.env.PUBLIC_URL || ""}/p/${projectName}`; - const sideNav = [ + const sideNav: React.ComponentProps['items'] = [ { name: "Home", id: htmlIdGenerator("basicExample")(), - onClick: () => { - navigate(`${baseUrl}/`); - }, + renderItem: props => , items: [ { name: dataSourcesLabel, id: htmlIdGenerator("dataSources")(), icon: , - onClick: () => { - navigate(`${baseUrl}/data-source`); - }, + renderItem: props => , isSelected: useMatchSubpath(`${baseUrl}/data-source`), }, { name: entitiesLabel, id: htmlIdGenerator("entities")(), icon: , - onClick: () => { - navigate(`${baseUrl}/entity`); - }, + renderItem: props => , isSelected: useMatchSubpath(`${baseUrl}/entity`), }, { name: featureViewsLabel, id: htmlIdGenerator("featureView")(), icon: , - onClick: () => { - navigate(`${baseUrl}/feature-view`); - }, + renderItem: props => , isSelected: useMatchSubpath(`${baseUrl}/feature-view`), }, { name: featureServicesLabel, id: htmlIdGenerator("featureService")(), icon: , - onClick: () => { - navigate(`${baseUrl}/feature-service`); - }, + renderItem: props => , isSelected: useMatchSubpath(`${baseUrl}/feature-service`), }, { name: savedDatasetsLabel, id: htmlIdGenerator("savedDatasets")(), icon: , - onClick: () => { - navigate(`${baseUrl}/data-set`); - }, + renderItem: props => , isSelected: useMatchSubpath(`${baseUrl}/data-set`), }, ],