1
1
import React , { useContext , useState } from "react" ;
2
2
3
3
import { EuiIcon , EuiSideNav , htmlIdGenerator } from "@elastic/eui" ;
4
- import { useNavigate , useParams } from "react-router-dom" ;
4
+ import { Link , useParams } from "react-router-dom" ;
5
5
import { useMatchSubpath } from "../hooks/useMatchSubpath" ;
6
6
import useLoadRegistry from "../queries/useLoadRegistry" ;
7
7
import RegistryPathContext from "../contexts/RegistryPathContext" ;
@@ -19,8 +19,6 @@ const SideNav = () => {
19
19
20
20
const [ isSideNavOpenOnMobile , setisSideNavOpenOnMobile ] = useState ( false ) ;
21
21
22
- const navigate = useNavigate ( ) ;
23
-
24
22
const toggleOpenOnMobile = ( ) => {
25
23
setisSideNavOpenOnMobile ( ! isSideNavOpenOnMobile ) ;
26
24
} ;
@@ -57,57 +55,45 @@ const SideNav = () => {
57
55
58
56
const baseUrl = `${ process . env . PUBLIC_URL || "" } /p/${ projectName } ` ;
59
57
60
- const sideNav = [
58
+ const sideNav : React . ComponentProps < typeof EuiSideNav > [ 'items' ] = [
61
59
{
62
60
name : "Home" ,
63
61
id : htmlIdGenerator ( "basicExample" ) ( ) ,
64
- onClick : ( ) => {
65
- navigate ( `${ baseUrl } /` ) ;
66
- } ,
62
+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /` } /> ,
67
63
items : [
68
64
{
69
65
name : dataSourcesLabel ,
70
66
id : htmlIdGenerator ( "dataSources" ) ( ) ,
71
67
icon : < EuiIcon type = { DataSourceIcon } /> ,
72
- onClick : ( ) => {
73
- navigate ( `${ baseUrl } /data-source` ) ;
74
- } ,
68
+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /data-source` } /> ,
75
69
isSelected : useMatchSubpath ( `${ baseUrl } /data-source` ) ,
76
70
} ,
77
71
{
78
72
name : entitiesLabel ,
79
73
id : htmlIdGenerator ( "entities" ) ( ) ,
80
74
icon : < EuiIcon type = { EntityIcon } /> ,
81
- onClick : ( ) => {
82
- navigate ( `${ baseUrl } /entity` ) ;
83
- } ,
75
+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /entity` } /> ,
84
76
isSelected : useMatchSubpath ( `${ baseUrl } /entity` ) ,
85
77
} ,
86
78
{
87
79
name : featureViewsLabel ,
88
80
id : htmlIdGenerator ( "featureView" ) ( ) ,
89
81
icon : < EuiIcon type = { FeatureViewIcon } /> ,
90
- onClick : ( ) => {
91
- navigate ( `${ baseUrl } /feature-view` ) ;
92
- } ,
82
+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /feature-view` } /> ,
93
83
isSelected : useMatchSubpath ( `${ baseUrl } /feature-view` ) ,
94
84
} ,
95
85
{
96
86
name : featureServicesLabel ,
97
87
id : htmlIdGenerator ( "featureService" ) ( ) ,
98
88
icon : < EuiIcon type = { FeatureServiceIcon } /> ,
99
- onClick : ( ) => {
100
- navigate ( `${ baseUrl } /feature-service` ) ;
101
- } ,
89
+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /feature-service` } /> ,
102
90
isSelected : useMatchSubpath ( `${ baseUrl } /feature-service` ) ,
103
91
} ,
104
92
{
105
93
name : savedDatasetsLabel ,
106
94
id : htmlIdGenerator ( "savedDatasets" ) ( ) ,
107
95
icon : < EuiIcon type = { DatasetIcon } /> ,
108
- onClick : ( ) => {
109
- navigate ( `${ baseUrl } /data-set` ) ;
110
- } ,
96
+ renderItem : props => < Link { ...props } to = { `${ baseUrl } /data-set` } /> ,
111
97
isSelected : useMatchSubpath ( `${ baseUrl } /data-set` ) ,
112
98
} ,
113
99
] ,
0 commit comments