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

feat: Person feed properties node #18185

Merged
merged 38 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7b426d5
feat: Added Canvas mode and node-children
benjackwhite Oct 23, 2023
5708383
Fix
benjackwhite Oct 23, 2023
3d9e304
Update UI snapshots for `chromium` (2)
github-actions[bot] Oct 23, 2023
b78448f
Fixed up persons display
benjackwhite Oct 23, 2023
339b7a6
Fix render column
benjackwhite Oct 23, 2023
d805067
Added header for creating from canvas
benjackwhite Oct 23, 2023
f052eec
Fix padding
benjackwhite Oct 23, 2023
bb8efc4
Refactoring
benjackwhite Oct 24, 2023
d1e4ae7
Fixed unmounting
benjackwhite Oct 24, 2023
6a2a6c2
Fixed up padding for now
benjackwhite Oct 24, 2023
58c59cc
More tidying
benjackwhite Oct 24, 2023
2254eef
Update UI snapshots for `chromium` (2)
github-actions[bot] Oct 24, 2023
e3c5a87
Fix
benjackwhite Oct 24, 2023
33122d6
Fix padding
benjackwhite Oct 25, 2023
6c6a2aa
Fix up call
benjackwhite Oct 25, 2023
bfb0de1
Fix
benjackwhite Oct 25, 2023
9e46b00
PR review changes
benjackwhite Oct 25, 2023
81ad3fa
Merge branch 'master' into hackathon-3000-canvas
benjackwhite Oct 25, 2023
8410e64
Pulled out feed alone from the other PR
benjackwhite Oct 25, 2023
7ae0a7a
Fixed up temporary bits
benjackwhite Oct 25, 2023
a0b0cc7
Update UI snapshots for `chromium` (2)
github-actions[bot] Oct 25, 2023
1ba2f74
Adds a properties node
benjackwhite Oct 25, 2023
726f796
Added properties node
benjackwhite Oct 25, 2023
b14f2be
Fix type issue
benjackwhite Oct 25, 2023
06c28e9
Merge branch 'feat/hackathon-3000-feed' into feat/hackathon-3000-feed…
benjackwhite Oct 25, 2023
c736b65
Added back in missing class
benjackwhite Oct 25, 2023
f35ba93
Merge branch 'hackathon-3000-canvas' into feat/hackathon-3000-feed
benjackwhite Oct 25, 2023
99e0f27
Addded person node and make it not expanded by default
benjackwhite Oct 25, 2023
9d98bd0
Merge branch 'feat/hackathon-3000-feed' into feat/hackathon-3000-feed…
benjackwhite Oct 25, 2023
a6c0d89
Merge branch 'master' into feat/hackathon-3000-feed
benjackwhite Oct 25, 2023
994e856
Merge branch 'feat/hackathon-3000-feed' into feat/hackathon-3000-feed…
benjackwhite Oct 25, 2023
2ce6cc8
Fixes
benjackwhite Oct 25, 2023
c540952
Fix
benjackwhite Oct 25, 2023
bc467c0
Merge branch 'feat/hackathon-3000-feed' into feat/hackathon-3000-feed…
benjackwhite Oct 25, 2023
1c95e71
Fix types
benjackwhite Oct 25, 2023
ed651c4
Merge branch 'master' into feat/hackathon-3000-feed-properties
benjackwhite Oct 26, 2023
3b3dbc1
Merge branch 'master' into feat/hackathon-3000-feed-properties
benjackwhite Oct 26, 2023
7a6b5e6
Fix order
benjackwhite Oct 26, 2023
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
66 changes: 66 additions & 0 deletions frontend/src/scenes/notebooks/Nodes/NotebookNodeProperties.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { NotebookNodeType, PropertyDefinitionType } from '~/types'
import { createPostHogWidgetNode } from 'scenes/notebooks/Nodes/NodeWrapper'
import { LemonLabel, LemonSkeleton } from '@posthog/lemon-ui'
import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'
import { PropertiesTable } from 'lib/components/PropertiesTable'
import { useValues } from 'kea'
import { personLogic } from 'scenes/persons/personLogic'
import { NotebookNodeProps } from '../Notebook/utils'
import { NotFound } from 'lib/components/NotFound'
import { notebookNodeLogic } from './notebookNodeLogic'

