Skip to content

Commit

Permalink
add fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EDsCODE committed Mar 19, 2024
1 parent 16fc714 commit 3cb6411
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,16 @@ function DefinitionView({ group }: { group: TaxonomicFilterGroup }): JSX.Element
} = useValues(definitionPopoverLogic)

const { setLocalDefinition } = useActions(definitionPopoverLogic)
const { selectedItemMeta } = useValues(taxonomicFilterLogic)
const { selectItem } = useActions(taxonomicFilterLogic)

// Use effect here to make definition view stateful. TaxonomicFilterLogic won't mount within definitionPopoverLogic
useEffect(() => {
if (definition.name == selectedItemMeta.id) {
setLocalDefinition(selectedItemMeta)
}
}, [definition])

if (!definition) {
return <></>
}
Expand Down Expand Up @@ -280,6 +288,7 @@ function DefinitionView({ group }: { group: TaxonomicFilterGroup }): JSX.Element
value: column.key,
}))
const itemValue = localDefinition ? group?.getValue?.(localDefinition) : null

return (
<form className="definition-popover-data-warehouse-schema-form">
<div className="flex flex-col justify-between gap-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ export function InfiniteList({ popupAnchorElement }: InfiniteListProps): JSX.Ele
const { mouseInteractionsEnabled, activeTab, searchQuery, value, groupType, eventNames } =
useValues(taxonomicFilterLogic)
const { selectItem } = useActions(taxonomicFilterLogic)

const {
isLoading,
results,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function TaxonomicFilter({
taxonomicFilterLogicKey: taxonomicFilterLogicKeyInput,
groupType,
value,
filter,
onChange,
onClose,
taxonomicGroupTypes,
Expand Down Expand Up @@ -48,6 +49,7 @@ export function TaxonomicFilter({
taxonomicFilterLogicKey,
groupType,
value,
filter,
onChange,
taxonomicGroupTypes,
optionsFromProp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
],
})),
selectors({
selectedItemMeta: [(_, p) => [p.filter], (filter) => filter],
taxonomicFilterLogicKey: [
(_, p) => [p.taxonomicFilterLogicKey],
(taxonomicFilterLogicKey) => taxonomicFilterLogicKey,
Expand Down Expand Up @@ -218,7 +219,7 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
logic: dataWarehouseSceneLogic,
value: 'externalTables',
getName: (table: DataWarehouseTableType) => table.name,
getValue: (table: DataWarehouseTableType) => table.id,
getValue: (table: DataWarehouseTableType) => table.name,
getPopoverHeader: () => 'Data Warehouse Table',
getIcon: () => <IconServer />,
},
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/components/TaxonomicFilter/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Fuse from 'fuse.js'
import { BuiltLogic, LogicWrapper } from 'kea'
import { DataWarehouseTableType } from 'scenes/data-warehouse/types'
import { LocalFilter } from 'scenes/insights/filters/ActionFilter/entityFilterLogic'

import { AnyDataNode, DatabaseSchemaQueryResponseField } from '~/queries/schema'
import {
Expand All @@ -22,6 +23,7 @@ export interface TaxonomicFilterProps {
value?: TaxonomicFilterValue
onChange?: (group: TaxonomicFilterGroup, value: TaxonomicFilterValue, item: any) => void
onClose?: () => void
filter?: LocalFilter
taxonomicGroupTypes: TaxonomicFilterGroupType[]
taxonomicFilterLogicKey?: string
optionsFromProp?: Partial<Record<TaxonomicFilterGroupType, SimpleOption[]>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TaxonomicFilterGroupType, TaxonomicFilterValue } from 'lib/components/T
import { LemonButton, LemonButtonProps } from 'lib/lemon-ui/LemonButton'
import { LemonDropdown } from 'lib/lemon-ui/LemonDropdown'
import { useEffect, useState } from 'react'
import { LocalFilter } from 'scenes/insights/filters/ActionFilter/entityFilterLogic'

import { AnyDataNode, DatabaseSchemaQueryResponseField } from '~/queries/schema'

Expand All @@ -13,6 +14,7 @@ export interface TaxonomicPopoverProps<ValueType extends TaxonomicFilterValue =
value?: ValueType
onChange: (value: ValueType, groupType: TaxonomicFilterGroupType, item: any) => void

filter?: LocalFilter
groupTypes?: TaxonomicFilterGroupType[]
renderValue?: (value: ValueType) => JSX.Element | null
eventNames?: string[]
Expand Down Expand Up @@ -41,6 +43,7 @@ export function TaxonomicStringPopover(props: TaxonomicPopoverProps<string>): JS
export function TaxonomicPopover<ValueType extends TaxonomicFilterValue = TaxonomicFilterValue>({
groupType,
value,
filter,
onChange,
renderValue,
groupTypes,
Expand Down Expand Up @@ -81,6 +84,7 @@ export function TaxonomicPopover<ValueType extends TaxonomicFilterValue = Taxono
<TaxonomicFilter
groupType={groupType}
value={value}
filter={filter}
onChange={({ type }, payload, item) => {
onChange?.(payload as ValueType, type, item)
setVisible(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export function ActionFilterRow({
fullWidth
groupType={filter.type as TaxonomicFilterGroupType}
value={getValue(value, filter)}
filter={filter}
onChange={(changedValue, taxonomicGroupType, item) => {
const groupType = taxonomicFilterGroupTypeToEntityType(taxonomicGroupType)
if (groupType === EntityTypes.DATA_WAREHOUSE) {
Expand Down

0 comments on commit 3cb6411

Please sign in to comment.