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

refactor(insights): remove filter based card content #24050

Merged
merged 53 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e06088e
wip
thmsobrmlr Jul 29, 2024
84e90bd
support notebook editing state
thmsobrmlr Jul 29, 2024
cde9313
wip
thmsobrmlr Jul 29, 2024
88dd5af
funnel styles
thmsobrmlr Jul 29, 2024
110c9d5
fix funnel single step
thmsobrmlr Jul 29, 2024
eb73f1c
move query based insight one level out
thmsobrmlr Jul 29, 2024
82a4618
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
dc550bc
Update UI snapshots for `chromium` (2)
github-actions[bot] Jul 30, 2024
09e54a8
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
de34965
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
0c55662
Update UI snapshots for `chromium` (2)
github-actions[bot] Jul 30, 2024
75c5ae5
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
b3cba4f
Update UI snapshots for `chromium` (2)
github-actions[bot] Jul 30, 2024
44aa1b2
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
4ce23dc
Update UI snapshots for `chromium` (2)
github-actions[bot] Jul 30, 2024
0affc7c
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
195f5df
Update UI snapshots for `chromium` (2)
github-actions[bot] Jul 30, 2024
6183190
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
49f9c8e
Update UI snapshots for `chromium` (2)
github-actions[bot] Jul 30, 2024
497af03
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
09be652
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
64b9dc9
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
02ca3ee
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
535b199
fix stories
thmsobrmlr Jul 30, 2024
c70e1c7
remove FilterBasedCardContentProps
thmsobrmlr Jul 30, 2024
cae8f44
fix types
thmsobrmlr Jul 30, 2024
ea984dd
Merge branch 'master' into remove-filter-based-card-3
thmsobrmlr Jul 30, 2024
ce92f4b
Update UI snapshots for `chromium` (2)
github-actions[bot] Jul 30, 2024
eac43c8
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
077dd12
Update UI snapshots for `chromium` (2)
github-actions[bot] Jul 30, 2024
75d6d78
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
7e5721d
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
ec15d11
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
7f5dec5
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
b616aeb
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
f816f18
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
1d537e6
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
fd62d3f
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
2d74922
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
5e956c3
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
487c412
dont snapshot all exporter stories (flappy)
thmsobrmlr Jul 30, 2024
35dbcec
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 30, 2024
08a02e4
Merge branch 'master' into remove-filter-based-card-3
thmsobrmlr Aug 1, 2024
29d1809
try a hacky fix for e2e tests
thmsobrmlr Aug 1, 2024
311436b
also add intercepts
thmsobrmlr Aug 1, 2024
0597d23
why does this work locally?!
thmsobrmlr Aug 1, 2024
4f66284
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 1, 2024
c830a80
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 1, 2024
7a3fedb
add .cy to e2e test file name
thmsobrmlr Aug 1, 2024
98584ed
use a blunt hammer to get this working
thmsobrmlr Aug 1, 2024
25f7bcd
remove intercepts and color hack
thmsobrmlr Aug 1, 2024
3159251
Merge branch 'master' into remove-filter-based-card-3
thmsobrmlr Aug 2, 2024
dde2f15
try 300ms
thmsobrmlr Aug 2, 2024
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
@@ -1,8 +1,11 @@
import 'cypress-network-idle'

import { urls } from 'scenes/urls'

