File tree Expand file tree Collapse file tree 3 files changed +20
-13
lines changed Expand file tree Collapse file tree 3 files changed +20
-13
lines changed Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2- import { Route , Routes } from 'react-router-dom' ;
2+ import { Route , Routes , Navigate } from 'react-router-dom' ;
33import { AppRoutePaths } from '~/app/routes' ;
44import { WorkspaceForm } from '~/app/pages/Workspaces/Form/WorkspaceForm' ;
55import { NotFound } from './pages/notFound/NotFound' ;
@@ -64,7 +64,7 @@ const AppRoutes: React.FC = () => {
6464 < Route path = { AppRoutePaths . workspaceEdit } element = { < WorkspaceForm /> } />
6565 < Route path = { AppRoutePaths . workspaces } element = { < Workspaces /> } />
6666 < Route path = { AppRoutePaths . workspaceKinds } element = { < WorkspaceKinds /> } />
67- < Route path = "/" element = { < Workspaces /> } />
67+ < Route path = "/" element = { < Navigate to = { AppRoutePaths . workspaces } replace /> } />
6868 < Route path = "*" element = { < NotFound /> } />
6969 {
7070 // TODO: Remove the linter skip when we implement authentication
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2- import { NavLink } from 'react-router-dom' ;
2+ import { NavLink , useLocation } from 'react-router-dom' ;
33import {
44 Brand ,
55 Nav ,
@@ -12,13 +12,20 @@ import {
1212import { useNavData , isNavDataGroup , NavDataHref , NavDataGroup } from './AppRoutes' ;
1313import { isMUITheme , LOGO_LIGHT } from './const' ;
1414
15- const NavHref : React . FC < { item : NavDataHref } > = ( { item } ) => (
16- < NavItem key = { item . label } data-id = { item . label } itemId = { item . label } >
17- < NavLink to = { item . path } data-testid = { `nav-link-${ item . path } ` } >
18- { item . label }
19- </ NavLink >
20- </ NavItem >
21- ) ;
15+ const NavHref : React . FC < { item : NavDataHref } > = ( { item } ) => {
16+ const location = useLocation ( ) ;
17+
18+ // With the redirect in place, we can now use a simple path comparison.
19+ const isActive = location . pathname === item . path ;
20+
21+ return (
22+ < NavItem isActive = { isActive } key = { item . label } data-id = { item . label } itemId = { item . label } >
23+ < NavLink to = { item . path } data-testid = { `nav-link-${ item . path } ` } >
24+ { item . label }
25+ </ NavLink >
26+ </ NavItem >
27+ ) ;
28+ } ;
2229
2330const NavGroup : React . FC < { item : NavDataGroup } > = ( { item } ) => {
2431 const { children } = item ;
Original file line number Diff line number Diff line change 543543 --pf-v6-c-nav__link--hover--Color : var (--kf-central-sidebar-default-color );
544544 --pf-v6-c-nav__link--FontSize : var (--pf-t--global--font--size--md );
545545
546- & .active {
546+ & .pf-m-current {
547547 border-left : 3px solid var (--mui-palette-common-white );
548- --pf-v6-c-nav__link--Color : var ( --mui-palette-common-white ) ;
549- --pf-v6-c-nav__link--hover --Color : var (--mui-palette-common-white );
548+ --pf-v6-c-nav__link--m-current--BackgroundColor : #ffffff1b ;
549+ --pf-v6-c-nav__link--m-current --Color : var (--mui-palette-common-white );
550550 }
551551
552552 & .pf-v6-c-brand {
You can’t perform that action at this time.
0 commit comments