Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Dec 21, 2023
1 parent a005e30 commit 2663bea
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 24 deletions.
6 changes: 4 additions & 2 deletions frontend/src/lib/components/ActivityLog/ActivityLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ export const ActivityLogRow = ({
<div className={clsx('ActivityLogRow', logItem.unread && 'ActivityLogRow--unread')}>
<ProfilePicture
showName={false}
name={logItem.isSystem ? logItem.name : undefined}
user={{
first_name: logItem.isSystem ? logItem.name : undefined,
email: logItem.email ?? undefined,
}}
type={logItem.isSystem ? 'system' : 'person'}
email={logItem.email ?? undefined}
size={'xl'}
/>
<div className="ActivityLogRow__details">
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/lib/components/ActivityLog/humanizeActivity.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { dayjs } from 'lib/dayjs'
import { fullName } from 'lib/utils'

import { InsightShortId, PersonType } from '~/types'

Expand Down Expand Up @@ -110,7 +111,7 @@ export function humanize(
if (description !== null) {
logLines.push({
email: logItem.user?.email,
name: logItem.user?.first_name,
name: logItem.user ? fullName(logItem.user) : undefined,
isSystem: logItem.is_system,
description,
extendedDescription,
Expand All @@ -126,5 +127,5 @@ export function userNameForLogItem(logItem: ActivityLogItem): string {
if (logItem.is_system) {
return 'PostHog'
}
return logItem.user?.first_name ?? 'A user'
return logItem.user ? fullName(logItem.user) : 'A user'
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ function AnnotationCard({ annotation }: { annotation: AnnotationType }): JSX.Ele
<div className="mt-1">{annotation.content}</div>
<div className="leading-6 mt-2">
<ProfilePicture
name={annotation.creation_type === 'GIT' ? 'GitHub automation' : annotation.created_by?.first_name}
email={annotation.creation_type === 'GIT' ? undefined : annotation.created_by?.email}
user={
annotation.creation_type === 'GIT' ? { first_name: 'GitHub automation' } : annotation.created_by
}
showName
size="md"
type={annotation.creation_type === 'GIT' ? 'bot' : 'person'}
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/lib/components/MemberSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,7 @@ export function MemberSelect({
fullWidth
role="menuitem"
size="small"
icon={
<ProfilePicture
size="md"
name={fullName(member.user)}
email={member.user.email}
/>
}
icon={<ProfilePicture size="md" user={member.user} />}
onClick={() => _onChange(member.user)}
>
<span className="flex items-center justify-between gap-2 flex-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const ComplexContent: Story = BasicTemplate.bind({})
ComplexContent.args = {
children: (
<span className="flex gap-2 items-center">
<ProfilePicture email="ben@posthog.com" size="sm" />
<ProfilePicture name="ben" size="sm" />
<span>
Look at me I'm <b>bold!</b>
</span>
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/lib/lemon-ui/ProfilePicture/ProfileBubbles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export function ProfileBubbles({ people, tooltip, limit = 6, ...divProps }: Prof
{shownPeople.map(({ email, name, title }, index) => (
<ProfilePicture
key={email}
name={name}
email={email}
user={{
email,
first_name: name,
}}
title={title || name || email}
size="md"
index={index}
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/scenes/annotations/Annotations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ export function Annotations(): JSX.Element {
return (
<div className="flex flex-row items-center">
<ProfilePicture
name={creation_type === 'GIT' ? 'GitHub Actions' : created_by?.first_name}
email={creation_type === 'GIT' ? undefined : created_by?.email}
user={creation_type === 'GIT' ? { first_name: 'GitHub Actions' } : created_by}
showName
size="md"
type={creation_type === 'GIT' ? 'bot' : 'person'}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/dashboard/DashboardCollaborators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function CollaboratorRow({

return (
<div className="flex items-center justify-between mt-2 pl-2 h-8">
<ProfilePicture email={user.email} name={user.first_name} size="md" showName />
<ProfilePicture user={user} size="md" showName />
<Tooltip
title={
!wasInvited
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/scenes/notebooks/Notebook/NotebookHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ function NotebookHistoryList({ onItemClick }: { onItemClick: (logItem: ActivityL
const buttonContent = (
<span className="flex flex-1 gap-2 items-center p-2">
<ProfilePicture
name={logItem.is_system ? name : undefined}
user={{
first_name: name,
email: logItem.user?.email ?? undefined,
}}
type={logItem.is_system ? 'system' : 'person'}
email={logItem.user?.email ?? undefined}
size={'md'}
/>
<span className="flex-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ function NotebooksChoiceList(props: {
sideIcon={
notebook.created_by ? (
<ProfilePicture
name={notebook.created_by?.first_name}
email={notebook.created_by?.email}
user={notebook.created_by}
size="md"
title={`Created by ${notebook.created_by?.first_name} <${notebook.created_by?.email}>`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function MemberRow({

return (
<div className="flex items-center justify-between mt-2 h-8">
<ProfilePicture email={user.email} name={user.first_name} size="md" showName />
<ProfilePicture user={user} size="md" showName />
{isAdminOrOwner && deleteMember && (
<LemonButton
icon={<IconDelete />}
Expand Down
1 change: 1 addition & 0 deletions posthog/api/test/test_organization_invites.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def test_add_organization_invite_with_email(self, mock_capture):
"distinct_id": self.user.distinct_id,
"email": self.user.email,
"first_name": self.user.first_name,
"last_name": self.user.last_name,
"is_email_verified": self.user.is_email_verified,
},
"is_expired": False,
Expand Down
1 change: 1 addition & 0 deletions posthog/api/test/test_organization_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def test_change_organization_member_level(self):
"uuid": str(user.uuid),
"distinct_id": str(user.distinct_id),
"first_name": user.first_name,
"last_name": user.last_name,
"email": user.email,
"is_email_verified": None,
},
Expand Down
6 changes: 6 additions & 0 deletions posthog/api/test/test_signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_api_sign_up(self, mock_capture):
"id": user.pk,
"uuid": str(user.uuid),
"distinct_id": user.distinct_id,
"last_name": "",
"first_name": "John",
"email": "[email protected]",
"redirect_url": "/",
Expand Down Expand Up @@ -210,6 +211,7 @@ def test_signup_minimum_attrs(self, mock_capture):
"id": user.pk,
"uuid": str(user.uuid),
"distinct_id": user.distinct_id,
"last_name": "",
"first_name": "Jane",
"email": "[email protected]",
"redirect_url": "/",
Expand Down Expand Up @@ -364,6 +366,7 @@ def test_default_dashboard_is_created_on_signup(self):
"id": user.pk,
"uuid": str(user.uuid),
"distinct_id": user.distinct_id,
"last_name": "",
"first_name": "Jane",
"email": "[email protected]",
"redirect_url": "/",
Expand Down Expand Up @@ -868,6 +871,7 @@ def test_api_invite_sign_up(self, mock_capture):
"id": user.pk,
"uuid": str(user.uuid),
"distinct_id": user.distinct_id,
"last_name": "",
"first_name": "Alice",
"email": "[email protected]",
"redirect_url": "/",
Expand Down Expand Up @@ -1076,6 +1080,7 @@ def test_existing_user_can_sign_up_to_a_new_organization(self, mock_update_disti
"id": user.pk,
"uuid": str(user.uuid),
"distinct_id": user.distinct_id,
"last_name": "",
"first_name": "",
"email": "[email protected]",
"redirect_url": "/",
Expand Down Expand Up @@ -1151,6 +1156,7 @@ def test_cannot_use_claim_invite_endpoint_to_update_user(self, mock_capture):
"id": user.pk,
"uuid": str(user.uuid),
"distinct_id": user.distinct_id,
"last_name": "",
"first_name": "",
"email": "[email protected]",
"redirect_url": "/",
Expand Down

0 comments on commit 2663bea

Please sign in to comment.