11import React , { useContext , useState } from "react" ;
22
33import { EuiIcon , EuiSideNav , htmlIdGenerator } from "@elastic/eui" ;
4- import { useNavigate , useParams } from "react-router-dom" ;
4+ import { Link , useParams } from "react-router-dom" ;
55import { useMatchSubpath } from "../hooks/useMatchSubpath" ;
66import useLoadRegistry from "../queries/useLoadRegistry" ;
77import RegistryPathContext from "../contexts/RegistryPathContext" ;
@@ -19,8 +19,6 @@ const SideNav = () => {
1919
2020 const [ isSideNavOpenOnMobile , setisSideNavOpenOnMobile ] = useState ( false ) ;
2121
22- const navigate = useNavigate ( ) ;
23-
2422 const toggleOpenOnMobile = ( ) => {
2523 setisSideNavOpenOnMobile ( ! isSideNavOpenOnMobile ) ;
2624 } ;
@@ -57,57 +55,45 @@ const SideNav = () => {
5755
5856 const baseUrl = `${ process . env . PUBLIC_URL || "" } /p/${ projectName } ` ;
5957
60- const sideNav = [
58+ const sideNav : React . ComponentProps < typeof EuiSideNav > [ 'items' ] = [
6159 {
6260 name : "Home" ,
6361 id : htmlIdGenerator ( "basicExample" ) ( ) ,
64- onClick : ( ) => {
65- navigate ( `${ baseUrl } /` ) ;
66- } ,
62+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /` } /> ,
6763 items : [
6864 {
6965 name : dataSourcesLabel ,
7066 id : htmlIdGenerator ( "dataSources" ) ( ) ,
7167 icon : < EuiIcon type = { DataSourceIcon } /> ,
72- onClick : ( ) => {
73- navigate ( `${ baseUrl } /data-source` ) ;
74- } ,
68+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /data-source` } /> ,
7569 isSelected : useMatchSubpath ( `${ baseUrl } /data-source` ) ,
7670 } ,
7771 {
7872 name : entitiesLabel ,
7973 id : htmlIdGenerator ( "entities" ) ( ) ,
8074 icon : < EuiIcon type = { EntityIcon } /> ,
81- onClick : ( ) => {
82- navigate ( `${ baseUrl } /entity` ) ;
83- } ,
75+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /entity` } /> ,
8476 isSelected : useMatchSubpath ( `${ baseUrl } /entity` ) ,
8577 } ,
8678 {
8779 name : featureViewsLabel ,
8880 id : htmlIdGenerator ( "featureView" ) ( ) ,
8981 icon : < EuiIcon type = { FeatureViewIcon } /> ,
90- onClick : ( ) => {
91- navigate ( `${ baseUrl } /feature-view` ) ;
92- } ,
82+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /feature-view` } /> ,
9383 isSelected : useMatchSubpath ( `${ baseUrl } /feature-view` ) ,
9484 } ,
9585 {
9686 name : featureServicesLabel ,
9787 id : htmlIdGenerator ( "featureService" ) ( ) ,
9888 icon : < EuiIcon type = { FeatureServiceIcon } /> ,
99- onClick : ( ) => {
100- navigate ( `${ baseUrl } /feature-service` ) ;
101- } ,
89+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /feature-service` } /> ,
10290 isSelected : useMatchSubpath ( `${ baseUrl } /feature-service` ) ,
10391 } ,
10492 {
10593 name : savedDatasetsLabel ,
10694 id : htmlIdGenerator ( "savedDatasets" ) ( ) ,
10795 icon : < EuiIcon type = { DatasetIcon } /> ,
108- onClick : ( ) => {
109- navigate ( `${ baseUrl } /data-set` ) ;
110- } ,
96+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /data-set` } /> ,
11197 isSelected : useMatchSubpath ( `${ baseUrl } /data-set` ) ,
11298 } ,
11399 ] ,
0 commit comments