Skip to content

Commit

Permalink
fix(flags): don't use the cohort not_in operators for feature flags…
Browse files Browse the repository at this point in the history
…, since we don't support that operation in flag matching yet (#25149)

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
dmarticus and github-actions[bot] authored Sep 24, 2024
1 parent c2778a3 commit cf07fb3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/src/lib/components/DefinitionPopover/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export function genericOperatorToHumanName(property?: AnyPropertyFilter | null):

export function allOperatorsToHumanName(operator?: PropertyOperator | null): string {
if (operator && allOperatorsMapping[operator]) {
// for the case of cohort matching, we want to return the operator name without the "In" prefix
if (operator === PropertyOperator.In) {
return 'in'
}
return allOperatorsMapping[operator].slice(2)
}
return 'equals'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface PropertyFiltersProps {
propertyAllowList?: { [key in TaxonomicFilterGroupType]?: string[] }
allowRelativeDateOptions?: boolean
disabledReason?: string
exactMatchFeatureFlagCohortOperators?: boolean
}

export function PropertyFilters({
Expand Down Expand Up @@ -65,6 +66,7 @@ export function PropertyFilters({
propertyAllowList,
allowRelativeDateOptions,
disabledReason = undefined,
exactMatchFeatureFlagCohortOperators = false,
}: PropertyFiltersProps): JSX.Element {
const logicProps = { propertyFilters, onChange, pageKey, sendAllKeyUpdates }
const { filters, filtersWithNew } = useValues(propertyFilterLogic(logicProps))
Expand Down Expand Up @@ -128,6 +130,7 @@ export function PropertyFilters({
propertyAllowList={propertyAllowList}
taxonomicFilterOptionsFromProp={taxonomicFilterOptionsFromProp}
allowRelativeDateOptions={allowRelativeDateOptions}
exactMatchFeatureFlagCohortOperators={exactMatchFeatureFlagCohortOperators}
/>
)}
errorMessage={errorMessages && errorMessages[index]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function TaxonomicPropertyFilter({
propertyAllowList,
taxonomicFilterOptionsFromProp,
allowRelativeDateOptions,
exactMatchFeatureFlagCohortOperators,
}: PropertyFilterInternalProps): JSX.Element {
const pageKey = useMemo(() => pageKeyInput || `filter-${uniqueMemoizedIndex++}`, [pageKeyInput])
const groupTypes = taxonomicGroupTypes || [
Expand Down Expand Up @@ -85,7 +86,14 @@ export function TaxonomicPropertyFilter({
const showInitialSearchInline =
!disablePopover &&
((!filter?.type && (!filter || !(filter as any)?.key)) || filter?.type === PropertyFilterType.HogQL)
const showOperatorValueSelect = filter?.type && filter?.key && filter?.type !== PropertyFilterType.HogQL
const showOperatorValueSelect =
filter?.type &&
filter?.key &&
!(filter?.type === PropertyFilterType.HogQL) &&
// If we're in a feature flag, we don't want to show operators for cohorts because
// we don't support any cohort matching operators other than "in"
// See https://github.com/PostHog/posthog/pull/25149/
!(filter?.type === PropertyFilterType.Cohort && exactMatchFeatureFlagCohortOperators)
const placeOperatorValueSelectOnLeft = filter?.type && filter?.key && filter?.type === PropertyFilterType.Cohort

const { propertyDefinitionsByType } = useValues(propertyDefinitionsModel)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/components/PropertyFilters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ export interface PropertyFilterInternalProps {
metadataSource?: AnyDataNode
propertyAllowList?: { [key in TaxonomicFilterGroupType]?: string[] }
allowRelativeDateOptions?: boolean
exactMatchFeatureFlagCohortOperators?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export function FeatureFlagReleaseConditions({
})
: null
}
exactMatchFeatureFlagCohortOperators={true}
/>
</div>
)}
Expand Down

0 comments on commit cf07fb3

Please sign in to comment.