diff --git a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--dark.png b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--dark.png index f84db4546c2..923fe9d53a9 100644 Binary files a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--dark.png and b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--dark.png differ diff --git a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--light.png b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--light.png index 2dce17c37f6..8ac25dbcb68 100644 Binary files a/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--light.png and b/frontend/__snapshots__/scenes-app-sidepanels--side-panel-settings--light.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-project--dark.png b/frontend/__snapshots__/scenes-other-settings--settings-project--dark.png index 24b46c28263..90a9520a0a5 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-project--dark.png and b/frontend/__snapshots__/scenes-other-settings--settings-project--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-project--light.png b/frontend/__snapshots__/scenes-other-settings--settings-project--light.png index ff07ce03253..67442495da9 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-project--light.png and b/frontend/__snapshots__/scenes-other-settings--settings-project--light.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-project-with-replay-features--dark.png b/frontend/__snapshots__/scenes-other-settings--settings-project-with-replay-features--dark.png index c8cd83be7e7..0ab641c721f 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-project-with-replay-features--dark.png and b/frontend/__snapshots__/scenes-other-settings--settings-project-with-replay-features--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-project-with-replay-features--light.png b/frontend/__snapshots__/scenes-other-settings--settings-project-with-replay-features--light.png index e8fe754ac07..457aa4cc9fb 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-project-with-replay-features--light.png and b/frontend/__snapshots__/scenes-other-settings--settings-project-with-replay-features--light.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-all-options--dark.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-all-options--dark.png index 24b46c28263..90a9520a0a5 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-all-options--dark.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-all-options--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-all-options--light.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-all-options--light.png index ff07ce03253..67442495da9 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-all-options--light.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-all-options--light.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--dark.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--dark.png index 24b46c28263..90a9520a0a5 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--dark.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--light.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--light.png index ff07ce03253..67442495da9 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--light.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-password-only--light.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-github--dark.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-github--dark.png index 24b46c28263..90a9520a0a5 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-github--dark.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-github--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-github--light.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-github--light.png index ff07ce03253..67442495da9 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-github--light.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-github--light.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-google--dark.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-google--dark.png index 24b46c28263..90a9520a0a5 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-google--dark.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-google--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-google--light.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-google--light.png index ff07ce03253..67442495da9 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-google--light.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-google--light.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--dark.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--dark.png index 24b46c28263..90a9520a0a5 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--dark.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--light.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--light.png index ff07ce03253..67442495da9 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--light.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-enforced-saml--light.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-only--dark.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-only--dark.png index 24b46c28263..90a9520a0a5 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-only--dark.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-only--dark.png differ diff --git a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-only--light.png b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-only--light.png index ff07ce03253..67442495da9 100644 Binary files a/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-only--light.png and b/frontend/__snapshots__/scenes-other-settings--settings-session-timeout-sso-only--light.png differ diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsx index 5e272bb12d8..0ace49b1ac2 100644 --- a/frontend/src/scenes/settings/SettingsMap.tsx +++ b/frontend/src/scenes/settings/SettingsMap.tsx @@ -81,7 +81,7 @@ export const SETTINGS_MAP: SettingSection[] = [ description: 'Describe your product in a few sentences. This context helps our AI assistant provide relevant answers and suggestions.', component: , - flag: '!ENVIRONMENTS', + flag: ['ARTIFICIAL_HOG', '!ENVIRONMENTS'], }, { id: 'snippet', diff --git a/frontend/src/scenes/settings/settingsLogic.ts b/frontend/src/scenes/settings/settingsLogic.ts index 3c825e75690..b2707e0ce71 100644 --- a/frontend/src/scenes/settings/settingsLogic.ts +++ b/frontend/src/scenes/settings/settingsLogic.ts @@ -74,16 +74,9 @@ export const settingsLogic = kea([ }, ], sections: [ - (s) => [s.featureFlags], - (featureFlags): SettingSection[] => { - const sections = SETTINGS_MAP.filter((x) => { - const isFlagConditionMet = !x.flag - ? true // No flag condition - : x.flag.startsWith('!') - ? !featureFlags[FEATURE_FLAGS[x.flag.slice(1)]] // Negated flag condition (!-prefixed) - : featureFlags[FEATURE_FLAGS[x.flag]] // Regular flag condition - return isFlagConditionMet - }) + (s) => [s.doesMatchFlags, s.featureFlags], + (doesMatchFlags, featureFlags): SettingSection[] => { + const sections = SETTINGS_MAP.filter(doesMatchFlags) if (!featureFlags[FEATURE_FLAGS.ENVIRONMENTS]) { return sections .filter((section) => section.level !== 'project') @@ -108,24 +101,8 @@ export const settingsLogic = kea([ }, ], settings: [ - (s) => [ - s.selectedLevel, - s.selectedSectionId, - s.sections, - s.settingId, - s.featureFlags, - s.hasAvailableFeature, - s.preflight, - ], - ( - selectedLevel, - selectedSectionId, - sections, - settingId, - featureFlags, - hasAvailableFeature, - preflight - ): Setting[] => { + (s) => [s.selectedLevel, s.selectedSectionId, s.sections, s.settingId, s.doesMatchFlags, s.preflight], + (selectedLevel, selectedSectionId, sections, settingId, doesMatchFlags, preflight): Setting[] => { let settings: Setting[] = [] if (selectedSectionId) { @@ -140,29 +117,40 @@ export const settingsLogic = kea([ return settings.filter((x) => x.id === settingId) } - return settings - .filter((x) => { - const isFlagConditionMet = !x.flag - ? true // No flag condition - : x.flag.startsWith('!') - ? !featureFlags[FEATURE_FLAGS[x.flag.slice(1)]] // Negated flag condition (!-prefixed) - : featureFlags[FEATURE_FLAGS[x.flag]] // Regular flag condition - if (x.flag && x.features) { - return x.features.some((feat) => hasAvailableFeature(feat)) || isFlagConditionMet - } else if (x.features) { - return x.features.some((feat) => hasAvailableFeature(feat)) - } else if (x.flag) { - return isFlagConditionMet - } - + return settings.filter((x) => { + if (!doesMatchFlags(x)) { + return false + } + if (x.hideOn?.includes(Realm.Cloud) && preflight?.cloud) { + return false + } + return true + }) + }, + ], + doesMatchFlags: [ + (s) => [s.featureFlags], + (featureFlags) => { + return (x: Pick) => { + if (!x.flag) { + // No flag condition return true - }) - .filter((x) => { - if (x.hideOn?.includes(Realm.Cloud) && preflight?.cloud) { + } + const flagsArray = Array.isArray(x.flag) ? x.flag : [x.flag] + for (const flagCondition of flagsArray) { + const flag = ( + flagCondition.startsWith('!') ? flagCondition.slice(1) : flagCondition + ) as keyof typeof FEATURE_FLAGS + let isConditionMet = featureFlags[FEATURE_FLAGS[flag]] + if (flagCondition.startsWith('!')) { + isConditionMet = !isConditionMet // Negated flag condition (!-prefixed) + } + if (!isConditionMet) { return false } - return true - }) + } + return true + } }, ], }), diff --git a/frontend/src/scenes/settings/types.ts b/frontend/src/scenes/settings/types.ts index 3b3f17218c8..fa210a263e2 100644 --- a/frontend/src/scenes/settings/types.ts +++ b/frontend/src/scenes/settings/types.ts @@ -1,6 +1,6 @@ import { EitherMembershipLevel, FEATURE_FLAGS } from 'lib/constants' -import { AvailableFeature, Realm } from '~/types' +import { Realm } from '~/types' export type SettingsLogicProps = { logicKey?: string @@ -111,21 +111,16 @@ export type Setting = { /** * Feature flag to gate the setting being shown. * If prefixed with !, the condition is inverted - the setting will only be shown if the is flag false. + * When an array is provided, the setting will be shown if ALL of the conditions are met. */ - flag?: FeatureFlagKey | `!${FeatureFlagKey}` - features?: AvailableFeature[] + flag?: FeatureFlagKey | `!${FeatureFlagKey}` | (FeatureFlagKey | `!${FeatureFlagKey}`)[] hideOn?: Realm[] } -export type SettingSection = { +export interface SettingSection extends Pick { id: SettingSectionId title: string level: SettingLevelId settings: Setting[] - /** - * Feature flag to gate the section being shown. - * If prefixed with !, the condition is inverted - the section will only be shown if the is flag false. - */ - flag?: FeatureFlagKey | `!${FeatureFlagKey}` minimumAccessLevel?: EitherMembershipLevel }