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 f0b4de0ba414d..a3eab87214df0 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 @@ -1,5 +1,5 @@ import {Box} from '@dagster-io/ui-components'; -import React from 'react'; +import {ReactNode} from 'react'; import {useHistory} from 'react-router-dom'; import {TopNavLink} from './AppTopNav'; @@ -9,113 +9,97 @@ import {FeatureFlag, featureEnabled} from '../Flags'; import {ShortcutHandler} from '../ShortcutHandler'; export type AppNavLinkType = { - title: string; - element: React.ReactNode; + key: string; + path: string; + element: ReactNode; }; export const AppTopNavLinks = ({links}: {links: AppNavLinkType[]}) => { + const history = useHistory(); return ( - {links.map((link) => link.element)} + {links.map((link, ii) => { + const {key, path, element} = link; + return ( + history.push(path)} + shortcutLabel={`⌥${ii + 1}`} + shortcutFilter={(e) => e.altKey && e.code === `Digit${ii + 1}`} + > + {element} + + ); + })} ); }; -export const navLinks = (history: ReturnType) => { +export const navLinks = () => { return [ { - title: 'overview' as const, + key: 'overview', + path: '/overview', element: ( - history.push('/overview')} - shortcutLabel="⌥1" - shortcutFilter={(e) => e.altKey && e.code === 'Digit1'} - > - - Overview - - + + Overview + ), }, { - title: 'runs' as const, + key: 'runs', + path: '/runs', element: ( - history.push('/runs')} - shortcutLabel="⌥2" - shortcutFilter={(e) => e.altKey && e.code === 'Digit2'} - > - - Runs - - + + Runs + ), }, { - title: 'assets' as const, + key: 'assets', + path: '/assets', element: ( - history.push('/assets')} - shortcutLabel="⌥3" - shortcutFilter={(e) => e.altKey && e.code === 'Digit3'} + - - Assets - - + Assets + ), }, featureEnabled(FeatureFlag.flagSettingsPage) ? { - title: 'settings' as const, + key: 'settings', + path: '/settings', element: ( - history.push('/settings')} - shortcutLabel="⌥4" - shortcutFilter={(e) => e.altKey && e.code === 'Digit4'} + - - - Settings - - - - + + Settings + + + ), } : { - title: 'deployment' as const, + key: 'deployment', + path: '/locations', element: ( - history.push('/locations')} - shortcutLabel="⌥4" - shortcutFilter={(e) => e.altKey && e.code === 'Digit4'} + - - - Deployment - - - - + + Deployment + + + ), }, ]; diff --git a/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/AppTopNavRightOfLogo.oss.tsx b/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/AppTopNavRightOfLogo.oss.tsx index 62160c9d4bc8d..1e6c7cec794a3 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/AppTopNavRightOfLogo.oss.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/app/AppTopNav/AppTopNavRightOfLogo.oss.tsx @@ -1,9 +1,7 @@ import {memo} from 'react'; -import {useHistory} from 'react-router-dom'; import {AppTopNavLinks, navLinks} from './AppTopNavLinks'; export const AppTopNavRightOfLogo = memo(() => { - const history = useHistory(); - return ; + return ; });