Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal query UI top-level elements (4050) #4217

Merged
merged 3 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { ActionFilter, ActionType, EntityTypes, EventDefinition } from '~/types'
import { actionsModel } from '~/models/actionsModel'
import { FireOutlined, InfoCircleOutlined, AimOutlined, ContainerOutlined } from '@ant-design/icons'
import { Tooltip } from 'antd'
import { ActionSelectInfo } from '../ActionSelectInfo'
import { SelectBox, SelectedItem } from '../../../lib/components/SelectBox'
import { ActionSelectInfo } from '../../ActionSelectInfo'
import { SelectBox, SelectedItem } from 'lib/components/SelectBox'
import { Link } from 'lib/components/Link'
import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'
import { entityFilterLogic } from './entityFilterLogic'
import { entityFilterLogic } from '../entityFilterLogic'
import { eventDefinitionsLogic } from 'scenes/events/eventDefinitionsLogic'

const getSuggestions = (events: EventDefinition[]): EventDefinition[] => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.property-select {
cursor: pointer;
width: 150px;
margin-top: 6px;
.ant-select-selector {
border-color: #d9d9d9 !important;
Expand Down Expand Up @@ -37,6 +38,24 @@
line-height: 24px !important;
color: #2d2d2d;
}

&.horizontal-ui {
width: unset !important;
margin-top: 0;

.ant-select-selector,
.ant-select-selection-placeholder,
.ant-select-selection-search-input {
font-size: inherit;
height: 32px !important;
}
.ant-select-selection-item {
line-height: 30px !important;
}
.ant-select-selection-placeholder {
line-height: 30px !important;
}
}
}
.action-row-letter {
line-height: 32px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
import { PROPERTY_MATH_TYPE, EVENT_MATH_TYPE, MATHS } from 'lib/constants'
import { DownOutlined, DeleteOutlined } from '@ant-design/icons'
import { SelectGradientOverflow } from 'lib/components/SelectGradientOverflow'
import './ActionFilterRow.scss'
import { BareEntity, entityFilterLogic } from './entityFilterLogic'
import { BareEntity, entityFilterLogic } from '../entityFilterLogic'
import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'
import { preflightLogic } from 'scenes/PreflightCheck/logic'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { propertyDefinitionsLogic } from 'scenes/events/propertyDefinitionsLogic'
import './index.scss'

const EVENT_MATH_ENTRIES = Object.entries(MATHS).filter(([, item]) => item.type == EVENT_MATH_TYPE)
const PROPERTY_MATH_ENTRIES = Object.entries(MATHS).filter(([, item]) => item.type == PROPERTY_MATH_TYPE)
Expand Down Expand Up @@ -87,10 +87,12 @@ export function ActionFilterRow({
})
}

