Skip to content

Commit

Permalink
feat(commands): add command to view shortcut overview (#19021)
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr authored Dec 4, 2023
1 parent 79eebd4 commit 5ba512a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions frontend/src/lib/components/CommandPalette/commandPaletteLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import { dashboardsModel } from '~/models/dashboardsModel'
import { DashboardType, InsightType } from '~/types'

import { personalAPIKeysLogic } from '../../../scenes/settings/user/personalAPIKeysLogic'
import { commandBarLogic } from '../CommandBar/commandBarLogic'
import { BarStatus } from '../CommandBar/types'
import { hedgehogbuddyLogic } from '../HedgehogBuddy/hedgehogbuddyLogic'
import type { commandPaletteLogicType } from './commandPaletteLogicType'
import { openCHQueriesDebugModal } from './DebugCHQueries'
Expand Down Expand Up @@ -144,6 +146,8 @@ export const commandPaletteLogic = kea<commandPaletteLogicType>([
['updateUser'],
hedgehogbuddyLogic,
['setHedgehogModeEnabled'],
commandBarLogic,
['setCommandBar'],
],
values: [
teamLogic,
Expand Down Expand Up @@ -935,6 +939,30 @@ export const commandPaletteLogic = kea<commandPaletteLogicType>([
},
}

const shortcuts: Command = {
key: 'shortcuts',
scope: GLOBAL_COMMAND_SCOPE,
resolver: {
icon: IconKeyboard,
display: 'Open keyboard shortcut overview',
executor: () => {
actions.setCommandBar(BarStatus.SHOW_SHORTCUTS)

// :HACKY: we need to return a dummy flow here, as otherwise
// the executor will hide the command bar, which also displays
// the shortcut overview
const dummyFlow: CommandFlow = {
resolver: () => ({
icon: <></>,
display: '',
executor: true,
}),
}
return dummyFlow
},
},
}

actions.registerCommand(goTo)
actions.registerCommand(openUrls)
actions.registerCommand(debugClickhouseQueries)
Expand All @@ -946,6 +974,7 @@ export const commandPaletteLogic = kea<commandPaletteLogicType>([
if (values.featureFlags[FEATURE_FLAGS.POSTHOG_3000]) {
actions.registerCommand(toggleTheme)
actions.registerCommand(toggleHedgehogMode)
actions.registerCommand(shortcuts)
}
},
beforeUnmount: () => {
Expand All @@ -959,6 +988,7 @@ export const commandPaletteLogic = kea<commandPaletteLogicType>([
actions.deregisterCommand('debug-copy-session-recording-url')
actions.deregisterCommand('toggle-theme')
actions.deregisterCommand('toggle-hedgehog-mode')
actions.deregisterCommand('shortcuts')
},
})),
])

0 comments on commit 5ba512a

Please sign in to comment.