diff --git a/frontend/src/layout/FeaturePreviews/featurePreviewsLogic.tsx b/frontend/src/layout/FeaturePreviews/featurePreviewsLogic.tsx index 592ced0043252..40c2e201be346 100644 --- a/frontend/src/layout/FeaturePreviews/featurePreviewsLogic.tsx +++ b/frontend/src/layout/FeaturePreviews/featurePreviewsLogic.tsx @@ -6,6 +6,7 @@ import { supportLogic } from 'lib/components/Support/supportLogic' import { userLogic } from 'scenes/userLogic' import { FEATURE_FLAGS, FeatureFlagKey } from 'lib/constants' import type { featurePreviewsLogicType } from './featurePreviewsLogicType' +import { actionToUrl, router, urlToAction } from 'kea-router' /** Features that can only be toggled if you fall under the `${flagKey}-preview` flag */ export const CONSTRAINED_PREVIEWS: Set = new Set([FEATURE_FLAGS.POSTHOG_3000]) @@ -107,4 +108,25 @@ export const featurePreviewsLogic = kea([ }), ], }), + urlToAction(({ actions }) => ({ + '*': (_, _search, hashParams) => { + if (hashParams['panel'] === 'feature-previews') { + actions.showFeaturePreviewsModal() + } + }, + })), + actionToUrl(() => { + return { + showFeaturePreviewsModal: () => { + const hashParams = router.values.hashParams + hashParams['panel'] = 'feature-previews' + return [router.values.location.pathname, router.values.searchParams, hashParams] + }, + hideFeaturePreviewsModal: () => { + const hashParams = router.values.hashParams + delete hashParams['panel'] + return [router.values.location.pathname, router.values.searchParams, hashParams] + }, + } + }), ]) diff --git a/frontend/src/lib/components/Support/supportLogic.ts b/frontend/src/lib/components/Support/supportLogic.ts index 78bd137b8ffe2..af00389dcf7bf 100644 --- a/frontend/src/lib/components/Support/supportLogic.ts +++ b/frontend/src/lib/components/Support/supportLogic.ts @@ -309,9 +309,21 @@ export const supportLogic = kea([ urlToAction(({ actions, values }) => ({ '*': (_, _search, hashParams) => { - if ('supportModal' in hashParams && !values.isSupportFormOpen) { + if (values.isSupportFormOpen) { + return + } + + // Legacy supportModal param + if ('supportModal' in hashParams) { const [kind, area] = (hashParams['supportModal'] || '').split(':') + actions.openSupportForm( + Object.keys(SUPPORT_KIND_TO_SUBJECT).includes(kind) ? kind : null, + Object.keys(TARGET_AREA_TO_NAME).includes(area) ? area : null + ) + } else if ((hashParams['panel'] as string | undefined)?.startsWith('support')) { + const [kind, area] = hashParams['panel'].split(':').slice(1) + actions.openSupportForm( Object.keys(SUPPORT_KIND_TO_SUBJECT).includes(kind) ? kind : null, Object.keys(TARGET_AREA_TO_NAME).includes(area) ? area : null @@ -322,7 +334,8 @@ export const supportLogic = kea([ actionToUrl(({ values }) => { const updateUrl = (): any => { const hashParams = router.values.hashParams - hashParams['supportModal'] = `${values.sendSupportRequest.kind || ''}:${ + delete hashParams['supportModal'] // legacy value + hashParams['panel'] = `support:${values.sendSupportRequest.kind || ''}:${ values.sendSupportRequest.target_area || '' }` return [router.values.location.pathname, router.values.searchParams, hashParams] @@ -332,7 +345,9 @@ export const supportLogic = kea([ setSendSupportRequestValue: () => updateUrl(), closeSupportForm: () => { const hashParams = router.values.hashParams - delete hashParams['supportModal'] + delete hashParams['supportModal'] // legacy value + delete hashParams['panel'] + return [router.values.location.pathname, router.values.searchParams, hashParams] }, }