Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Dec 13, 2021
1 parent a3d87e4 commit 6ec1da8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface OperatorValueSelectProps {
endpoint?: string
onChange: (operator: PropertyOperator, value: PropertyFilterValue) => void
operatorSelectProps?: Omit<SelectProps<any>, 'onChange'>
allowQueryingEventsByDateTime?: boolean
}

interface OperatorSelectProps extends SelectProps<any> {
Expand All @@ -33,15 +34,18 @@ export function OperatorValueSelect({
endpoint,
onChange,
operatorSelectProps,
allowQueryingEventsByDateTime,
}: OperatorValueSelectProps): JSX.Element {
const [currentOperator, setCurrentOperator] = useState(operator)

const operators = allowQueryingEventsByDateTime
? (Object.keys(operatorMap).filter((o) => o != 'is_before' && o != 'is_after') as Array<PropertyOperator>)
: (Object.keys(operatorMap) as Array<PropertyOperator>)
return (
<>
<Col {...(Array.isArray(columnOptions) ? columnOptions[0] : columnOptions)}>
<OperatorSelect
operator={currentOperator || PropertyOperator.Exact}
operators={Object.keys(operatorMap) as Array<PropertyOperator>}
operators={operators}
onChange={(newOperator: PropertyOperator) => {
setCurrentOperator(newOperator)
if (isOperatorFlag(newOperator)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { PropertyFilterInternalProps } from 'lib/components/PropertyFilters'
import { TaxonomicFilter } from 'lib/components/TaxonomicFilter/TaxonomicFilter'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { propertyFilterTypeToTaxonomicFilterType } from 'lib/components/PropertyFilters/utils'
import { featureFlagsLogic } from 'scenes/feature-flags/featureFlagsLogic'
import { FEATURE_FLAGS } from 'lib/constants'

let uniqueMemoizedIndex = 0

Expand All @@ -25,6 +27,7 @@ export function TaxonomicPropertyFilter({
}: PropertyFilterInternalProps): JSX.Element {
const pageKey = useMemo(() => pageKeyInput || `filter-${uniqueMemoizedIndex++}`, [pageKeyInput])
const { setFilter } = useActions(propertyFilterLogic)
const { featureFlags } = useValues(featureFlagsLogic)

const logic = taxonomicPropertyFilterLogic({ pageKey, filterIndex: index })
const { filter, dropdownOpen, selectedCohortName, activeTaxonomicGroup } = useValues(logic)
Expand Down Expand Up @@ -102,6 +105,7 @@ export function TaxonomicPropertyFilter({

{showOperatorValueSelect && (
<OperatorValueSelect
allowQueryingEventsByDateTime={featureFlags[FEATURE_FLAGS.QUERY_EVENTS_BY_DATETIME]}
type={filter?.type}
propkey={filter?.key}
operator={filter?.operator}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const FEATURE_FLAGS = {
RETENTION_BREAKDOWN: 'retention-breakdown', // owner: @hazzadous
STALE_EVENTS: 'stale-events', // owner: @paolodamico
INSIGHT_LEGENDS: 'insight-legends', // owner @alexkim205
QUERY_EVENTS_BY_DATETIME: '6619-query-events-by-date', // owner @pauldambra
}

export const ENTITY_MATCH_TYPE = 'entities'
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ export const operatorMap: Record<string, string> = {
lt: '< lower than',
is_set: '✓ is set',
is_not_set: '✕ is not set',
is_before: '< before',
is_after: '> after',
}

export function isOperatorMulti(operator: string): boolean {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ export enum PropertyOperator {
LessThan = 'lt',
IsSet = 'is_set',
IsNotSet = 'is_not_set',
IsBefore = 'is_before',
IsAfter = 'is_after',
}

export enum SavedInsightsTabs {
Expand Down

0 comments on commit 6ec1da8

Please sign in to comment.