Changeset View
Changeset View
Standalone View
Standalone View
web/navigation-panels/topbar.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { useDispatch } from 'react-redux'; | |||||
import { useModalContext } from 'lib/components/modal-provider.react.js'; | |||||
import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; | import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; | ||||
import AppSwitcher from './app-switcher.react.js'; | import AppSwitcher from './app-switcher.react.js'; | ||||
import css from './topbar.css'; | import css from './topbar.css'; | ||||
import Button from '../components/button.react.js'; | import Button from '../components/button.react.js'; | ||||
import { updateNavInfoActionType } from '../redux/action-types.js'; | import AppsDirectory from '../modals/apps/apps-directory-modal.react.js'; | ||||
function Topbar(): React.Node { | function Topbar(): React.Node { | ||||
const dispatch = useDispatch(); | const { pushModal } = useModalContext(); | ||||
const onClickApps = React.useCallback( | const onClickApps = React.useCallback( | ||||
(event: SyntheticEvent<HTMLAnchorElement>) => { | (event: SyntheticEvent<HTMLAnchorElement>) => { | ||||
event.preventDefault(); | event.preventDefault(); | ||||
dispatch({ | pushModal(<AppsDirectory />); | ||||
type: updateNavInfoActionType, | |||||
payload: { | |||||
tab: 'apps', | |||||
}, | }, | ||||
}); | [pushModal], | ||||
}, | |||||
[dispatch], | |||||
); | ); | ||||
const appNavigationItem = React.useMemo( | const appNavigationItem = React.useMemo( | ||||
() => ( | () => ( | ||||
<Button className={css.plusButton} onClick={onClickApps}> | <Button className={css.plusButton} onClick={onClickApps}> | ||||
<SWMansionIcon icon="plus-small" size={24} /> | <SWMansionIcon icon="plus-small" size={24} /> | ||||
</Button> | </Button> | ||||
), | ), | ||||
Show All 16 Lines |