Skip to content

Commit

Permalink
Merge branch 'master' into fix/insights-css
Browse files Browse the repository at this point in the history
# Conflicts:
#	frontend/__snapshots__/scenes-app-insights--funnel-historical-trends-edit.png
#	frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-breakdown-edit.png
#	frontend/__snapshots__/scenes-app-insights--funnel-left-to-right-edit.png
#	frontend/__snapshots__/scenes-app-insights--funnel-time-to-convert-edit.png
#	frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-breakdown-edit.png
#	frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-edit.png
  • Loading branch information
benjackwhite committed Nov 14, 2023
2 parents d2f06a3 + fb82110 commit 0cde87f
Show file tree
Hide file tree
Showing 25 changed files with 365 additions and 243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CopyToClipboardInline } from '../CopyToClipboard'
import { useValues } from 'kea'
import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { NewPropertyComponent } from 'scenes/persons/NewPropertyComponent'
import { NewProperty } from 'scenes/persons/NewProperty'
import { LemonCheckbox, LemonInput, Link } from '@posthog/lemon-ui'
import clsx from 'clsx'
import { PropertyDefinitionType } from '~/types'
Expand Down Expand Up @@ -351,7 +351,7 @@ export function PropertiesTable({
)}
</span>

{onEdit && <NewPropertyComponent editProperty={onEdit} />}
{onEdit && <NewProperty onSave={onEdit} />}
</div>
)}

Expand Down
13 changes: 9 additions & 4 deletions frontend/src/queries/nodes/InsightViz/TrendsSeries.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useValues, useActions } from 'kea'
import { groupsModel } from '~/models/groupsModel'
import { ActionFilter } from 'scenes/insights/filters/ActionFilter/ActionFilter'
import { InsightType, FilterType } from '~/types'
import { FilterType } from '~/types'
import { alphabet } from 'lib/utils'
import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
Expand All @@ -12,10 +12,15 @@ import { queryNodeToFilter } from '../InsightQuery/utils/queryNodeToFilter'
import { actionsAndEventsToSeries } from '../InsightQuery/utils/filtersToQueryNode'

import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
import { insightLogic } from 'scenes/insights/insightLogic'
import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'

export function TrendsSeries(): JSX.Element | null {
const { querySource, isTrends, isLifecycle, isStickiness, display, hasFormula } = useValues(insightVizDataLogic)
const { updateQuerySource } = useActions(insightVizDataLogic)
const { insightProps } = useValues(insightLogic)
const { querySource, isTrends, isLifecycle, isStickiness, display, hasFormula } = useValues(
insightVizDataLogic(insightProps)
)
const { updateQuerySource } = useActions(insightVizDataLogic(insightProps))

const { groupsTaxonomicTypes } = useValues(groupsModel)

Expand Down Expand Up @@ -52,7 +57,7 @@ export function TrendsSeries(): JSX.Element | null {
| StickinessQuery
| LifecycleQuery)
}}
typeKey={`trends_${InsightType.TRENDS}_data_exploration`}
typeKey={`${keyForInsightLogicProps('new')(insightProps)}-TrendsSeries`}
buttonCopy={`Add graph ${hasFormula ? 'variable' : 'series'}`}
showSeriesIndicator
showNestedArrow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { queryNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeT
import { actionsAndEventsToSeries } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'
import { FunnelsQuery } from '~/queries/schema'
import { isInsightQueryNode } from '~/queries/utils'
import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'

export const FUNNEL_STEP_COUNT_LIMIT = 20

Expand Down Expand Up @@ -50,7 +51,7 @@ export function FunnelsQuerySteps({ insightProps }: EditorFilterProps): JSX.Elem
bordered
filters={actionFilters}
setFilters={setActionFilters}
typeKey={`EditFunnel-action`}
typeKey={`${keyForInsightLogicProps('new')(insightProps)}-FunnelsQuerySteps`}
mathAvailability={MathAvailability.None}
hideDeleteBtn={filterSteps.length === 1}
buttonCopy="Add step"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Link } from 'lib/lemon-ui/Link'
import { LemonInput, LemonSelect } from '@posthog/lemon-ui'
import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
import { IconInfo } from '@posthog/icons'
import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'

