Skip to content

Commit 3ecc245

Browse files
authored
Merge pull request #116 from topcoder-platform/PROD-2333_work-link
PROD 2333 work link not having underline -> Dev
2 parents d89ae47 + a0514fb commit 3ecc245

File tree

6 files changed

+11
-24
lines changed

6 files changed

+11
-24
lines changed

src-ts/header/tool-selectors/tool-selectors-narrow/tool-selector-narrow/ToolSelectorNarrow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ToolSelectorNarrow: FC<ToolSelectorNarrowProps> = (props: ToolSelectorNarr
2222
const toolPath: string = getPathFromRoute(toolRoute)
2323

2424
const baseClass: string = 'tool-selector-narrow'
25-
const isActive: boolean = isActiveRoute(useLocation().pathname, toolPath)
25+
const isActive: boolean = isActiveRoute(useLocation().pathname, toolRoute)
2626
const activeIndicaterClass: string = `${baseClass}-${isActive ? '' : 'in'}active`
2727
const hasChildren: boolean = !!toolRoute.children.some(child => !!child.route && !isParamRoute(child.route))
2828

src-ts/header/tool-selectors/tool-selectors-wide/tool-selector-wide/ToolSelectorWide.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const ToolSelectorWide: FC<ToolSelectorWideProps> = (props: ToolSelectorWideProp
2626
const toolRoute: PlatformRoute = props.route
2727
const toolPath: string = getPathFromRoute(toolRoute)
2828

29-
const isActive: boolean = isActiveRoute(activePath, toolPath)
29+
const isActive: boolean = isActiveRoute(activePath, toolRoute)
3030

3131
const activeIndicatorClass: string = `tool-selector-wide-${isActive ? '' : 'in'}active`
3232

src-ts/lib/route-provider/platform-route.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { FC, SVGProps } from 'react'
22

33
export interface PlatformRoute {
4+
alternativePaths?: Array<string>
45
children?: Array<PlatformRoute>
56
disabled?: boolean
67
element: JSX.Element

src-ts/lib/route-provider/route-context-data.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface RouteContextData {
99
getPath: (routeTitle: string) => string
1010
getPathFromRoute: (route: PlatformRoute) => string
1111
getRouteElement: (route: PlatformRoute) => JSX.Element
12-
isActiveRoute: (activePath: string, pathName: string, rootPath?: string) => boolean
12+
isActiveRoute: (activePath: string, toolRoute: PlatformRoute) => boolean
1313
isRootRoute: (activePath: string) => boolean
1414
rootLoggedInRoute: string
1515
rootLoggedOutRoute: string

src-ts/lib/route-provider/route.provider.tsx

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const RouteProvider: FC<RouteProviderProps> = (props: RouteProviderProps)
4040
getPath,
4141
getPathFromRoute,
4242
getRouteElement,
43-
isActiveRoute: isActiveRoute(props.rootLoggedIn, props.rootLoggedOut),
43+
isActiveRoute,
4444
isRootRoute: isRootRoute(props.rootLoggedIn, props.rootLoggedOut),
4545
rootLoggedInRoute: props.rootLoggedIn,
4646
rootLoggedOutRoute: props.rootLoggedOut,
@@ -111,26 +111,11 @@ export const RouteProvider: FC<RouteProviderProps> = (props: RouteProviderProps)
111111
)
112112
}
113113

114-
function isActivePath(activePath: string, pathName: string, rootPath?: string): boolean {
115-
return activePath?.startsWith(pathName)
116-
&& (pathName !== rootPath || activePath === rootPath)
117-
}
118-
119-
function isActiveRoute(rootLoggedIn: string, rootLoggedOut: string):
120-
(activePath: string, pathName: string, rootPath?: string) => boolean {
121-
122-
return (activePath: string, pathName: string, rootPath?: string) => {
123-
124-
let isActive: boolean = isActivePath(activePath, pathName, rootPath)
125-
126-
// if this is the root logged in route,
127-
// also check the root logged out route
128-
if (!isActive && pathName.startsWith(rootLoggedIn)) {
129-
isActive = isActivePath(activePath, rootLoggedOut)
130-
}
131-
132-
return isActive
133-
}
114+
function isActiveRoute(activePath: string, toolRoute: PlatformRoute): boolean {
115+
return !!(
116+
activePath?.startsWith(toolRoute.route)
117+
|| toolRoute.alternativePaths?.some(path => activePath?.startsWith(path))
118+
)
134119
}
135120

136121
function isRootRoute(rootLoggedIn: string, rootLoggedOut: string):

src-ts/tools/work/work.routes.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const workRoutes: Array<PlatformRoute> = [
3030
title: 'Logged Out Landing',
3131
},
3232
{
33+
alternativePaths: [selfServiceRootRoute],
3334
children: [
3435
{
3536
element: <WorkTable />,

0 commit comments

Comments
 (0)