Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Nov 8, 2023
1 parent a22a945 commit 8c2aded
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ interface InsightVizNodeViewProps {
/** Query is embedded inside another bordered component */
embedded?: boolean
suppressSessionAnalysisWarning?: boolean
hidePersonsModal?: boolean
}

/** Base class for insight query nodes. Should not be used directly. */
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/scenes/insights/insightLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { isInsightVizNode } from '~/queries/utils'
import { userLogic } from 'scenes/userLogic'
import { transformLegacyHiddenLegendKeys } from 'scenes/funnels/funnelUtils'
import { summarizeInsight } from 'scenes/insights/summarizeInsight'
import { InsightVizNode } from '~/queries/schema'

const IS_TEST_MODE = process.env.NODE_ENV === 'test'
export const UNSAVED_INSIGHT_MIN_REFRESH_INTERVAL_MINUTES = 3
Expand Down Expand Up @@ -540,6 +541,7 @@ export const insightLogic = kea<insightLogicType>([
)
},
],
showPersonsModal: [() => [(_, p) => p.query], (query?: InsightVizNode) => query && query.hidePersonsModal],
}),
listeners(({ actions, selectors, values }) => ({
setFiltersMerge: ({ filters }) => {
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/scenes/insights/views/BoldNumber/BoldNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ function useBoldNumberTooltip({
export function BoldNumber({ showPersonsModal = true }: ChartParams): JSX.Element {
const { insightProps } = useValues(insightLogic)
const { insightData, trendsFilter } = useValues(insightVizDataLogic(insightProps))
const { hidePersonsModal } = insightProps

const [isTooltipShown, setIsTooltipShown] = useState(false)
const valueRef = useBoldNumberTooltip({ showPersonsModal, isTooltipShown })
Expand All @@ -100,7 +99,7 @@ export function BoldNumber({ showPersonsModal = true }: ChartParams): JSX.Elemen
className={clsx('BoldNumber__value', showPersonsModal ? 'cursor-pointer' : 'cursor-default')}
onClick={
// != is intentional to catch undefined too
showPersonsModal && !hidePersonsModal && resultSeries.aggregated_value != null
showPersonsModal && resultSeries.aggregated_value != null
? () => {
if (resultSeries.persons?.url) {
openPersonsModal({
Expand All @@ -118,7 +117,7 @@ export function BoldNumber({ showPersonsModal = true }: ChartParams): JSX.Elemen
{formatAggregationAxisValue(trendsFilter, resultSeries.aggregated_value)}
</div>
</Textfit>
{showComparison && <BoldNumberComparison showPersonsModal={showPersonsModal && !hidePersonsModal} />}
{showComparison && <BoldNumberComparison showPersonsModal={showPersonsModal} />}
</div>
) : (
<InsightEmptyState />
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/scenes/insights/views/WorldMap/WorldMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ export function WorldMap({ showPersonsModal = true }: ChartParams): JSX.Element
const { insightProps } = useValues(insightLogic)
const { countryCodeToSeries, maxAggregatedValue } = useValues(worldMapLogic(insightProps))
const { showTooltip, hideTooltip, updateTooltipCoordinates } = useActions(worldMapLogic(insightProps))
const { hidePersonsModal, chartRenderingMetadata } = insightProps
const { chartRenderingMetadata } = insightProps
const renderingMetadata = chartRenderingMetadata?.[ChartDisplayType.WorldMap]

const svgRef = useWorldMapTooltip(showPersonsModal && !hidePersonsModal)
const svgRef = useWorldMapTooltip(showPersonsModal)

return (
<WorldMapSVG
showPersonsModal={showPersonsModal && !hidePersonsModal}
showPersonsModal={showPersonsModal}
countryCodeToSeries={countryCodeToSeries}
maxAggregatedValue={maxAggregatedValue}
showTooltip={showTooltip}
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/scenes/trends/Trends.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface Props {

export function TrendInsight({ view }: Props): JSX.Element {
const { insightMode } = useValues(insightSceneLogic)
const { insightProps } = useValues(insightLogic)
const { insightProps, showPersonsModal } = useValues(insightLogic)

const { display, series, breakdown, loadMoreBreakdownUrl, breakdownValuesLoading } = useValues(
trendsDataLogic(insightProps)
Expand All @@ -30,10 +30,10 @@ export function TrendInsight({ view }: Props): JSX.Element {
display === ChartDisplayType.ActionsAreaGraph ||
display === ChartDisplayType.ActionsBar
) {
return <ActionsLineGraph />
return <ActionsLineGraph showPersonsModal={showPersonsModal} />
}
if (display === ChartDisplayType.BoldNumber) {
return <BoldNumber />
return <BoldNumber showPersonsModal={showPersonsModal} />
}
if (display === ChartDisplayType.ActionsTable) {
const ActionsTable = InsightsTable
Expand All @@ -47,13 +47,13 @@ export function TrendInsight({ view }: Props): JSX.Element {
)
}
if (display === ChartDisplayType.ActionsPie) {
return <ActionsPie />
return <ActionsPie showPersonsModal={showPersonsModal} />
}
if (display === ChartDisplayType.ActionsBarValue) {
return <ActionsHorizontalBar />
return <ActionsHorizontalBar showPersonsModal={showPersonsModal} />
}
if (display === ChartDisplayType.WorldMap) {
return <WorldMap />
return <WorldMap showPersonsModal={showPersonsModal} />
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/trends/viz/ActionsHorizontalBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function ActionsHorizontalBar({ inCardView, showPersonsModal = true }: Ch
datasets={data}
labels={data[0].labels}
hiddenLegendKeys={hiddenLegendKeys}
showPersonsModal={showPersonsModal && !insightProps.hidePersonsModal}
showPersonsModal={showPersonsModal}
trendsFilter={trendsFilter}
formula={formula}
showValueOnSeries={showValueOnSeries}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/trends/viz/ActionsLineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function ActionsLineGraph({
labels={(indexedResults[0] && indexedResults[0].labels) || []}
inSharedMode={inSharedMode}
labelGroupType={labelGroupType}
showPersonsModal={showPersonsModal && !insightProps.hidePersonsModal}
showPersonsModal={showPersonsModal}
trendsFilter={trendsFilter}
formula={formula}
showValueOnSeries={showValueOnSeries}
Expand All @@ -76,7 +76,7 @@ export function ActionsLineGraph({
isArea={display === ChartDisplayType.ActionsAreaGraph}
incompletenessOffsetFromEnd={incompletenessOffsetFromEnd}
onClick={
!showPersonsModal || insightProps.hidePersonsModal || isMultiSeriesFormula(formula)
!showPersonsModal || isMultiSeriesFormula(formula)
? undefined
: (payload) => {
const { index, points, crossDataset } = payload
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/trends/viz/ActionsPie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function ActionsPie({ inSharedMode, inCardView, showPersonsModal = true }
labels={data[0].labels}
labelGroupType={labelGroupType}
inSharedMode={!!inSharedMode}
showPersonsModal={showPersonsModal && !insightProps.hidePersonsModal}
showPersonsModal={showPersonsModal}
trendsFilter={trendsFilter}
formula={formula}
showValueOnSeries={showValueOnSeries}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/scenes/web-analytics/WebAnalyticsTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export const WebStatsTrendTile = ({ query }: { query: InsightVizNode }): JSX.Ele
}),
},
},
hidePersonsModal: true,
},
}
}, [onWorldMapClick])
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/scenes/web-analytics/webAnalyticsLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
filterTestAccounts: true,
properties: webAnalyticsFilters,
},
hidePersonsModal: true,
},
},
{
Expand Down Expand Up @@ -288,6 +289,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
filterTestAccounts: true,
properties: webAnalyticsFilters,
},
hidePersonsModal: true,
},
},
{
Expand Down Expand Up @@ -316,6 +318,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
properties: webAnalyticsFilters,
},
suppressSessionAnalysisWarning: true,
hidePersonsModal: true,
},
},
],
Expand Down Expand Up @@ -501,6 +504,7 @@ export const webAnalyticsLogic = kea<webAnalyticsLogicType>([
filterTestAccounts: true,
properties: webAnalyticsFilters,
},
hidePersonsModal: true,
},
},
{
Expand Down
1 change: 0 additions & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,6 @@ export interface InsightLogicProps {
query?: InsightVizNode
setQuery?: (node: InsightVizNode) => void

hidePersonsModal?: boolean
/** chart-specific rendering context **/
chartRenderingMetadata?: ChartRenderingMetadata
}
Expand Down

0 comments on commit 8c2aded

Please sign in to comment.