describe('insights date picker', () => {
beforeEach(() => {
cy.visit(urls.insightNew())
cy.waitForNetworkIdle(2000)
thmsobrmlr marked this conversation as resolved.
Show resolved Hide resolved
})

it('Can set the date filter and show the right grouping interval', () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/exporter-exporter--dashboard--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/exporter-exporter--dashboard--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did manually export one insight of each kind and compared it against the previous version - couldn't replicate the shrinking as seen in these snapshot tests e.g. this is the lifecycle insight with the new query based card:
export-lifecycle

Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified frontend/__snapshots__/scenes-app-dashboards--edit--light.png
Binary file modified frontend/__snapshots__/scenes-app-dashboards--show--dark.png
Binary file modified frontend/__snapshots__/scenes-app-dashboards--show--light.png
15 changes: 8 additions & 7 deletions frontend/src/exporter/ExportedInsight/ExportedInsight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import './ExportedInsight.scss'

import clsx from 'clsx'
import { BindLogic } from 'kea'
import { FilterBasedCardContent } from 'lib/components/Cards/InsightCard/InsightCard'
import { TopHeading } from 'lib/components/Cards/InsightCard/TopHeading'
import { InsightLegend } from 'lib/components/InsightLegend/InsightLegend'
import {
Expand Down Expand Up @@ -48,7 +47,7 @@ export function ExportedInsight({

const insightLogicProps: InsightLogicProps = {
dashboardItemId: insight.short_id,
cachedInsight: legacyInsight, // TODO: use query based insight here
cachedInsight: insight,
doNotLoad: true,
}

Expand Down Expand Up @@ -97,11 +96,13 @@ export function ExportedInsight({
'ExportedInsight__content--with-watermark': showWatermark,
})}
>
{legacyInsight.query ? (
<Query query={legacyInsight.query} cachedResults={legacyInsight} readOnly />
) : (
<FilterBasedCardContent insight={legacyInsight} insightProps={insightLogicProps} />
)}
<Query
query={insight.query}
cachedResults={insight}
readOnly
context={{ insightProps: insightLogicProps }}
embedded
/>
{showLegend && (
<div className="p-4">
<InsightLegend horizontal readOnly />
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/exporter/Exporter.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const Template: StoryFn<typeof Exporter> = (props) => {

export const TrendsLineInsight: Story = Template.bind({})
TrendsLineInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsLine.json') }
TrendsLineInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsLineInsightLegend: Story = Template.bind({})
TrendsLineInsightLegend.args = {
Expand All @@ -67,38 +68,47 @@ TrendsLineMultiInsight.args = {
TrendsLineMultiInsight.parameters = {
mockDate: '2023-07-10',
}
TrendsLineMultiInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsLineBreakdownInsight: Story = Template.bind({})
TrendsLineBreakdownInsight.args = {
insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsLineBreakdown.json'),
}
TrendsLineBreakdownInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsBarInsight: Story = Template.bind({})
TrendsBarInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsBar.json') }
TrendsBarInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsBarBreakdownInsight: Story = Template.bind({})
TrendsBarBreakdownInsight.args = {
insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsBarBreakdown.json'),
}
TrendsBarBreakdownInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsValueInsight: Story = Template.bind({})
TrendsValueInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsValue.json') }
TrendsValueInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsValueBreakdownInsight: Story = Template.bind({})
TrendsValueBreakdownInsight.args = {
insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsValueBreakdown.json'),
}
TrendsValueBreakdownInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsAreaInsight: Story = Template.bind({})
TrendsAreaInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsArea.json') }
TrendsAreaInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsAreaBreakdownInsight: Story = Template.bind({})
TrendsAreaBreakdownInsight.args = {
insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsAreaBreakdown.json'),
}
TrendsAreaBreakdownInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsNumberInsight: Story = Template.bind({})
TrendsNumberInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsNumber.json') }
TrendsNumberInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const TrendsTableInsight: Story = Template.bind({})
TrendsTableInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/trendsTable.json') }
Expand Down Expand Up @@ -183,9 +193,11 @@ RetentionBreakdownInsight.args = {

export const LifecycleInsight: Story = Template.bind({})
LifecycleInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/lifecycle.json') }
LifecycleInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const StickinessInsight: Story = Template.bind({})
StickinessInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/stickiness.json') }
StickinessInsight.tags = ['test-skip'] // doesn't produce a helpful reference image, as canvas can't be captured

export const UserPathsInsight: Story = Template.bind({})
UserPathsInsight.args = { insight: require('../mocks/fixtures/api/projects/team_id/insights/userPaths.json') }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Meta, Story } from '@storybook/react'
import { useState } from 'react'

import { filtersToQueryNode } from '~/queries/nodes/InsightQuery/utils/filtersToQueryNode'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
import { NodeKind } from '~/queries/schema'
import { ChartDisplayType, InsightColor, InsightModel, InsightShortId, TrendsFilterType } from '~/types'

Expand All @@ -12,6 +13,7 @@ import EXAMPLE_LIFECYCLE from '../../../../mocks/fixtures/api/projects/team_id/i
import EXAMPLE_RETENTION from '../../../../mocks/fixtures/api/projects/team_id/insights/retention.json'
import EXAMPLE_STICKINESS from '../../../../mocks/fixtures/api/projects/team_id/insights/stickiness.json'
import EXAMPLE_TRENDS from '../../../../mocks/fixtures/api/projects/team_id/insights/trendsLine.json'
import EXAMPLE_TRENDS_BREAKDOWN_MANY from '../../../../mocks/fixtures/api/projects/team_id/insights/trendsLineBreakdownMany.json'
import EXAMPLE_TRENDS_MULTI from '../../../../mocks/fixtures/api/projects/team_id/insights/trendsLineMulti.json'
import EXAMPLE_TRENDS_PIE from '../../../../mocks/fixtures/api/projects/team_id/insights/trendsPie.json'
import EXAMPLE_TRENDS_TABLE from '../../../../mocks/fixtures/api/projects/team_id/insights/trendsTable.json'
Expand All @@ -23,6 +25,7 @@ import { InsightCard as InsightCardComponent } from './index'
const examples = [
EXAMPLE_TRENDS,
EXAMPLE_TRENDS_MULTI,
EXAMPLE_TRENDS_BREAKDOWN_MANY,
EXAMPLE_TRENDS_HORIZONTAL_BAR,
EXAMPLE_TRENDS_TABLE,
EXAMPLE_TRENDS_PIE,
Expand Down Expand Up @@ -74,13 +77,11 @@ export const InsightCard: Story = (args) => {
<div style={{ display: 'grid', gap: '1rem', gridTemplateColumns: 'repeat(2, 1fr)', minWidth: '50rem' }}>
{!wasItemRemoved && (
<InsightCardComponent
insight={
{
...EXAMPLE_TRENDS,
name: args.insightName,
description: args.insightDescription,
} as unknown as InsightModel
}
insight={getQueryBasedInsightModel({
...EXAMPLE_TRENDS,
name: args.insightName,
description: args.insightDescription,
} as unknown as InsightModel)}
ribbonColor={insightColor}
loading={args.loading}
apiErrored={args.apiErrored}
Expand All @@ -95,15 +96,13 @@ export const InsightCard: Story = (args) => {
/>
)}
<InsightCardComponent
insight={
{
...EXAMPLE_TRENDS,
name: 'Wow, this name is really super duper ginormously off the charts long! How do we even manage to fit it in an insight card without it breaking?!',
description:
'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.',
tags: ['every', 'green', 'bus', 'drives', 'fast', 'face'],
} as unknown as InsightModel
}
insight={getQueryBasedInsightModel({
...EXAMPLE_TRENDS,
name: 'Wow, this name is really super duper ginormously off the charts long! How do we even manage to fit it in an insight card without it breaking?!',
description:
'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.',
tags: ['every', 'green', 'bus', 'drives', 'fast', 'face'],
} as unknown as InsightModel)}
rename={() => {}}
duplicate={() => {}}
placement="SavedInsightGrid"
Expand All @@ -114,9 +113,12 @@ export const InsightCard: Story = (args) => {
showResizeHandles={args.resizable}
/>
<InsightCardComponent
insight={
{ ...EXAMPLE_TRENDS, name: '', description: '', last_modified_by: null } as unknown as InsightModel
}
insight={getQueryBasedInsightModel({
...EXAMPLE_TRENDS,
name: '',
description: '',
last_modified_by: null,
} as unknown as InsightModel)}
rename={() => {}}
duplicate={() => {}}
placement="SavedInsightGrid"
Expand All @@ -127,14 +129,12 @@ export const InsightCard: Story = (args) => {
showResizeHandles={args.resizable}
/>
<InsightCardComponent
insight={
{
...EXAMPLE_FUNNEL,
short_id: 'funnel_empty' as InsightShortId,
filters: { ...EXAMPLE_FUNNEL.filters, events: EXAMPLE_FUNNEL.filters.events?.slice(0, 1) },
name: 'What a pitiful funnel',
} as unknown as InsightModel
}
insight={getQueryBasedInsightModel({
...EXAMPLE_FUNNEL,
short_id: 'funnel_empty' as InsightShortId,
filters: { ...EXAMPLE_FUNNEL.filters, events: EXAMPLE_FUNNEL.filters.events?.slice(0, 1) },
name: 'What a pitiful funnel',
} as unknown as InsightModel)}
rename={() => {}}
duplicate={() => {}}
placement="SavedInsightGrid"
Expand All @@ -145,7 +145,10 @@ export const InsightCard: Story = (args) => {
showResizeHandles={args.resizable}
/>
<InsightCardComponent
insight={{ ...EXAMPLE_FUNNEL, name: 'What a plentiful funnel' } as unknown as InsightModel}
insight={getQueryBasedInsightModel({
...EXAMPLE_FUNNEL,
name: 'What a plentiful funnel',
} as unknown as InsightModel)}
rename={() => {}}
duplicate={() => {}}
placement="SavedInsightGrid"
Expand All @@ -156,15 +159,13 @@ export const InsightCard: Story = (args) => {
showResizeHandles={args.resizable}
/>
<InsightCardComponent
insight={
{
...EXAMPLE_TRENDS,
filters: {
...EXAMPLE_TRENDS.filters,
display: 'totally_wrong_display_type' as ChartDisplayType,
} as TrendsFilterType,
} as unknown as InsightModel
}
insight={getQueryBasedInsightModel({
...EXAMPLE_TRENDS,
filters: {
...EXAMPLE_TRENDS.filters,
display: 'totally_wrong_display_type' as ChartDisplayType,
} as TrendsFilterType,
} as unknown as InsightModel)}
rename={() => {}}
duplicate={() => {}}
placement="SavedInsightGrid"
Expand All @@ -177,7 +178,7 @@ export const InsightCard: Story = (args) => {
{examples.map((e) => (
<InsightCardComponent
key={e.id}
insight={e}
insight={getQueryBasedInsightModel(e)}
rename={() => {}}
duplicate={() => {}}
placement="SavedInsightGrid"
Expand Down Expand Up @@ -206,12 +207,12 @@ export const QueryInsightCard: Story = (args) => {
kind: NodeKind.InsightVizNode,
source: filtersToQueryNode(insight.filters),
}
const { filters: _, ...baseInsight } = insight
return (
<InsightCardComponent
key={insight.id}
insight={{
...insight,
filters: {},
...baseInsight,
query,
}}
rename={() => {}}
Expand Down
Loading
Loading