diff --git a/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/AppTopNavLinks.tsx b/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/AppTopNavLinks.tsx index c11ae872b969d..d5663caa3783c 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/AppTopNavLinks.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/AppTopNavLinks.tsx @@ -3,7 +3,13 @@ import {ReactNode} from 'react'; import {useHistory} from 'react-router-dom'; import {TopNavLink} from './AppTopNav'; -import {assetsPathMatcher, locationPathMatcher, settingsPathMatcher} from './activePathMatchers'; +import { + assetsPathMatcher, + automationPathMatcher, + jobsPathMatcher, + locationPathMatcher, + settingsPathMatcher, +} from './activePathMatchers'; import {DeploymentStatusIcon} from '../../nav/DeploymentStatusIcon'; import {FeatureFlag, featureEnabled} from '../Flags'; import {ShortcutHandler} from '../ShortcutHandler'; @@ -60,7 +66,7 @@ export const navLinks = () => { key: 'jobs', path: '/jobs', element: ( - + Jobs ), @@ -70,12 +76,7 @@ export const navLinks = () => { key: 'assets', path: '/assets', element: ( - + Assets ), @@ -85,7 +86,11 @@ export const navLinks = () => { key: 'automation', path: '/automation', element: ( - + Automation ), diff --git a/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/activePathMatchers.tsx b/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/activePathMatchers.tsx index 41d6e4e44157d..fba809d107055 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/activePathMatchers.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/activePathMatchers.tsx @@ -1,8 +1,15 @@ import {ComponentProps} from 'react'; -import {NavLink} from 'react-router-dom'; +import {NavLink, matchPath} from 'react-router-dom'; type MatcherFn = NonNullable['isActive']>; +export const jobsPathMatcher: MatcherFn = (_, currentLocation) => { + const {pathname} = currentLocation; + return !!matchPath(pathname, { + path: ['/jobs', '/locations/:codeLocation/jobs/:jobName'], + }); +}; + export const assetsPathMatcher: MatcherFn = (_, currentLocation) => { const {pathname} = currentLocation; return ( @@ -17,7 +24,10 @@ export const settingsPathMatcher: MatcherFn = (_, currentLocation) => { const {pathname} = currentLocation; return ( pathname.startsWith('/settings') || - (pathname.startsWith('/locations') && !pathname.includes('/asset-groups/')) + (pathname.startsWith('/locations') && + !pathname.includes('/asset-groups/') && + !automationPathMatcher(_, currentLocation) && + !jobsPathMatcher(_, currentLocation)) ); }; @@ -29,3 +39,14 @@ export const locationPathMatcher: MatcherFn = (_, currentLocation) => { pathname.startsWith('/config') ); }; + +export const automationPathMatcher: MatcherFn = (_, currentLocation) => { + const {pathname} = currentLocation; + return !!matchPath(pathname, { + path: [ + '/automation', + '/locations/:codeLocation/sensors/:sensorName', + '/locations/:codeLocation/schedules/:scheduleName', + ], + }); +};