Skip to content

Commit

Permalink
repro of insight logic issues
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr committed Oct 29, 2023
1 parent ec095f3 commit 9dc2119
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/src/scenes/appScenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const appScenes: Record<Scene, () => any> = {
[Scene.Error404]: () => ({ default: preloadedScenes[Scene.Error404].component }),
[Scene.ErrorNetwork]: () => ({ default: preloadedScenes[Scene.ErrorNetwork].component }),
[Scene.ErrorProjectUnavailable]: () => ({ default: preloadedScenes[Scene.ErrorProjectUnavailable].component }),
[Scene.Playground]: () => import('./playground/Playground'),
[Scene.Dashboards]: () => import('./dashboard/dashboards/Dashboards'),
[Scene.Dashboard]: () => import('./dashboard/Dashboard'),
[Scene.Insight]: () => import('./insights/InsightScene'),
Expand Down
39 changes: 39 additions & 0 deletions frontend/src/scenes/playground/Playground.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useState } from 'react'
import { SceneExport } from 'scenes/sceneTypes'
import { Query } from '~/queries/Query/Query'
import { InsightVizNode, NodeKind, TrendsQuery } from '~/queries/schema'
import { BaseMathType } from '~/types'

export const scene: SceneExport = {
component: PlaygroundScene,
}

const trendsDefaultQuery: TrendsQuery = {
kind: NodeKind.TrendsQuery,
series: [
{
kind: NodeKind.EventsNode,
name: '$pageview',
event: '$pageview',
math: BaseMathType.TotalCount,
},
],
trendsFilter: {},
}

function PlaygroundScene(): JSX.Element {
const initialQuery: InsightVizNode = {
kind: NodeKind.InsightVizNode,
source: trendsDefaultQuery,
full: true,
showFilters: true,
}
const [query, setQuery] = useState(initialQuery)
return (
<div>
<h1>Playground</h1>
<pre>{JSON.stringify(query, null, 2)}</pre>
<Query query={query} setQuery={setQuery} readOnly={false} />

Check failure on line 36 in frontend/src/scenes/playground/Playground.tsx

View workflow job for this annotation

GitHub Actions / Code quality checks

Type 'Dispatch<SetStateAction<InsightVizNode>>' is not assignable to type '(query: Node | QuerySchema) => void'.
</div>
)
}
1 change: 1 addition & 0 deletions frontend/src/scenes/sceneTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LogicWrapper } from 'kea'
// If so, we can preload the scene's required chunks in parallel with the scene itself.

export enum Scene {
Playground = 'Playground',
Error404 = '404',
ErrorNetwork = '4xx',
ErrorProjectUnavailable = 'ProjectUnavailable',
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/scenes/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export const preloadedScenes: Record<string, LoadedScene> = {
}

export const sceneConfigurations: Partial<Record<Scene, SceneConfig>> = {
[Scene.Playground]: {
projectBased: true,
name: 'Playground',
},
// Project-based routes
[Scene.Dashboards]: {
projectBased: true,
Expand Down Expand Up @@ -349,6 +353,7 @@ export const redirects: Record<
string | ((params: Params, searchParams: Params, hashParams: Params) => string)
> = {
'/': preserveParams(urls.projectHomepage()),
'/playground': urls.playground(),
'/saved_insights': urls.savedInsights(),
'/dashboards': urls.dashboards(),
'/plugins': urls.projectApps(),
Expand Down Expand Up @@ -395,6 +400,7 @@ export const redirects: Record<
}

export const routes: Record<string, Scene> = {
[urls.playground()]: Scene.Playground,
[urls.dashboards()]: Scene.Dashboards,
[urls.dashboard(':id')]: Scene.Dashboard,
[urls.dashboardTextTile(':id', ':textTileId')]: Scene.Dashboard,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { toParams } from 'lib/utils'
* Sync the paths with AutoProjectMiddleware!
*/
export const urls = {
playground: (): string => '/playground',
default: (): string => '/',
dashboards: (): string => '/dashboard',
dashboard: (id: string | number, highlightInsightId?: string): string =>
Expand Down

0 comments on commit 9dc2119

Please sign in to comment.