Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ import {GroupActivityType} from 'sentry/types/group';
interface IconWithDefaultProps {
Component: React.ComponentType<SVGIconProps> | null;
defaultProps: {locked?: boolean; type?: string};
componentFunction?: (props: {
propsFunction?: (data: GroupActivity['data']) => Record<string, unknown>;
renderIcon?: (props: {
data: GroupActivity['data'];
sentry_app: GroupActivity['sentry_app'];
user: GroupActivity['user'];
}) => React.ComponentType<SVGIconProps>;
propsFunction?: (data: GroupActivity['data']) => Record<string, unknown>;
}) => React.ReactNode;
Comment thread
cursor[bot] marked this conversation as resolved.
}

export const groupActivityTypeIconMapping: Record<
Expand All @@ -59,13 +59,11 @@ export const groupActivityTypeIconMapping: Record<
[GroupActivityType.NOTE]: {
Component: IconChat,
defaultProps: {},
componentFunction: ({user, sentry_app}) => {
renderIcon: ({user, sentry_app}) => {
if (sentry_app) {
return function () {
return <SentryAppAvatar sentryApp={sentry_app} />;
};
return <SentryAppAvatar sentryApp={sentry_app} />;
}
return user ? () => <StyledUserAvatar user={user} /> : IconChat;
return user ? <StyledUserAvatar user={user} /> : <IconChat size="xs" />;
},
},
[GroupActivityType.SET_RESOLVED]: {Component: IconCheckmark, defaultProps: {}},
Comment thread
sentry[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -109,21 +107,21 @@ export const groupActivityTypeIconMapping: Record<
[GroupActivityType.SET_REGRESSION]: {Component: IconFire, defaultProps: {}},
[GroupActivityType.CREATE_ISSUE]: {
Component: IconAdd,
componentFunction: ({data}) => {
renderIcon: ({data}) => {
const provider = (data as GroupActivityCreateIssue['data']).provider;
switch (provider) {
case 'GitHub':
return IconGithub;
return <IconGithub size="xs" />;
case 'GitLab':
return IconGitlab;
return <IconGitlab size="xs" />;
case 'Bitbucket':
return IconBitbucket;
return <IconBitbucket size="xs" />;
case 'Jira':
return IconJira;
return <IconJira size="xs" />;
case 'Asana':
return IconAsana;
return <IconAsana size="xs" />;
default:
return IconAdd;
return <IconAdd size="xs" />;
}
},
defaultProps: {},
Expand Down
24 changes: 11 additions & 13 deletions static/app/views/issueDetails/activitySection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,20 @@ function LegacyTimelineItem({
);

const iconMapping = groupActivityTypeIconMapping[item.type];
const componentFunction = iconMapping?.componentFunction;
const Icon = componentFunction
? componentFunction({
const Icon = iconMapping?.Component ?? null;
const iconNode = iconMapping?.renderIcon
? iconMapping.renderIcon({
data: item.data,
user: item.user,
sentry_app: item.sentry_app,
})
: (iconMapping?.Component ?? null);
: Icon && (
<Icon
{...iconMapping.defaultProps}
{...iconMapping.propsFunction?.(item.data)}
size="xs"
/>
);

return (
<ActivityTimelineItem
Expand All @@ -160,15 +166,7 @@ function LegacyTimelineItem({
</TitleRow>
}
timestamp={<Timestamp date={item.dateCreated} unitStyle={timestampUnitStyle} />}
icon={
Icon && (
<Icon
{...iconMapping.defaultProps}
{...iconMapping.propsFunction?.(item.data)}
size="xs"
/>
)
}
icon={iconNode}
>
{item.type === GroupActivityType.NOTE && editing ? (
<ActivityNoteInput
Expand Down
Loading