Skip to content

Commit

Permalink
fix(issues): Restyle non member in suspect commit (#76579)
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper committed Aug 28, 2024
1 parent 77749ef commit 8032d59
Showing 1 changed file with 68 additions and 47 deletions.
115 changes: 68 additions & 47 deletions static/app/components/commitRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import Link from 'sentry/components/links/link';
import PanelItem from 'sentry/components/panels/panelItem';
import TextOverflow from 'sentry/components/textOverflow';
import TimeSince from 'sentry/components/timeSince';
import {Tooltip} from 'sentry/components/tooltip';
import Version from 'sentry/components/version';
import VersionHoverCard from 'sentry/components/versionHoverCard';
import {IconWarning} from 'sentry/icons';
import {IconQuestion, IconWarning} from 'sentry/icons';
import {t, tct} from 'sentry/locale';
import ConfigStore from 'sentry/stores/configStore';
import {space} from 'sentry/styles/space';
Expand Down Expand Up @@ -78,16 +79,25 @@ function CommitRow({

const firstRelease = commit.releases?.[0];

const tctArgs = {
author: <span>{isUser ? t('You') : commit.author?.name ?? t('Unknown author')}</span>,
unknownLabel: (
<Hovercard
body={
<EmailWarning>
{tct(
return hasStreamlinedUI ? (
<StreamlinedCommitRow data-test-id="commit-row">
{commit.pullRequest?.externalUrl ? (
<StyledExternalLink href={commit.pullRequest?.externalUrl}>
<Message>{formatCommitMessage(commit.message)}</Message>
</StyledExternalLink>
) : (
<Message>{formatCommitMessage(commit.message)}</Message>
)}
<MetaWrapper>
<span>
{customAvatar ? customAvatar : <UserAvatar size={16} user={commit.author} />}
</span>
<Meta>
<Tooltip
title={tct(
'The email [actorEmail] is not a member of your organization. [inviteUser:Invite] them or link additional emails in [accountSettings:account settings].',
{
actorEmail: <strong>{commit.author?.email}</strong>,
actorEmail: <BoldEmail>{commit.author?.email}</BoldEmail>,
accountSettings: (
<StyledLink
to="/settings/account/emails/"
Expand All @@ -102,41 +112,30 @@ function CommitRow({
inviteUser: <StyledLink to="" onClick={handleInviteClick} />,
}
)}
</EmailWarning>
}
>
<UnknownAuthorWrapper>{t('(not a member)')}</UnknownAuthorWrapper>
</Hovercard>
),
commitLink: (
<CommitLink
inline
showIcon={false}
commitId={commit.id}
repository={commit.repository}
onClick={onCommitClick ? () => onCommitClick(commit) : undefined}
/>
),
date: <TimeSince date={commit.dateCreated} disabledAbsoluteTooltip />,
};

return hasStreamlinedUI ? (
<StreamlinedCommitRow data-test-id="commit-row">
{commit.pullRequest?.externalUrl ? (
<StyledExternalLink href={commit.pullRequest?.externalUrl}>
<Message>{formatCommitMessage(commit.message)}</Message>
</StyledExternalLink>
) : (
<Message>{formatCommitMessage(commit.message)}</Message>
)}
<MetaWrapper>
<span>
{customAvatar ? customAvatar : <UserAvatar size={16} user={commit.author} />}
</span>
<Meta>
{commit.author && commit.author.id === undefined
? tct('[author] [unknownLabel] committed [commitLink] [date]', tctArgs)
: tct('[author] committed [commitLink] [date]', tctArgs)}
disabled={!commit.author || commit.author.id !== undefined}
overlayStyle={{maxWidth: '350px'}}
skipWrapper
isHoverable
>
<AuthorWrapper>
{isUser ? t('You') : commit.author?.name ?? t('Unknown author')}
{commit.author && commit.author.id === undefined && (
<IconQuestion size="xs" />
)}
</AuthorWrapper>
</Tooltip>
{tct(' committed [commitLink]', {
commitLink: (
<CommitLink
inline
showIcon={false}
commitId={commit.id}
repository={commit.repository}
onClick={onCommitClick ? () => onCommitClick(commit) : undefined}
/>
),
})}{' '}
<TimeSince date={commit.dateCreated} disabledAbsoluteTooltip />
</Meta>
{project && firstRelease && (
<Fragment>
Expand Down Expand Up @@ -261,6 +260,11 @@ const EmailWarning = styled('div')`
margin: -4px;
`;

const BoldEmail = styled('strong')`
font-weight: bold;
word-break: break-all;
`;

const StyledLink = styled(Link)`
color: ${p => p.theme.textColor};
border-bottom: 1px dotted ${p => p.theme.textColor};
Expand Down Expand Up @@ -304,6 +308,10 @@ const Meta = styled(TextOverflow)<{hasStreamlinedUI?: boolean}>`
text-decoration: underline;
text-decoration-style: dotted;
}
a:hover {
color: ${p => p.theme.textColor};
}
`;

const StreamlinedCommitRow = styled('div')`
Expand All @@ -330,10 +338,23 @@ const StyledExternalLink = styled(ExternalLink)`
}
`;

const UnknownAuthorWrapper = styled('div')`
const AuthorWrapper = styled('span')`
display: inline-flex;
align-items: center;
gap: ${space(0.25)};
color: ${p => p.theme.subText};
text-decoration: underline;
text-decoration-style: dotted;
& svg {
transition: 120ms opacity;
opacity: 0.6;
}
&:has(svg):hover {
color: ${p => p.theme.textColor};
& svg {
opacity: 1;
}
}
`;

export {CommitRow};

0 comments on commit 8032d59

Please sign in to comment.