Skip to content

Commit f4403f6

Browse files
committed
refactor: Pass down filter overrides through notebookLogic with BindLogic
1 parent 2e78bc8 commit f4403f6

File tree

2 files changed

+59
-58
lines changed

2 files changed

+59
-58
lines changed

frontend/src/scenes/notebooks/Notebook/Notebook.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { NotebookLogicProps, notebookLogic } from 'scenes/notebooks/Notebook/not
1414

1515
import { ErrorBoundary } from '~/layout/ErrorBoundary'
1616
import { SCRATCHPAD_NOTEBOOK } from '~/models/notebooksModel'
17-
import { AnyPropertyFilter } from '~/types'
1817

1918
import { AddInsightsToNotebookModal } from '../AddInsightsToNotebookModal/AddInsightsToNotebookModal'
2019
import { Editor } from './Editor'
@@ -29,7 +28,6 @@ export type NotebookProps = NotebookLogicProps & {
2928
initialAutofocus?: EditorFocusPosition
3029
initialContent?: JSONContent
3130
editable?: boolean
32-
canvasFiltersOverride?: AnyPropertyFilter[]
3331
}
3432

3533
export function Notebook({
@@ -38,9 +36,8 @@ export function Notebook({
3836
editable = true,
3937
initialAutofocus = 'start',
4038
initialContent,
41-
canvasFiltersOverride,
4239
}: NotebookProps): JSX.Element {
43-
const logicProps: NotebookLogicProps = { shortId, mode, canvasFiltersOverride }
40+
const logicProps: NotebookLogicProps = { shortId, mode }
4441
const logic = notebookLogic(logicProps)
4542
const { notebook, notebookLoading, editor, conflictWarningVisible, isEditable, isTemplate, notebookMissing } =
4643
useValues(logic)

frontend/src/scenes/persons/PersonFeedCanvas.tsx

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { useValues } from 'kea'
1+
import { BindLogic, useValues } from 'kea'
22

33
import { uuid } from 'lib/utils'
44
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
55
import { Notebook } from 'scenes/notebooks/Notebook/Notebook'
6+
import { notebookLogic } from 'scenes/notebooks/Notebook/notebookLogic'
67

78
import { AnyPropertyFilter, PersonType, PropertyFilterType, PropertyOperator } from '~/types'
89

@@ -15,6 +16,8 @@ const PersonFeedCanvas = ({ person }: PersonFeedCanvasProps): JSX.Element => {
1516

1617
const id = person.id
1718
const distinctId = person.distinct_ids[0]
19+
const shortId = `canvas-${id}`
20+
const mode = 'canvas'
1821

1922
const personFilter: AnyPropertyFilter[] = [
2023
{
@@ -26,60 +29,61 @@ const PersonFeedCanvas = ({ person }: PersonFeedCanvasProps): JSX.Element => {
2629
]
2730

2831
return (
29-
<Notebook
30-
editable={false}
31-
shortId={`canvas-${id}`}
32-
mode="canvas"
33-
canvasFiltersOverride={personFilter}
34-
initialContent={{
35-
type: 'doc',
36-
content: [
37-
{ type: 'ph-usage-metrics', attrs: { personId: id, nodeId: uuid() } },
38-
{
39-
type: 'ph-person-feed',
40-
attrs: {
41-
height: null,
42-
title: null,
43-
nodeId: uuid(),
44-
id,
45-
distinctId,
46-
__init: null,
47-
children: [
48-
{
49-
type: 'ph-person',
50-
attrs: { id, distinctId, nodeId: uuid(), title: 'Info' },
51-
},
52-
...(isCloudOrDev
53-
? [
54-
{
55-
type: 'ph-map',
56-
attrs: { id, distinctId, nodeId: uuid() },
57-
},
58-
]
59-
: []),
60-
{
61-
type: 'ph-person-properties',
62-
attrs: { id, distinctId, nodeId: uuid() },
63-
},
64-
{ type: 'ph-related-groups', attrs: { id, nodeId: uuid(), type: 'group' } },
65-
],
32+
<BindLogic logic={notebookLogic} props={{ shortId, mode, canvasFiltersOverride: personFilter }}>
33+
<Notebook
34+
editable={false}
35+
shortId={shortId}
36+
mode={mode}
37+
initialContent={{
38+
type: 'doc',
39+
content: [
40+
{ type: 'ph-usage-metrics', attrs: { personId: id, nodeId: uuid() } },
41+
{
42+
type: 'ph-person-feed',
43+
attrs: {
44+
height: null,
45+
title: null,
46+
nodeId: uuid(),
47+
id,
48+
distinctId,
49+
__init: null,
50+
children: [
51+
{
52+
type: 'ph-person',
53+
attrs: { id, distinctId, nodeId: uuid(), title: 'Info' },
54+
},
55+
...(isCloudOrDev
56+
? [
57+
{
58+
type: 'ph-map',
59+
attrs: { id, distinctId, nodeId: uuid() },
60+
},
61+
]
62+
: []),
63+
{
64+
type: 'ph-person-properties',
65+
attrs: { id, distinctId, nodeId: uuid() },
66+
},
67+
{ type: 'ph-related-groups', attrs: { id, nodeId: uuid(), type: 'group' } },
68+
],
69+
},
6670
},
67-
},
68-
{
69-
type: 'ph-llm-trace',
70-
attrs: { personId: id, nodeId: uuid() },
71-
},
72-
{
73-
type: 'ph-zendesk-tickets',
74-
attrs: { personId: id, nodeId: uuid() },
75-
},
76-
{
77-
type: 'ph-issues',
78-
attrs: { personId: id, nodeId: uuid() },
79-
},
80-
],
81-
}}
82-
/>
71+
{
72+
type: 'ph-llm-trace',
73+
attrs: { personId: id, nodeId: uuid() },
74+
},
75+
{
76+
type: 'ph-zendesk-tickets',
77+
attrs: { personId: id, nodeId: uuid() },
78+
},
79+
{
80+
type: 'ph-issues',
81+
attrs: { personId: id, nodeId: uuid() },
82+
},
83+
],
84+
}}
85+
/>
86+
</BindLogic>
8387
)
8488
}
8589

0 commit comments

Comments
 (0)