Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 25 additions & 21 deletions static/app/components/events/userFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ type Props = {
export function EventUserFeedback({eventLink, report}: Props) {
const {copy} = useCopyToClipboard();
const showEmailLabel = !isSameIdentity(report.name, report.email);
const copyEmail = () =>
copy(report.email, {successMessage: t('Copied email to clipboard')});

return (
<Flex data-test-id="activity-item" gap="md">
Expand All @@ -34,20 +32,26 @@ export function EventUserFeedback({eventLink, report}: Props) {
<Text as="span" bold size="md">
{report.name}
</Text>
<Button
aria-label={showEmailLabel ? undefined : t('Copy email address')}
variant="transparent"
onClick={copyEmail}
size="zero"
tooltipProps={{delay: 0, title: t('Copy email address')}}
icon={<IconCopy size="xs" variant="muted" />}
>
{showEmailLabel && (
<Text as="span" size="sm" variant="muted">
{report.email}
</Text>
)}
</Button>
{report.email ? (
<Button
aria-label={showEmailLabel ? undefined : t('Copy email address')}
variant="transparent"
onClick={() =>
copy(report.email ?? '', {
successMessage: t('Copied email to clipboard'),
})
}
Comment on lines +39 to +43
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inlined to make it more obvious that report.email is checked above

size="zero"
tooltipProps={{delay: 0, title: t('Copy email address')}}
icon={<IconCopy size="xs" variant="muted" />}
>
{showEmailLabel && (
<Text as="span" size="sm" variant="muted">
{report.email}
</Text>
)}
</Button>
) : null}

{eventLink && (
<Text as="span" size="sm">
Expand All @@ -71,8 +75,8 @@ export function EventUserFeedback({eventLink, report}: Props) {
);
}

function isSameIdentity(name: string, email: string) {
return name.trim().toLowerCase() === email.trim().toLowerCase();
function isSameIdentity(name: string | null, email: string | null) {
return name?.trim().toLowerCase() === email?.trim().toLowerCase();
}

function getAvatarUser(report: UserReport): AvatarUser | undefined {
Expand All @@ -81,8 +85,8 @@ function getAvatarUser(report: UserReport): AvatarUser | undefined {
if (!user) {
return {
id: '',
email: report.email,
name: report.name,
email: report.email ?? '',
name: report.name ?? '',
username: '',
ip_address: '',
};
Expand All @@ -91,7 +95,7 @@ function getAvatarUser(report: UserReport): AvatarUser | undefined {
return {
id: user.id,
email: user.email ?? '',
name: user.name ?? report.name,
name: user.name ?? report.name ?? '',
username: user.username ?? '',
ip_address: user.ipAddress ?? '',
avatarUrl: user.avatarUrl ?? undefined,
Expand Down
4 changes: 2 additions & 2 deletions static/app/types/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1262,11 +1262,11 @@ export type ChunkType = {
export type UserReport = {
comments: string;
dateCreated: string;
email: string;
email: string | null;
event: {eventID: string; id: string};
eventID: string;
id: string;
name: string;
name: string | null;
user: {
avatarUrl: string | null;
email: string | null;
Expand Down
Loading