From a9c22d373647004dc0277400b50b1c5b081faef6 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Thu, 9 Nov 2023 21:16:20 +0000 Subject: [PATCH] fix: allow flagging of settings as well as sections of settings (#18530) --- frontend/src/scenes/settings/SettingsMap.tsx | 1 + frontend/src/scenes/settings/settingsLogic.ts | 6 +++--- frontend/src/scenes/settings/types.ts | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsx index 3be4ecd4347c7..f5015ea7f5681 100644 --- a/frontend/src/scenes/settings/SettingsMap.tsx +++ b/frontend/src/scenes/settings/SettingsMap.tsx @@ -156,6 +156,7 @@ export const SettingsMap: SettingSection[] = [ id: 'replay-ingestion', title: 'Ingestion controls', component: , + flag: 'SESSION_RECORDING_SAMPLING', }, ], }, diff --git a/frontend/src/scenes/settings/settingsLogic.ts b/frontend/src/scenes/settings/settingsLogic.ts index ae049e9dcf96e..665b7d27a4c7f 100644 --- a/frontend/src/scenes/settings/settingsLogic.ts +++ b/frontend/src/scenes/settings/settingsLogic.ts @@ -76,8 +76,8 @@ export const settingsLogic = kea([ }, ], settings: [ - (s) => [s.selectedLevel, s.selectedSectionId, s.sections], - (selectedLevel, selectedSectionId, sections): Setting[] => { + (s) => [s.selectedLevel, s.selectedSectionId, s.sections, s.featureFlags], + (selectedLevel, selectedSectionId, sections, featureFlags): Setting[] => { let settings: Setting[] = [] if (!selectedSectionId) { @@ -88,7 +88,7 @@ export const settingsLogic = kea([ settings = sections.find((x) => x.id === selectedSectionId)?.settings || [] } - return settings + return settings.filter((x) => (x.flag ? featureFlags[FEATURE_FLAGS[x.flag]] : true)) }, ], }), diff --git a/frontend/src/scenes/settings/types.ts b/frontend/src/scenes/settings/types.ts index 7ee3455fd79e7..30ee8324d0ebe 100644 --- a/frontend/src/scenes/settings/types.ts +++ b/frontend/src/scenes/settings/types.ts @@ -67,6 +67,7 @@ export type Setting = { title: string description?: JSX.Element | string component: JSX.Element + flag?: keyof typeof FEATURE_FLAGS } export type SettingSection = {