2023-08-22 09:33:19 -04:00
|
|
|
import { useState, useCallback } from 'react'
|
2022-10-24 16:33:13 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2023-08-22 09:33:19 -04:00
|
|
|
import * as eventTracking from '../../../infrastructure/event-tracking'
|
2022-10-24 16:33:13 -04:00
|
|
|
import { useProjectContext } from '../../../shared/context/project-context'
|
|
|
|
import HotkeysModal from '../../hotkeys-modal/components/hotkeys-modal'
|
2022-11-24 09:26:38 -05:00
|
|
|
import useScopeValue from '../../../shared/hooks/use-scope-value'
|
2022-10-24 16:33:13 -04:00
|
|
|
import LeftMenuButton from './left-menu-button'
|
|
|
|
|
|
|
|
export default function HelpShowHotkeys() {
|
|
|
|
const [showModal, setShowModal] = useState(false)
|
2022-11-24 09:26:38 -05:00
|
|
|
const [newSourceEditor] = useScopeValue('editor.newSourceEditor')
|
2022-10-24 16:33:13 -04:00
|
|
|
const { t } = useTranslation()
|
|
|
|
const { features } = useProjectContext()
|
|
|
|
const isMac = /Mac/.test(window.navigator?.platform)
|
|
|
|
|
2023-08-22 09:33:19 -04:00
|
|
|
const showModalWithAnalytics = useCallback(() => {
|
|
|
|
eventTracking.sendMB('left-menu-hotkeys')
|
|
|
|
setShowModal(true)
|
|
|
|
}, [])
|
|
|
|
|
2022-10-24 16:33:13 -04:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<LeftMenuButton
|
2023-08-22 09:33:19 -04:00
|
|
|
onClick={showModalWithAnalytics}
|
2022-10-24 16:33:13 -04:00
|
|
|
icon={{
|
|
|
|
type: 'keyboard-o',
|
|
|
|
fw: true,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{t('show_hotkeys')}
|
|
|
|
</LeftMenuButton>
|
|
|
|
<HotkeysModal
|
|
|
|
show={showModal}
|
|
|
|
handleHide={() => setShowModal(false)}
|
|
|
|
isMac={isMac}
|
|
|
|
trackChangesVisible={features?.trackChangesVisible}
|
2022-11-24 09:26:38 -05:00
|
|
|
newSourceEditor={newSourceEditor}
|
2022-10-24 16:33:13 -04:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|