Skip to content

Commit

Permalink
Merge branch 'master' into fix/debounc-resizes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Nov 23, 2023
2 parents 78dacdb + 6e51b92 commit f9053c6
Show file tree
Hide file tree
Showing 34 changed files with 118 additions and 29 deletions.
7 changes: 3 additions & 4 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { toMatchImageSnapshot } from 'jest-image-snapshot'
import { getStoryContext, TestRunnerConfig, TestContext } from '@storybook/test-runner'
import { getStoryContext, TestRunnerConfig, TestContext, waitForPageReady } from '@storybook/test-runner'
import type { Locator, Page, LocatorScreenshotOptions } from '@playwright/test'
import type { Mocks } from '~/mocks/utils'
import { StoryContext } from '@storybook/types'
Expand Down Expand Up @@ -110,8 +110,7 @@ async function expectStoryToMatchSnapshot(
check = expectStoryToMatchComponentSnapshot
}

// Wait for story to load
await page.waitForSelector('.sb-show-preparing-story', { state: 'detached' })
await waitForPageReady(page)
await page.evaluate(() => {
// Stop all animations for consistent snapshots
document.body.classList.add('storybook-test-runner')
Expand All @@ -123,7 +122,7 @@ async function expectStoryToMatchSnapshot(
await page.waitForSelector(waitForSelector)
}

await page.waitForTimeout(400) // Wait for animations to finish
await page.waitForTimeout(400) // Wait for effects to finish

// Wait for all images to load
await page.waitForFunction(() =>
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.
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.
Binary file modified frontend/__snapshots__/lemon-ui-lemon-select--long-options.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__/lemon-ui-utilities--overview.png
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.
Binary file modified frontend/__snapshots__/scenes-other-toolbar--heatmap-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IconExternal } from '@posthog/icons'
import { LemonButton, LemonSkeleton } from '@posthog/lemon-ui'
import { LemonButton, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'
import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { useEffect, useRef, useState } from 'react'
Expand All @@ -8,6 +8,11 @@ import { themeLogic } from '../../themeLogic'
import { SidePanelPaneHeader } from '../components/SidePanelPane'
import { POSTHOG_WEBSITE_ORIGIN, sidePanelDocsLogic } from './sidePanelDocsLogic'

type Menu = {
name: string
url?: string
}

function SidePanelDocsSkeleton(): JSX.Element {
return (
<div className="absolute inset-0 p-4 space-y-2">
Expand All @@ -23,12 +28,50 @@ function SidePanelDocsSkeleton(): JSX.Element {
)
}

function Menu({
menu,
activeMenuName,
onChange,
}: {
menu: Menu[]
activeMenuName: string | null
onChange: (newValue: string | null) => void
}): JSX.Element {
return (
<div className="mr-auto">
<LemonSelect
placeholder="Navigate"
dropdownMatchSelectWidth={false}
onChange={onChange}
size="small"
value={activeMenuName}
options={menu.map(({ name }) => ({ label: name, value: name }))}
/>
</div>
)
}

export const SidePanelDocs = (): JSX.Element => {
const { iframeSrc, currentUrl } = useValues(sidePanelDocsLogic)
const { updatePath, unmountIframe, closeSidePanel, handleExternalUrl } = useActions(sidePanelDocsLogic)
const ref = useRef<HTMLIFrameElement>(null)
const [ready, setReady] = useState(false)
const { isDarkModeOn } = useValues(themeLogic)
const [menu, setMenu] = useState<Menu[] | null>(null)
const [activeMenuName, setActiveMenuName] = useState<string | null>(null)

const handleMenuChange = (newValue: string | null): void => {
const url = menu?.find(({ name }: Menu) => name === newValue)?.url
if (url) {
ref.current?.contentWindow?.postMessage(
{
type: 'navigate',
url,
},
'*'
)
}
}

useEffect(() => {
ref.current?.contentWindow?.postMessage(
Expand Down Expand Up @@ -57,6 +100,15 @@ export const SidePanelDocs = (): JSX.Element => {
handleExternalUrl(event.data.url)
return
}
if (event.data.type === 'docs-menu') {
setMenu(event.data.menu)
return
}

if (event.data.type === 'docs-active-menu') {
setActiveMenuName(event.data.activeMenuName)
return
}

console.warn('Unhandled iframe message from Docs:', event.data)
}
Expand All @@ -79,6 +131,7 @@ export const SidePanelDocs = (): JSX.Element => {
return (
<>
<SidePanelPaneHeader>
{menu && <Menu menu={menu} activeMenuName={activeMenuName} onChange={handleMenuChange} />}
<LemonButton
size="small"
sideIcon={<IconExternal />}
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/lib/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,16 @@ export function idToKey(array: Record<string, any>[], keyField: string = 'id'):
return object
}

export function delay(ms: number): Promise<number> {
return new Promise((resolve) => window.setTimeout(resolve, ms))
export function delay(ms: number, signal?: AbortSignal): Promise<void> {
return new Promise((resolve, reject) => {
const timeoutId = setTimeout(resolve, ms)
if (signal) {
signal.addEventListener('abort', () => {
clearTimeout(timeoutId)
reject(new DOMException('Aborted', 'AbortError'))
})
}
})
}

export function clearDOMTextSelection(): void {
Expand Down
10 changes: 2 additions & 8 deletions frontend/src/queries/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
isTimeToSeeDataSessionsQuery,
} from './utils'

const QUERY_ASYNC_MAX_INTERVAL_SECONDS = 10
const QUERY_ASYNC_MAX_INTERVAL_SECONDS = 5
const QUERY_ASYNC_TOTAL_POLL_SECONDS = 300

//get export context for a given query
Expand Down Expand Up @@ -115,15 +115,9 @@ async function executeQuery<N extends DataNode = DataNode>(
let currentDelay = 300 // start low, because all queries will take at minimum this

while (performance.now() - pollStart < QUERY_ASYNC_TOTAL_POLL_SECONDS * 1000) {
await delay(currentDelay)
await delay(currentDelay, methodOptions?.signal)
currentDelay = Math.min(currentDelay * 2, QUERY_ASYNC_MAX_INTERVAL_SECONDS * 1000)

if (methodOptions?.signal?.aborted) {
const customAbortError = new Error('Query aborted')
customAbortError.name = 'AbortError'
throw customAbortError
}

const statusResponse = await api.queryStatus.get(response.id)

if (statusResponse.complete || statusResponse.error) {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/funnels/FunnelBarGraph/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface BarProps {
wrapperWidth: number
}
type LabelPosition = 'inside' | 'outside'

export function Bar({
percentage: conversionPercentage,
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function FunnelBarGraph({
) : null}
</header>
<div className="funnel-inner-viz">
<div className={clsx('funnel-bar-wrapper', { breakdown: isBreakdown })}>
<div className={clsx('funnel-bar-wrapper', { breakdown: isBreakdown })} aria-busy={!width}>
{!width ? null : isBreakdown ? (
<>
{step?.nested_breakdown?.map((breakdown, index) => {
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@
"optionalDependencies": {
"fsevents": "^2.3.2"
},
"pnpm": {
"overrides": {
"playwright": "1.32.2"
}
},
"lint-staged": {
"*.{json,yaml,yml}": "prettier --write",
"*.{css,scss}": [
Expand Down
19 changes: 8 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 33 additions & 2 deletions posthog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
)
from posthog.warehouse.models import DataWarehouseTable

admin.site.register(DataWarehouseTable)


class DashboardTileInline(admin.TabularInline):
extra = 0
Expand Down Expand Up @@ -81,6 +79,39 @@ def organization_link(self, dashboard: Dashboard):
)


@admin.register(DataWarehouseTable)
class DataWarehouseTableAdmin(admin.ModelAdmin):
list_display = (
"id",
"name",
"format",
"url_pattern",
"team_link",
"organization_link",
"created_at",
"created_by",
)
list_display_links = ("id", "name")
list_select_related = ("team", "team__organization")
search_fields = ("id", "name", "team__name", "team__organization__name")
autocomplete_fields = ("team", "created_by")
ordering = ("-created_at",)

def team_link(self, dashboard: Dashboard):
return format_html(
'<a href="/admin/posthog/team/{}/change/">{}</a>',
dashboard.team.pk,
dashboard.team.name,
)

def organization_link(self, dashboard: Dashboard):
return format_html(
'<a href="/admin/posthog/organization/{}/change/">{}</a>',
dashboard.team.organization.pk,
dashboard.team.organization.name,
)


@admin.register(Text)
class TextAdmin(admin.ModelAdmin):
autocomplete_fields = ("created_by", "last_modified_by", "team")
Expand Down
1 change: 1 addition & 0 deletions posthog/warehouse/models/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"Array": StringArrayDatabaseField,
"Map": StringJSONDatabaseField,
"Bool": BooleanDatabaseField,
"Decimal": IntegerDatabaseField,
}

ExtractErrors = {
Expand Down

0 comments on commit f9053c6

Please sign in to comment.