Skip to content

Commit

Permalink
feat(commands): add hedgehog toggle command (#19019)
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr authored Dec 1, 2023
1 parent ffeddd9 commit 519415c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 37 additions & 2 deletions frontend/src/lib/components/CommandPalette/commandPaletteLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { actions, connect, events, kea, listeners, path, reducers, selectors } f
import { router } from 'kea-router'
import api from 'lib/api'
import { FEATURE_FLAGS } from 'lib/constants'
import { IconFlare } from 'lib/lemon-ui/icons'
import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { isMobile, isURL, uniqueBy } from 'lib/utils'
Expand All @@ -63,6 +64,7 @@ import { dashboardsModel } from '~/models/dashboardsModel'
import { DashboardType, InsightType } from '~/types'

import { personalAPIKeysLogic } from '../../../scenes/settings/user/personalAPIKeysLogic'
import { hedgehogbuddyLogic } from '../HedgehogBuddy/hedgehogbuddyLogic'
import type { commandPaletteLogicType } from './commandPaletteLogicType'
import { openCHQueriesDebugModal } from './DebugCHQueries'

Expand Down Expand Up @@ -134,8 +136,26 @@ function resolveCommand(source: Command | CommandFlow, argument?: string, prefix
export const commandPaletteLogic = kea<commandPaletteLogicType>([
path(['lib', 'components', 'CommandPalette', 'commandPaletteLogic']),
connect({
actions: [personalAPIKeysLogic, ['createKey'], router, ['push'], themeLogic, ['overrideTheme']],
values: [teamLogic, ['currentTeam'], userLogic, ['user'], featureFlagLogic, ['featureFlags']],
actions: [
personalAPIKeysLogic,
['createKey'],
router,
['push'],
themeLogic,
['overrideTheme'],
hedgehogbuddyLogic,
['setHedgehogModeEnabled'],
],
values: [
teamLogic,
['currentTeam'],
userLogic,
['user'],
featureFlagLogic,
['featureFlags'],
hedgehogbuddyLogic,
['hedgehogModeEnabled'],
],
logic: [preflightLogic],
}),
actions({
Expand Down Expand Up @@ -903,6 +923,19 @@ export const commandPaletteLogic = kea<commandPaletteLogicType>([
},
}

const toggleHedgehogMode: Command = {
key: 'toggle-hedgehog-mode',
scope: GLOBAL_COMMAND_SCOPE,
resolver: {
icon: IconFlare,
display: `${values.hedgehogModeEnabled ? 'Disable' : 'Enable'} hedgehog mode`,
synonyms: ['buddy', 'toggle', 'max'],
executor: () => {
actions.setHedgehogModeEnabled(!values.hedgehogModeEnabled)
},
},
}

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

0 comments on commit 519415c

Please sign in to comment.