export function RetentionSummary({ insightProps }: EditorFilterProps): JSX.Element {
const { showGroupsOptions } = useValues(groupsModel)
Expand Down Expand Up @@ -52,7 +53,7 @@ export function RetentionSummary({ insightProps }: EditorFilterProps): JSX.Eleme
updateInsightFilter({ target_entity: undefined })
}
}}
typeKey="retention-table"
typeKey={`${keyForInsightLogicProps('new')(insightProps)}-RetentionSummary`}
/>
</span>
<LemonSelect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFil
import { funnelDataLogic } from 'scenes/funnels/funnelDataLogic'
import { ExclusionRowSuffix } from './ExclusionRowSuffix'
import { ExclusionRow } from './ExclusionRow'
import { keyForInsightLogicProps } from 'scenes/insights/sharedUtils'

export function FunnelExclusionsFilter(): JSX.Element {
const { insightProps } = useValues(insightLogic)
Expand All @@ -35,7 +36,7 @@ export function FunnelExclusionsFilter(): JSX.Element {
ref={ref}
setFilters={setFilters}
filters={exclusionFilters}
typeKey="funnel-exclusions-filter"
typeKey={`${keyForInsightLogicProps('new')(insightProps)}-FunnelExclusionsFilter`}
addFilterDefaultOptions={{
id: '$pageview',
name: '$pageview',
Expand Down
129 changes: 129 additions & 0 deletions frontend/src/scenes/persons/NewProperty.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { useState } from 'react'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonInput, LemonLabel, LemonModal, LemonSegmentedButton } from '@posthog/lemon-ui'

interface NewPropertyInterface {
creating: boolean
propertyType: 'string' | 'boolean'
key?: string | null
value?: string | number
}

export interface NewPropertyProps {
onSave: (key: string, newValue?: string | number) => void
}

export function NewProperty({ onSave }: NewPropertyProps): JSX.Element {
const initialState = { creating: false, propertyType: 'string', value: '' } as NewPropertyInterface
const [state, setState] = useState(initialState)

const saveProperty = (): void => {
if (state.key && state.value !== undefined) {
onSave(state.key, state.value)
setState(initialState)
}
}

return (
<>
<LemonButton
data-attr="add-prop-button"
onClick={() => setState({ ...state, creating: true })}
type="primary"
>
New property
</LemonButton>
<LemonModal
isOpen={state.creating}
onClose={() => setState(initialState)}
title="Add new property"
footer={
<LemonButton
disabledReason={(!state.key || state.value === undefined) && 'Set a key and a value'}
type="secondary"
onClick={saveProperty}
>
Save
</LemonButton>
}
>
<div className="space-y-2">
<div>
<LemonLabel>Key</LemonLabel>
<LemonInput
id="propertyKey"
autoFocus
placeholder="try email, first_name, is_verified, membership_level, total_revenue"
onChange={(key) => setState({ ...state, key: key })}
autoComplete="off"
autoCapitalize="off"
/>
</div>
<div>
<LemonLabel>Type of Property</LemonLabel>
<LemonSegmentedButton
onChange={(value: 'string' | 'boolean') =>
setState({
...state,
propertyType: value,
value: value === 'string' ? '' : 'true',
})
}
value={state.propertyType}
options={[
{
value: 'string',
label: 'Text or Number',
},
{
value: 'boolean',
label: 'Boolean or Null',
},
]}
fullWidth
/>
</div>
<div>
<LemonLabel>Value</LemonLabel>
{state.propertyType === 'boolean' ? (
<LemonSegmentedButton
onChange={(value) =>
setState({
...state,
value: value,
})
}
fullWidth
value={state.value}
options={[
{
value: 'true',
label: 'True',
},
{
value: 'false',
label: 'False',
},
{
value: 'null',
label: 'Null',
},
]}
size="small"
/>
) : (
<LemonInput
id="propertyValue"
placeholder="try [email protected], gold, 1"
onChange={(value) => setState({ ...state, value: value })}
onKeyDown={(e) => e.key === 'Enter' && saveProperty()}
autoComplete="off"
autoCapitalize="off"
/>
)}
</div>
</div>
</LemonModal>
</>
)
}
126 changes: 0 additions & 126 deletions frontend/src/scenes/persons/NewPropertyComponent.tsx

This file was deleted.

Loading

0 comments on commit 0cde87f

Please sign in to comment.