const Component = ({ attributes }: NotebookNodeProps<NotebookNodePropertiesAttributes>): JSX.Element | null => {
const { id } = attributes

const { expanded } = useValues(notebookNodeLogic)

const logic = personLogic({ id })
const { person, personLoading } = useValues(logic)

if (personLoading) {
return <LemonSkeleton className="h-6" />
} else if (!person) {
return <NotFound object="person" />
}

const numProperties = Object.keys(person.properties).length

if (!expanded) {
return null
}

return (
<div className="py-2 px-4 text-xs">
{Object.entries(person.properties).map(([key, value], index) => {
const isLast = index === numProperties - 1

return (
<div key={key} className="mb-1">
<LemonLabel className="leading-4">
<PropertyKeyInfo value={key} />
</LemonLabel>
<div className={`${!isLast && 'border-b border-border-light pb-1'}`}>
<PropertiesTable properties={value} rootKey={key} type={PropertyDefinitionType.Person} />
</div>
</div>
)
})}
</div>
)
}

type NotebookNodePropertiesAttributes = {
id: string
}

export const NotebookNodeProperties = createPostHogWidgetNode({
nodeType: NotebookNodeType.Properties,
titlePlaceholder: 'Properties',
Component,
resizeable: false,
expandable: true,
startExpanded: true,
attributes: {
id: {},
},
})
2 changes: 2 additions & 0 deletions frontend/src/scenes/notebooks/Notebook/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { sampleOne } from 'lib/utils'
import { NotebookNodeGroup } from '../Nodes/NotebookNodeGroup'
import { NotebookNodeCohort } from '../Nodes/NotebookNodeCohort'
import { NotebookNodePersonFeed } from '../Nodes/NotebookNodePersonFeed/NotebookNodePersonFeed'
import { NotebookNodeProperties } from '../Nodes/NotebookNodeProperties'
import { NotebookNodeMap } from '../Nodes/NotebookNodeMap'

const CustomDocument = ExtensionDocument.extend({
Expand Down Expand Up @@ -117,6 +118,7 @@ export function Editor(): JSX.Element {
NotebookNodeEarlyAccessFeature,
NotebookNodeSurvey,
NotebookNodeImage,
NotebookNodeProperties,
SlashCommandsExtension,
BacklinkCommandsExtension,
NodeGapInsertionExtension,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/notebooks/Notebook/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const textContent = (node: any): string => {
'ph-group': customOrTitleSerializer,
'ph-cohort': customOrTitleSerializer,
'ph-person-feed': customOrTitleSerializer,
'ph-properties': customOrTitleSerializer,
'ph-map': customOrTitleSerializer,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NotebooksListFilters } from 'scenes/notebooks/NotebooksTable/notebooksT

export const fromNodeTypeToLabel: Omit<
Record<NotebookNodeType, string>,
NotebookNodeType.Backlink | NotebookNodeType.PersonFeed | NotebookNodeType.Map
NotebookNodeType.Backlink | NotebookNodeType.PersonFeed | NotebookNodeType.Properties | NotebookNodeType.Map
> = {
[NotebookNodeType.FeatureFlag]: 'Feature flags',
[NotebookNodeType.FeatureFlagCodeExample]: 'Feature flag Code Examples',
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/scenes/persons/PersonFeedCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const PersonFeedCanvas = ({ person }: PersonFeedCanvasProps): JSX.Element => {
type: 'ph-map',
attrs: { id: personId, nodeId: uuid() },
},
{
type: 'ph-properties',
attrs: { id: personId, nodeId: uuid() },
},
],
},
},
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3082,6 +3082,7 @@ export enum NotebookNodeType {
ReplayTimestamp = 'ph-replay-timestamp',
Image = 'ph-image',
PersonFeed = 'ph-person-feed',
Properties = 'ph-properties',
Map = 'ph-map',
}

Expand Down
Loading