const dropDownCondition: boolean = Boolean(
const dropDownCondition = Boolean(
selectedFilter && selectedFilter?.type === filter.type && selectedFilter?.index === index
)

const separatorWord = math === 'dau' ? 'who did' : 'of' // Separator between property and value.

const onClick = (): void => {
if (dropDownCondition) {
selectFilter(null)
Expand All @@ -107,6 +109,7 @@ export function ActionFilterRow({
name = entity.name || filter.name
value = entity.id || filter.id
}

return (
<div>
{showOr && (
Expand All @@ -127,18 +130,36 @@ export function ActionFilterRow({
{horizontalUI && (
<>
<Col>Showing</Col>
<Col style={{ maxWidth: `calc(50% - 16px${letter ? ' - 32px' : ''})` }}>
{!hideMathSelector && (
<MathSelector
math={math}
index={index}
onMathSelect={onMathSelect}
areEventPropertiesNumericalAvailable={!!numericalPropertyNames.length}
style={{ maxWidth: '100%', width: 'initial' }}
/>
)}
</Col>
<Col>of</Col>
{!hideMathSelector && (
<>
<Col style={{ maxWidth: `calc(50% - 16px${letter ? ' - 32px' : ''})` }}>
<MathSelector
math={math}
index={index}
onMathSelect={onMathSelect}
areEventPropertiesNumericalAvailable={!!numericalPropertyNames.length}
style={{ maxWidth: '100%', width: 'initial' }}
/>
</Col>
{MATHS[math || '']?.onProperty && (
<>
<Col>of</Col>
<Col style={{ maxWidth: `calc(50% - 16px${letter ? ' - 32px' : ''})` }}>
<MathPropertySelector
name={name}
math={math}
mathProperty={mathProperty}
index={index}
onMathPropertySelect={onMathPropertySelect}
properties={numericalPropertyNames}
horizontalUI={horizontalUI}
/>
</Col>
</>
)}
</>
)}
<Col>{separatorWord}</Col>
</>
)}
<Col style={{ maxWidth: `calc(${hideMathSelector ? '100' : '50'}% - 16px)` }}>
Expand Down Expand Up @@ -188,15 +209,17 @@ export function ActionFilterRow({
</Col>
)}
</Row>
{!hideMathSelector && MATHS[math || '']?.onProperty && (
<MathPropertySelector
name={name}
math={math}
mathProperty={mathProperty}
index={index}
onMathPropertySelect={onMathPropertySelect}
properties={numericalPropertyNames}
/>
{!horizontalUI && !hideMathSelector && MATHS[math || '']?.onProperty && (
<Row align="middle">
<MathPropertySelector
name={name}
math={math}
mathProperty={mathProperty}
index={index}
onMathPropertySelect={onMathPropertySelect}
properties={numericalPropertyNames}
/>
</Row>
)}
{(!hidePropertySelector || (filter.properties && filter.properties.length > 0)) && (
<div style={{ paddingTop: 6 }}>
Expand Down Expand Up @@ -335,6 +358,7 @@ interface MathPropertySelectorProps {
index: number
onMathPropertySelect: (index: number, value: string) => any
properties: SelectOption[]
horizontalUI?: boolean
}

function MathPropertySelector(props: MathPropertySelectorProps): JSX.Element {
Expand All @@ -353,11 +377,10 @@ function MathPropertySelector(props: MathPropertySelectorProps): JSX.Element {
return (
<SelectGradientOverflow
showSearch
style={{ width: 150 }}
className={`property-select ${props.horizontalUI ? 'horizontal-ui' : ''}`}
onChange={(_: string, payload) => {
props.onMathPropertySelect(props.index, (payload as SelectOption)?.value)
}}
className="property-select"
value={props.mathProperty}
data-attr="math-property-select"
dropdownMatchSelectWidth={350}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/insights/InsightTabs/RetentionTab.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useRef } from 'react'
import { useValues, useActions } from 'kea'
import { PropertyFilters } from 'lib/components/PropertyFilters/PropertyFilters'
import { ActionFilterDropdown } from '../ActionFilter/ActionFilterDropdown'
import { ActionFilterDropdown } from '../ActionFilter/ActionFilterRow/ActionFilterDropdown'
import { entityFilterLogic } from '../ActionFilter/entityFilterLogic'

import { DownOutlined, InfoCircleOutlined, ExportOutlined } from '@ant-design/icons'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/sessions/filters/SessionsFilterBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useActions, useValues } from 'kea'
import { actionsModel } from '~/models/actionsModel'
import { ActionType, CohortType } from '~/types'
import { EntityTypes } from '~/types'
import { ActionInfo } from 'scenes/insights/ActionFilter/ActionFilterDropdown'
import { ActionInfo } from 'scenes/insights/ActionFilter/ActionFilterRow/ActionFilterDropdown'
import { FilterSelector, sessionsFiltersLogic } from 'scenes/sessions/filters/sessionsFiltersLogic'
import { Link } from 'lib/components/Link'
import { cohortsModel } from '~/models/cohortsModel'
Expand Down