Skip to content

Commit

Permalink
Merge branch 'master' into remove-3000-flag
Browse files Browse the repository at this point in the history
# Conflicts:
#	frontend/__snapshots__/scenes-app-sidepanels--side-panel-docs.png
#	frontend/src/lib/lemon-ui/Link/Link.tsx
  • Loading branch information
thmsobrmlr committed Dec 21, 2023
2 parents 25f258f + 8f33ae0 commit b38a38d
Show file tree
Hide file tree
Showing 25 changed files with 393 additions and 115 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IconExternal } from '@posthog/icons'
import { IconExternal, IconHome } from '@posthog/icons'
import { LemonButton, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'
import clsx from 'clsx'
import { useActions, useValues } from 'kea'
Expand Down Expand Up @@ -28,29 +28,6 @@ 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)
Expand Down Expand Up @@ -131,7 +108,33 @@ export const SidePanelDocs = (): JSX.Element => {
return (
<>
<SidePanelPaneHeader>
{menu && <Menu menu={menu} activeMenuName={activeMenuName} onChange={handleMenuChange} />}
<LemonButton
size="small"
sideIcon={<IconHome />}
type="secondary"
onClick={() => {
ref.current?.contentWindow?.postMessage(
{
type: 'navigate',
url: '/docs',
},
'*'
)
}}
/>

{menu && (
<LemonSelect
placeholder="Navigate"
dropdownMatchSelectWidth={false}
onChange={handleMenuChange}
size="small"
value={activeMenuName}
options={menu.map(({ name }) => ({ label: name, value: name }))}
/>
)}

<div className="flex-1" />
<LemonButton
size="small"
sideIcon={<IconExternal />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { actions, afterMount, beforeUnmount, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { router } from 'kea-router'

import { SidePanelTab } from '~/types'
import { sceneLogic } from 'scenes/sceneLogic'

import { sidePanelStateLogic } from '../sidePanelStateLogic'
import type { sidePanelDocsLogicType } from './sidePanelDocsLogicType'
Expand All @@ -26,10 +25,10 @@ export const sidePanelDocsLogic = kea<sidePanelDocsLogicType>([
path(['scenes', 'navigation', 'sidepanel', 'sidePanelDocsLogic']),
connect({
actions: [sidePanelStateLogic, ['openSidePanel', 'closeSidePanel']],
values: [sceneLogic, ['sceneConfig']],
}),

actions({
openDocsPage: (urlOrPath: string) => ({ urlOrPath }),
updatePath: (path: string) => ({ path }),
setInitialPath: (path: string) => ({ path }),
unmountIframe: true,
Expand Down Expand Up @@ -68,9 +67,11 @@ export const sidePanelDocsLogic = kea<sidePanelDocsLogicType>([
}),

listeners(({ actions, values }) => ({
openDocsPage: ({ urlOrPath }) => {
actions.setInitialPath(getPathFromUrl(urlOrPath))
actions.openSidePanel(SidePanelTab.Docs)
openSidePanel: ({ options }) => {
if (options) {
const initialPath = getPathFromUrl(options)
actions.setInitialPath(initialPath)
}
},

unmountIframe: () => {
Expand All @@ -82,4 +83,14 @@ export const sidePanelDocsLogic = kea<sidePanelDocsLogicType>([
router.actions.push(getPathFromUrl(urlOrPath))
},
})),

afterMount(({ actions, values }) => {
if (values.sceneConfig?.defaultDocsPath) {
actions.setInitialPath(values.sceneConfig?.defaultDocsPath)
}
}),

beforeUnmount(({ actions, values }) => {
actions.setInitialPath(values.currentPath ?? '/docs')
}),
])
4 changes: 2 additions & 2 deletions frontend/src/lib/lemon-ui/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const Link: React.FC<LinkProps & React.RefAttributes<HTMLElement>> = Reac
})

// NOTE: Temporarily disabled - owner @corywatilo
// const { openDocsPage } = useActions(sidePanelDocsLogic)
// const { openSidePanel } = useActions(sidePanelStateLogic)

const onClick = (event: React.MouseEvent<HTMLElement>): void => {
if (event.metaKey || event.ctrlKey) {
Expand All @@ -103,7 +103,7 @@ export const Link: React.FC<LinkProps & React.RefAttributes<HTMLElement>> = Reac
// NOTE: Temporarily disabled - owner @corywatilo
// if (typeof to === 'string' && isPostHogComDocs(to)) {
// event.preventDefault()
// openDocsPage(to)
// openSidePanel(SidePanelTab.Docs, to)
// return
// }

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/queries/nodes/DataTable/DataTableExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function startDownload(query: DataTableNode, onlySelectedColumns: boolean)
)
} else if (isPersonsNode(query.source)) {
exportContext['columns'] = exportContext['columns'].map((c: string) =>
removeExpressionComment(c) === 'person' ? 'properties.email' : c
removeExpressionComment(c) === 'person' ? 'email' : c
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export const LineGraph = (): JSX.Element => {
tooltipEl.classList.remove('above', 'below', 'no-transform')
tooltipEl.classList.add(tooltip.yAlign || 'no-transform')
tooltipEl.style.opacity = '1'
tooltipEl.style.display = 'initial'

if (tooltip.body) {
const referenceDataPoint = tooltip.dataPoints[0] // Use this point as reference to get the date
Expand Down Expand Up @@ -225,8 +224,8 @@ export const LineGraph = (): JSX.Element => {
? chartClientLeft + tooltip.caretX - tooltipEl.clientWidth - 8 // If tooltip is too large (or close to the edge), show it to the left of the data point instead
: defaultOffsetLeft

tooltipEl.style.top = Math.min(tooltipClientTop, window.innerHeight) + 'px'
tooltipEl.style.left = Math.min(tooltipClientLeft, window.innerWidth) + 'px'
tooltipEl.style.top = tooltipClientTop + 'px'
tooltipEl.style.left = tooltipClientLeft + 'px'
},
},
},
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,12 @@
"hogql": {
"type": "string"
},
"limit": {
"type": "integer"
},
"offset": {
"type": "integer"
},
"results": {
"items": {
"items": {},
Expand All @@ -1067,7 +1073,7 @@
"type": "array"
}
},
"required": ["columns", "types", "results", "hogql"],
"required": ["columns", "types", "results", "hogql", "limit", "offset"],
"type": "object"
},
"FeaturePropertyFilter": {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ export interface EventsQueryResponse {
hogql: string
hasMore?: boolean
timings?: QueryTiming[]
/** @asType integer */
limit: number
/** @asType integer */
offset: number
}
export interface EventsQueryPersonColumn {
uuid: string
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/scenes/funnels/useFunnelTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ export function useFunnelTooltip(showPersonsModal: boolean): React.RefObject<HTM
const svgRect = vizRef.current?.getBoundingClientRect()
const [tooltipRoot, tooltipEl] = ensureTooltip()
tooltipEl.style.opacity = isTooltipShown ? '1' : '0'
if (isTooltipShown) {
tooltipEl.style.display = 'initial'
}
const tooltipRect = tooltipEl.getBoundingClientRect()
if (tooltipOrigin) {
tooltipRoot.render(
Expand Down
11 changes: 4 additions & 7 deletions frontend/src/scenes/insights/views/BoldNumber/BoldNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ function useBoldNumberTooltip({

useLayoutEffect(() => {
tooltipEl.style.opacity = isTooltipShown ? '1' : '0'
if (isTooltipShown) {
tooltipEl.style.display = 'initial'
}

const seriesResult = insightData?.result?.[0]

Expand Down Expand Up @@ -73,10 +70,10 @@ function useBoldNumberTooltip({
useEffect(() => {
const tooltipRect = tooltipEl.getBoundingClientRect()
if (divRect) {
const desiredTop = window.scrollY + divRect.top - tooltipRect.height - BOLD_NUMBER_TOOLTIP_OFFSET_PX
const desiredLeft = divRect.left + divRect.width / 2 - tooltipRect.width / 2
tooltipEl.style.top = `${Math.min(desiredTop, window.innerHeight)}px`
tooltipEl.style.left = `${Math.min(desiredLeft, window.innerWidth)}px`
tooltipEl.style.top = `${
window.scrollY + divRect.top - tooltipRect.height - BOLD_NUMBER_TOOLTIP_OFFSET_PX
}px`
tooltipEl.style.left = `${divRect.left + divRect.width / 2 - tooltipRect.width / 2}px`
}
})

Expand Down
6 changes: 2 additions & 4 deletions frontend/src/scenes/insights/views/LineGraph/LineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export function ensureTooltip(): [Root, HTMLElement] {
tooltipEl = document.createElement('div')
tooltipEl.id = 'InsightTooltipWrapper'
tooltipEl.classList.add('InsightTooltipWrapper')
tooltipEl.style.display = 'none'
document.body.appendChild(tooltipEl)
}

Expand Down Expand Up @@ -461,7 +460,6 @@ export function LineGraph_({
tooltipEl.classList.remove('above', 'below', 'no-transform')
tooltipEl.classList.add(tooltip.yAlign || 'no-transform')
tooltipEl.style.opacity = '1'
tooltipEl.style.display = 'initial'

if (tooltip.body) {
const referenceDataPoint = tooltip.dataPoints[0] // Use this point as reference to get the date
Expand Down Expand Up @@ -549,8 +547,8 @@ export function LineGraph_({
? chartClientLeft + tooltip.caretX - tooltipEl.clientWidth - 8 // If tooltip is too large (or close to the edge), show it to the left of the data point instead
: defaultOffsetLeft

tooltipEl.style.top = Math.min(tooltipClientTop, window.innerHeight) + 'px'
tooltipEl.style.left = Math.min(tooltipClientLeft, window.innerWidth) + 'px'
tooltipEl.style.top = tooltipClientTop + 'px'
tooltipEl.style.left = tooltipClientLeft + 'px'
},
},
...(!isBar
Expand Down
1 change: 0 additions & 1 deletion frontend/src/scenes/insights/views/LineGraph/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ export function PieChart({
tooltipEl.classList.remove('above', 'below', 'no-transform')
tooltipEl.classList.add(tooltip.yAlign || 'no-transform')
tooltipEl.style.opacity = '1'
tooltipEl.style.display = 'initial'

if (tooltip.body) {
const referenceDataPoint = tooltip.dataPoints[0] // Use this point as reference to get the date
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/scenes/insights/views/WorldMap/WorldMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ function useWorldMapTooltip(showPersonsModal: boolean): React.RefObject<SVGSVGEl

useEffect(() => {
tooltipEl.style.opacity = isTooltipShown ? '1' : '0'
if (isTooltipShown) {
tooltipEl.style.display = 'initial'
}

if (tooltipCoordinates) {
tooltipRoot.render(
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/scenes/sceneTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,7 @@ export interface SceneConfig {
organizationBased?: boolean
/** Route requires project access (used e.g. by breadcrumbs). `true` implies also `organizationBased` */
projectBased?: boolean

/** Default docs path - what the docs side panel will open by default if this scene is active */
defaultDocsPath?: string
}
Loading

0 comments on commit b38a38d

Please sign in to comment.