diff --git a/ui/src/pages/Sidebar.tsx b/ui/src/pages/Sidebar.tsx index dac02709ba6..fbd1a8cf22e 100644 --- a/ui/src/pages/Sidebar.tsx +++ b/ui/src/pages/Sidebar.tsx @@ -55,12 +55,14 @@ const SideNav = () => { : "" }`; + const baseUrl = `${process.env.PUBLIC_URL || ""}/p/${projectName}`; + const sideNav = [ { name: "Home", id: htmlIdGenerator("basicExample")(), onClick: () => { - navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/`); + navigate(`${baseUrl}/`); }, items: [ { @@ -68,45 +70,45 @@ const SideNav = () => { id: htmlIdGenerator("dataSources")(), icon: , onClick: () => { - navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-source`); + navigate(`${baseUrl}/data-source`); }, - isSelected: useMatchSubpath("data-source"), + isSelected: useMatchSubpath(`${baseUrl}/data-source`), }, { name: entitiesLabel, id: htmlIdGenerator("entities")(), icon: , onClick: () => { - navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/entity`); + navigate(`${baseUrl}/entity`); }, - isSelected: useMatchSubpath("entity"), + isSelected: useMatchSubpath(`${baseUrl}/entity`), }, { name: featureViewsLabel, id: htmlIdGenerator("featureView")(), icon: , onClick: () => { - navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-view`); + navigate(`${baseUrl}/feature-view`); }, - isSelected: useMatchSubpath("feature-view"), + isSelected: useMatchSubpath(`${baseUrl}/feature-view`), }, { name: featureServicesLabel, id: htmlIdGenerator("featureService")(), icon: , onClick: () => { - navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/feature-service`); + navigate(`${baseUrl}/feature-service`); }, - isSelected: useMatchSubpath("feature-service"), + isSelected: useMatchSubpath(`${baseUrl}/feature-service`), }, { name: savedDatasetsLabel, id: htmlIdGenerator("savedDatasets")(), icon: , onClick: () => { - navigate(`${process.env.PUBLIC_URL || ""}/p/${projectName}/data-set`); + navigate(`${baseUrl}/data-set`); }, - isSelected: useMatchSubpath("data-set"), + isSelected: useMatchSubpath(`${baseUrl}/data-set`), }, ], },