Skip to content

Commit 7f4504e

Browse files
feat(ui): Add actor to delegating Avatar component (#68933)
1 parent 9767d7f commit 7f4504e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

static/app/components/avatar/index.spec.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {ActorFixture} from 'sentry-fixture/actor';
12
import {OrganizationFixture} from 'sentry-fixture/organization';
23
import {ProjectFixture} from 'sentry-fixture/project';
34
import {SentryAppFixture} from 'sentry-fixture/sentryApp';
@@ -174,6 +175,15 @@ describe('Avatar', function () {
174175
);
175176
});
176177

178+
it('can display a actor Avatar', function () {
179+
const actor = ActorFixture();
180+
181+
render(<AvatarComponent actor={actor} />);
182+
183+
expect(screen.getByTestId(`letter_avatar-avatar`)).toBeInTheDocument();
184+
expect(screen.getByText('FB')).toBeInTheDocument();
185+
});
186+
177187
it('displays platform list icons for project Avatar', function () {
178188
const project = ProjectFixture({
179189
platform: 'java',

static/app/components/avatar/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import SentryAppAvatar from 'sentry/components/avatar/sentryAppAvatar';
77
import TeamAvatar from 'sentry/components/avatar/teamAvatar';
88
import UserAvatar from 'sentry/components/avatar/userAvatar';
99
import type {
10+
Actor,
1011
AvatarProject,
1112
AvatarSentryApp,
1213
DocIntegration,
1314
OrganizationSummary,
1415
Team,
1516
} from 'sentry/types';
1617

18+
import ActorAvatar from './actorAvatar';
19+
1720
type Props = {
21+
actor?: Actor;
1822
docIntegration?: DocIntegration;
1923
/**
2024
* True if the Avatar is full color, rather than B&W (Used for SentryAppAvatar)
@@ -33,6 +37,7 @@ type Props = {
3337
const Avatar = forwardRef(function Avatar(
3438
{
3539
hasTooltip = false,
40+
actor,
3641
user,
3742
team,
3843
project,
@@ -47,6 +52,10 @@ const Avatar = forwardRef(function Avatar(
4752
) {
4853
const commonProps = {hasTooltip, forwardedRef: ref, ...props};
4954

55+
if (actor) {
56+
return <ActorAvatar actor={actor} {...commonProps} />;
57+
}
58+
5059
if (user) {
5160
return <UserAvatar user={user} {...commonProps} />;
5261
}

0 commit comments

Comments
 (0)