-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Insights query UI, Option B (#4233)
Co-authored-by: Paolo D'Amico <[email protected]>
- Loading branch information
1 parent
d71e52c
commit 2c78919
Showing
19 changed files
with
526 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
frontend/src/lib/components/PropertyFilters/components/FilterRow.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React, { useState } from 'react' | ||
import { PropertyFilter } from './PropertyFilter' | ||
import { Button } from 'antd' | ||
import { useActions } from 'kea' | ||
import { Popover, Row } from 'antd' | ||
import { CloseButton } from 'lib/components/CloseButton' | ||
import { DeleteOutlined } from '@ant-design/icons' | ||
import PropertyFilterButton from './PropertyFilterButton' | ||
import 'scenes/actions/Actions.scss' | ||
|
||
export const FilterRow = React.memo(function FilterRow({ | ||
item, | ||
index, | ||
filters, | ||
logic, | ||
pageKey, | ||
showConditionBadge, | ||
totalCount, | ||
disablePopover = false, // use bare PropertyFilter without popover | ||
popoverPlacement, | ||
}) { | ||
const { remove } = useActions(logic) | ||
let [open, setOpen] = useState(false) | ||
const { key } = item | ||
|
||
let handleVisibleChange = (visible) => { | ||
if (!visible && Object.keys(item).length >= 0 && !item[Object.keys(item)[0]]) { | ||
remove(index) | ||
} | ||
setOpen(visible) | ||
} | ||
|
||
const propertyFilterCommonProps = { | ||
key: index, | ||
index, | ||
onComplete: () => setOpen(false), | ||
logic, | ||
selectProps: { | ||
delayBeforeAutoOpen: 150, | ||
}, | ||
} | ||
|
||
return ( | ||
<Row | ||
align="middle" | ||
className="mt-05 mb-05" | ||
data-attr={'property-filter-' + index} | ||
style={{ | ||
maxWidth: '90vw', | ||
}} | ||
> | ||
{disablePopover ? ( | ||
<> | ||
<PropertyFilter {...propertyFilterCommonProps} variant="unified" /> | ||
{!!Object.keys(filters[index]).length && ( | ||
<Button | ||
type="link" | ||
onClick={() => remove(index)} | ||
style={{ | ||
padding: 0, | ||
paddingLeft: 5, | ||
}} | ||
> | ||
<DeleteOutlined /> | ||
</Button> | ||
)} | ||
</> | ||
) : ( | ||
<> | ||
<Popover | ||
trigger="click" | ||
onVisibleChange={handleVisibleChange} | ||
destroyTooltipOnHide={true} | ||
defaultVisible={false} | ||
visible={open} | ||
placement={popoverPlacement || 'bottomLeft'} | ||
content={<PropertyFilter {...propertyFilterCommonProps} variant="tabs" />} | ||
> | ||
{key ? ( | ||
<PropertyFilterButton onClick={() => setOpen(!open)} item={item} /> | ||
) : ( | ||
<Button type="default" shape="round" data-attr={'new-prop-filter-' + pageKey}> | ||
Add filter | ||
</Button> | ||
)} | ||
</Popover> | ||
{!!Object.keys(filters[index]).length && ( | ||
<CloseButton | ||
className="ml-1" | ||
onClick={() => { | ||
remove(index) | ||
}} | ||
style={{ cursor: 'pointer', float: 'none', marginLeft: 5 }} | ||
/> | ||
)} | ||
</> | ||
)} | ||
{key && showConditionBadge && index + 1 < totalCount && ( | ||
<span style={{ marginLeft: 16, right: 16, position: 'absolute' }} className="stateful-badge and"> | ||
AND | ||
</span> | ||
)} | ||
</Row> | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
frontend/src/lib/components/PropertyFilters/components/PropertyFilter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import { SelectGradientOverflowProps } from 'lib/components/SelectGradientOverflow' | ||
import { propertyFilterLogic } from '../propertyFilterLogic' | ||
import { TabbedPropertyFilter } from './TabbedPropertyFilter' | ||
import { UnifiedPropertyFilter } from './UnifiedPropertyFilter' | ||
|
||
export interface PropertyFilterInternalProps { | ||
index: number | ||
onComplete: CallableFunction | ||
logic: typeof propertyFilterLogic | ||
selectProps: Partial<SelectGradientOverflowProps> | ||
} | ||
|
||
export interface PropertyFilterProps extends PropertyFilterInternalProps { | ||
variant: 'tabs' | 'unified' | ||
} | ||
|
||
export function PropertyFilter({ variant = 'tabs', ...props }: PropertyFilterProps): JSX.Element { | ||
switch (variant) { | ||
case 'unified': | ||
return <UnifiedPropertyFilter {...props} /> | ||
case 'tabs': | ||
return <TabbedPropertyFilter {...props} /> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...mponents/PropertyFilters/PropertyValue.js → ...opertyFilters/components/PropertyValue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.