Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Render UI navigation items as links instead of buttons #4970

Merged
merged 1 commit into from
Jan 28, 2025
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
4 changes: 2 additions & 2 deletions ui/src/FeastUISansProviders.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand All @@ -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",
Expand Down
30 changes: 8 additions & 22 deletions ui/src/pages/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -19,8 +19,6 @@ const SideNav = () => {

const [isSideNavOpenOnMobile, setisSideNavOpenOnMobile] = useState(false);

const navigate = useNavigate();

const toggleOpenOnMobile = () => {
setisSideNavOpenOnMobile(!isSideNavOpenOnMobile);
};
Expand Down Expand Up @@ -57,57 +55,45 @@ const SideNav = () => {

const baseUrl = `${process.env.PUBLIC_URL || ""}/p/${projectName}`;

const sideNav = [
const sideNav: React.ComponentProps<typeof EuiSideNav>['items'] = [
{
name: "Home",
id: htmlIdGenerator("basicExample")(),
onClick: () => {
navigate(`${baseUrl}/`);
},
renderItem: props => <Link {...props} to={`${baseUrl}/`} />,
items: [
{
name: dataSourcesLabel,
id: htmlIdGenerator("dataSources")(),
icon: <EuiIcon type={DataSourceIcon} />,
onClick: () => {
navigate(`${baseUrl}/data-source`);
},
renderItem: props => <Link {...props} to={`${baseUrl}/data-source`} />,
isSelected: useMatchSubpath(`${baseUrl}/data-source`),
},
{
name: entitiesLabel,
id: htmlIdGenerator("entities")(),
icon: <EuiIcon type={EntityIcon} />,
onClick: () => {
navigate(`${baseUrl}/entity`);
},
renderItem: props => <Link {...props} to={`${baseUrl}/entity`} />,
isSelected: useMatchSubpath(`${baseUrl}/entity`),
},
{
name: featureViewsLabel,
id: htmlIdGenerator("featureView")(),
icon: <EuiIcon type={FeatureViewIcon} />,
onClick: () => {
navigate(`${baseUrl}/feature-view`);
},
renderItem: props => <Link {...props} to={`${baseUrl}/feature-view`} />,
isSelected: useMatchSubpath(`${baseUrl}/feature-view`),
},
{
name: featureServicesLabel,
id: htmlIdGenerator("featureService")(),
icon: <EuiIcon type={FeatureServiceIcon} />,
onClick: () => {
navigate(`${baseUrl}/feature-service`);
},
renderItem: props => <Link {...props} to={`${baseUrl}/feature-service`} />,
isSelected: useMatchSubpath(`${baseUrl}/feature-service`),
},
{
name: savedDatasetsLabel,
id: htmlIdGenerator("savedDatasets")(),
icon: <EuiIcon type={DatasetIcon} />,
onClick: () => {
navigate(`${baseUrl}/data-set`);
},
renderItem: props => <Link {...props} to={`${baseUrl}/data-set`} />,
isSelected: useMatchSubpath(`${baseUrl}/data-set`),
},
],
Expand Down
Loading