0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00

feat(commands): add hedgehog toggle command (#19019)

This commit is contained in:
Thomas Obermüller 2023-12-01 15:56:01 +01:00 committed by GitHub
parent ffeddd9e55
commit 519415c42b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 144 KiB

View File

@ -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'
@ -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'
@ -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({
@ -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)
@ -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: () => {
@ -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')
},
})),
])