|
@@ -12,9 +12,12 @@ import TextOverflow from 'sentry/components/textOverflow';
|
|
|
import TimeSince from 'sentry/components/timeSince';
|
|
|
import {IconWarning} from 'sentry/icons';
|
|
|
import {t, tct} from 'sentry/locale';
|
|
|
+import ConfigStore from 'sentry/stores/configStore';
|
|
|
import space from 'sentry/styles/space';
|
|
|
import {Commit} from 'sentry/types';
|
|
|
|
|
|
+import Button from './button';
|
|
|
+
|
|
|
function formatCommitMessage(message: string | null) {
|
|
|
if (!message) {
|
|
|
return t('No message provided');
|
|
@@ -25,11 +28,17 @@ function formatCommitMessage(message: string | null) {
|
|
|
|
|
|
interface CommitRowProps {
|
|
|
commit: Commit;
|
|
|
- className?: string;
|
|
|
customAvatar?: React.ReactNode;
|
|
|
+ onCommitClick?: () => void;
|
|
|
+ onPullRequestClick?: () => void;
|
|
|
}
|
|
|
|
|
|
-function CommitRow({commit, customAvatar, className}: CommitRowProps) {
|
|
|
+function CommitRow({
|
|
|
+ commit,
|
|
|
+ customAvatar,
|
|
|
+ onPullRequestClick,
|
|
|
+ onCommitClick,
|
|
|
+}: CommitRowProps) {
|
|
|
const handleInviteClick = useCallback(() => {
|
|
|
if (!commit.author?.email) {
|
|
|
Sentry.captureException(
|
|
@@ -48,13 +57,17 @@ function CommitRow({commit, customAvatar, className}: CommitRowProps) {
|
|
|
});
|
|
|
}, [commit.author]);
|
|
|
|
|
|
+ const user = ConfigStore.get('user');
|
|
|
+ const isUser = user?.id === commit.author?.id;
|
|
|
+
|
|
|
return (
|
|
|
- <PanelItem key={commit.id} className={className} data-test-id="commit-row">
|
|
|
+ <StyledPanelItem key={commit.id} data-test-id="commit-row">
|
|
|
{customAvatar ? (
|
|
|
customAvatar
|
|
|
) : commit.author && commit.author.id === undefined ? (
|
|
|
<AvatarWrapper>
|
|
|
<Hovercard
|
|
|
+ skipWrapper
|
|
|
body={
|
|
|
<EmailWarning>
|
|
|
{tct(
|
|
@@ -75,32 +88,53 @@ function CommitRow({commit, customAvatar, className}: CommitRowProps) {
|
|
|
</Hovercard>
|
|
|
</AvatarWrapper>
|
|
|
) : (
|
|
|
- <AvatarWrapper>
|
|
|
+ <div>
|
|
|
<UserAvatar size={36} user={commit.author} />
|
|
|
- </AvatarWrapper>
|
|
|
+ </div>
|
|
|
)}
|
|
|
|
|
|
<CommitMessage>
|
|
|
- <Message>{formatCommitMessage(commit.message)}</Message>
|
|
|
- <Meta>
|
|
|
- {tct('[author] committed [timeago]', {
|
|
|
- author: <strong>{commit.author?.name ?? t('Unknown author')}</strong>,
|
|
|
- timeago: <TimeSince date={commit.dateCreated} />,
|
|
|
+ <Message>
|
|
|
+ {tct('[author] committed [commitLink]', {
|
|
|
+ author: isUser ? t('You') : commit.author?.name ?? t('Unknown author'),
|
|
|
+ commitLink: (
|
|
|
+ <CommitLink
|
|
|
+ inline
|
|
|
+ showIcon={false}
|
|
|
+ commitId={commit.id}
|
|
|
+ repository={commit.repository}
|
|
|
+ onClick={onCommitClick}
|
|
|
+ />
|
|
|
+ ),
|
|
|
})}
|
|
|
+ </Message>
|
|
|
+ <Meta>
|
|
|
+ {formatCommitMessage(commit.message)} •{' '}
|
|
|
+ <TimeSince date={commit.dateCreated} />
|
|
|
</Meta>
|
|
|
</CommitMessage>
|
|
|
|
|
|
- <div>
|
|
|
- <CommitLink commitId={commit.id} repository={commit.repository} />
|
|
|
- </div>
|
|
|
- </PanelItem>
|
|
|
+ {commit.pullRequest && commit.pullRequest.externalUrl && (
|
|
|
+ <Button
|
|
|
+ external
|
|
|
+ href={commit.pullRequest.externalUrl}
|
|
|
+ onClick={onPullRequestClick}
|
|
|
+ >
|
|
|
+ {t('View Pull Request')}
|
|
|
+ </Button>
|
|
|
+ )}
|
|
|
+ </StyledPanelItem>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+const StyledPanelItem = styled(PanelItem)`
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ gap: ${space(2)};
|
|
|
+`;
|
|
|
+
|
|
|
const AvatarWrapper = styled('div')`
|
|
|
position: relative;
|
|
|
- align-self: flex-start;
|
|
|
- margin-right: ${space(2)};
|
|
|
`;
|
|
|
|
|
|
const EmailWarning = styled('div')`
|
|
@@ -137,9 +171,8 @@ const CommitMessage = styled('div')`
|
|
|
`;
|
|
|
|
|
|
const Message = styled(TextOverflow)`
|
|
|
- font-size: 15px;
|
|
|
- line-height: 1.1;
|
|
|
- font-weight: bold;
|
|
|
+ font-size: ${p => p.theme.fontSizeLarge};
|
|
|
+ line-height: 1.2;
|
|
|
`;
|
|
|
|
|
|
const Meta = styled(TextOverflow)`
|
|
@@ -149,8 +182,4 @@ const Meta = styled(TextOverflow)`
|
|
|
color: ${p => p.theme.subText};
|
|
|
`;
|
|
|
|
|
|
-const StyledCommitRow = styled(CommitRow)`
|
|
|
- align-items: center;
|
|
|
-`;
|
|
|
-
|
|
|
-export {StyledCommitRow as CommitRow};
|
|
|
+export {CommitRow};
|