Skip to content

Commit 09f9cdb

Browse files
ref(avatars): Use relative imports for avatar types (#93748)
1 parent 599ae62 commit 09f9cdb

18 files changed

+49
-46
lines changed

static/app/components/core/avatar/actorAvatar.spec.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import {UserFixture} from 'sentry-fixture/user';
44

55
import {render, screen} from 'sentry-test/reactTestingLibrary';
66

7-
import {ActorAvatar} from 'sentry/components/core/avatar/actorAvatar';
87
import MemberListStore from 'sentry/stores/memberListStore';
98
import OrganizationStore from 'sentry/stores/organizationStore';
109
import TeamStore from 'sentry/stores/teamStore';
1110
import type {Team as TeamType} from 'sentry/types/organization';
1211
import type {User as UserType} from 'sentry/types/user';
1312

13+
import {ActorAvatar} from './actorAvatar';
14+
1415
describe('ActorAvatar', function () {
1516
const user: UserType = {
1617
...UserFixture(),

static/app/components/core/avatar/actorAvatar.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import type React from 'react';
22
import {useMemo} from 'react';
33
import * as Sentry from '@sentry/react';
44

5-
import {BaseAvatar, type BaseAvatarProps} from 'sentry/components/core/avatar/baseAvatar';
6-
import {TeamAvatar, type TeamAvatarProps} from 'sentry/components/core/avatar/teamAvatar';
7-
import {UserAvatar, type UserAvatarProps} from 'sentry/components/core/avatar/userAvatar';
85
import Placeholder from 'sentry/components/placeholder';
96
import type {Actor} from 'sentry/types/core';
107
import {useMembers} from 'sentry/utils/useMembers';
118
import {useTeamsById} from 'sentry/utils/useTeamsById';
129

10+
import {BaseAvatar, type BaseAvatarProps} from './baseAvatar';
11+
import {TeamAvatar, type TeamAvatarProps} from './teamAvatar';
12+
import {UserAvatar, type UserAvatarProps} from './userAvatar';
13+
1314
// Allows us to pass in an actor if we do not have any info aside from the ID
1415
interface SimpleActor extends Omit<Actor, 'name'> {
1516
name?: string;

static/app/components/core/avatar/avatarList.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {UserFixture} from 'sentry-fixture/user';
33

44
import {render, screen} from 'sentry-test/reactTestingLibrary';
55

6-
import AvatarList from 'sentry/components/core/avatar/avatarList';
6+
import AvatarList from './avatarList';
77

88
function renderComponent({
99
users,

static/app/components/core/avatar/avatarList.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import {Fragment, useEffect} from 'react';
22

3-
import AvatarList from 'sentry/components/core/avatar/avatarList';
43
import Placeholder from 'sentry/components/placeholder';
54
import * as Storybook from 'sentry/stories';
65
import {useMembers} from 'sentry/utils/useMembers';
76
import {useUserTeams} from 'sentry/utils/useUserTeams';
87

8+
import AvatarList from './avatarList';
9+
910
function useLoadedMembers() {
1011
const {members, loadMore, ...rest} = useMembers({limit: 50});
1112

static/app/components/core/avatar/avatarList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import {css, type Theme} from '@emotion/react';
22
import styled from '@emotion/styled';
33

4-
import {TeamAvatar} from 'sentry/components/core/avatar/teamAvatar';
5-
import {UserAvatar, type UserAvatarProps} from 'sentry/components/core/avatar/userAvatar';
64
import {Tag} from 'sentry/components/core/badge/tag';
75
import {Tooltip} from 'sentry/components/core/tooltip';
86
import type {Actor} from 'sentry/types/core';
97
import type {Team} from 'sentry/types/organization';
108
import type {AvatarUser} from 'sentry/types/user';
119
import {useHasStreamlinedUI} from 'sentry/views/issueDetails/utils';
1210

11+
import {TeamAvatar} from './teamAvatar';
12+
import {UserAvatar, type UserAvatarProps} from './userAvatar';
13+
1314
type Props = {
1415
avatarSize?: number;
1516
className?: string;

static/app/components/core/avatar/baseAvatar.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ import styled from '@emotion/styled';
44
import classNames from 'classnames';
55
import * as qs from 'query-string';
66

7-
import {Gravatar} from 'sentry/components/core/avatar/gravatar';
8-
import {LetterAvatar} from 'sentry/components/core/avatar/letterAvatar';
97
import {Tooltip, type TooltipProps} from 'sentry/components/core/tooltip';
108
import type {Avatar as AvatarType} from 'sentry/types/core';
119

12-
import {
13-
type BaseAvatarComponentProps,
14-
BaseAvatarComponentStyles,
15-
} from './baseAvatarComponentStyles';
10+
import {type BaseAvatarStyleProps, baseAvatarStyles} from './baseAvatarComponentStyles';
11+
import {Gravatar} from './gravatar';
12+
import {LetterAvatar} from './letterAvatar';
1613

1714
const DEFAULT_REMOTE_SIZE = 120;
1815

@@ -143,6 +140,6 @@ const AvatarContainer = styled('span')<{
143140
background-color: ${p => (p.suggested ? p.theme.background : 'none')};
144141
`;
145142

146-
const ImageAvatar = styled('img')<BaseAvatarComponentProps>`
147-
${BaseAvatarComponentStyles};
143+
const ImageAvatar = styled('img')<BaseAvatarStyleProps>`
144+
${baseAvatarStyles};
148145
`;

static/app/components/core/avatar/baseAvatarComponentStyles.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {css} from '@emotion/react';
22

3-
export interface BaseAvatarComponentProps {
3+
export interface BaseAvatarStyleProps {
44
round?: boolean;
55
suggested?: boolean;
66
}
77

8-
export const BaseAvatarComponentStyles = (props: BaseAvatarComponentProps) => css`
8+
export const baseAvatarStyles = (props: BaseAvatarStyleProps) => css`
99
position: absolute;
1010
top: 0px;
1111
left: 0px;

static/app/components/core/avatar/docIntegrationAvatar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import {BaseAvatar, type BaseAvatarProps} from 'sentry/components/core/avatar/baseAvatar';
21
import {PluginIcon} from 'sentry/plugins/components/pluginIcon';
32
import type {DocIntegration} from 'sentry/types/integrations';
43

4+
import {BaseAvatar, type BaseAvatarProps} from './baseAvatar';
5+
56
interface DocIntegrationAvatarProps extends BaseAvatarProps {
67
docIntegration?: DocIntegration;
78
ref?: React.Ref<HTMLSpanElement>;

static/app/components/core/avatar/gravatar.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {render, screen} from 'sentry-test/reactTestingLibrary';
22

3-
import {Gravatar} from 'sentry/components/core/avatar/gravatar';
3+
import {Gravatar} from './gravatar';
44

55
describe('Gravatar', () => {
66
it('renders the image with remote size', async () => {

static/app/components/core/avatar/gravatar.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ import styled from '@emotion/styled';
33
import * as Sentry from '@sentry/react';
44
import * as qs from 'query-string';
55

6-
import {
7-
type BaseAvatarComponentProps,
8-
BaseAvatarComponentStyles,
9-
} from 'sentry/components/core/avatar/baseAvatarComponentStyles';
106
import ConfigStore from 'sentry/stores/configStore';
117

12-
interface GravatarProps extends BaseAvatarComponentProps {
8+
import {type BaseAvatarStyleProps, baseAvatarStyles} from './baseAvatarComponentStyles';
9+
10+
interface GravatarProps extends BaseAvatarStyleProps {
1311
remoteSize: number;
1412
gravatarId?: string;
1513
onError?: () => void;
@@ -94,6 +92,6 @@ async function hashGravatarId(message = ''): Promise<string> {
9492
.join('');
9593
}
9694

97-
const Image = styled('img')<BaseAvatarComponentProps>`
98-
${BaseAvatarComponentStyles};
95+
const Image = styled('img')<BaseAvatarStyleProps>`
96+
${baseAvatarStyles};
9997
`;

static/app/components/core/avatar/index.stories.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import {Fragment} from 'react';
22

3-
import {DocIntegrationAvatar} from 'sentry/components/core/avatar/docIntegrationAvatar';
4-
import {OrganizationAvatar} from 'sentry/components/core/avatar/organizationAvatar';
5-
import {ProjectAvatar} from 'sentry/components/core/avatar/projectAvatar';
6-
import {SentryAppAvatar} from 'sentry/components/core/avatar/sentryAppAvatar';
7-
import {TeamAvatar} from 'sentry/components/core/avatar/teamAvatar';
8-
import {UserAvatar} from 'sentry/components/core/avatar/userAvatar';
93
import * as Storybook from 'sentry/stories';
104

5+
import {DocIntegrationAvatar} from './docIntegrationAvatar';
6+
import {OrganizationAvatar} from './organizationAvatar';
7+
import {ProjectAvatar} from './projectAvatar';
8+
import {SentryAppAvatar} from './sentryAppAvatar';
9+
import {TeamAvatar} from './teamAvatar';
10+
import {UserAvatar} from './userAvatar';
11+
1112
// eslint-disable-next-line import/no-webpack-loader-syntax
12-
import types from '!!type-loader!sentry/components/core/avatar/projectAvatar';
13+
import types from '!!type-loader!./projectAvatar';
1314

1415
export default Storybook.story('Avatar', (story, APIReference) => {
1516
APIReference(types.Avatar);

static/app/components/core/avatar/letterAvatar.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {render, screen} from 'sentry-test/reactTestingLibrary';
22

3-
import {LetterAvatar} from 'sentry/components/core/avatar/letterAvatar';
3+
import {LetterAvatar} from './letterAvatar';
44

55
describe('LetterAvatar', function () {
66
const USER_1 = {

static/app/components/core/avatar/letterAvatar.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ import styled from '@emotion/styled';
55

66
import {isChonkTheme} from 'sentry/utils/theme/withChonk';
77

8-
import {
9-
type BaseAvatarComponentProps,
10-
BaseAvatarComponentStyles,
11-
} from './baseAvatarComponentStyles';
8+
import {type BaseAvatarStyleProps, baseAvatarStyles} from './baseAvatarComponentStyles';
129

1310
interface LetterAvatarProps
1411
extends React.HTMLAttributes<SVGSVGElement>,
15-
BaseAvatarComponentProps {
12+
BaseAvatarStyleProps {
1613
displayName?: string;
1714
identifier?: string;
1815
ref?: React.Ref<SVGSVGElement>;
@@ -42,7 +39,7 @@ export function LetterAvatar({displayName, ref, ...props}: LetterAvatarProps) {
4239
}
4340

4441
const LetterAvatarComponent = styled('svg')<LetterAvatarProps>`
45-
${BaseAvatarComponentStyles};
42+
${baseAvatarStyles};
4643
4744
rect {
4845
fill: ${props =>

static/app/components/core/avatar/organizationAvatar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import {BaseAvatar, type BaseAvatarProps} from 'sentry/components/core/avatar/baseAvatar';
21
import type {OrganizationSummary} from 'sentry/types/organization';
32
import {explodeSlug} from 'sentry/utils';
43

4+
import {BaseAvatar, type BaseAvatarProps} from './baseAvatar';
5+
56
interface OrganizationAvatarProps extends BaseAvatarProps {
67
organization?: OrganizationSummary;
78
ref?: React.Ref<HTMLSpanElement>;

static/app/components/core/avatar/projectAvatar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import type {BaseAvatarProps} from 'sentry/components/core/avatar/baseAvatar';
21
import {Tooltip} from 'sentry/components/core/tooltip';
32
import {PlatformList} from 'sentry/components/platformList';
43
import type {AvatarProject} from 'sentry/types/project';
54

5+
import type {BaseAvatarProps} from './baseAvatar';
6+
67
interface ProjectAvatarProps extends BaseAvatarProps {
78
project: AvatarProject;
89
direction?: 'left' | 'right';

static/app/components/core/avatar/sentryAppAvatar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import {BaseAvatar, type BaseAvatarProps} from 'sentry/components/core/avatar/baseAvatar';
21
import {IconGeneric} from 'sentry/icons';
32
import type {AvatarSentryApp} from 'sentry/types/integrations';
43

4+
import {BaseAvatar, type BaseAvatarProps} from './baseAvatar';
5+
56
interface SentryAppAvatarProps extends BaseAvatarProps {
67
isColor?: boolean;
78
isDefault?: boolean;

static/app/components/core/avatar/teamAvatar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import type React from 'react';
22

3-
import {BaseAvatar, type BaseAvatarProps} from 'sentry/components/core/avatar/baseAvatar';
43
import type {Team} from 'sentry/types/organization';
54
import {explodeSlug} from 'sentry/utils';
65

6+
import {BaseAvatar, type BaseAvatarProps} from './baseAvatar';
7+
78
export interface TeamAvatarProps extends BaseAvatarProps {
89
team: Team | undefined;
910
ref?: React.Ref<HTMLSpanElement | SVGSVGElement | HTMLImageElement>;

static/app/components/core/avatar/userAvatar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type React from 'react';
22

3-
import {BaseAvatar, type BaseAvatarProps} from 'sentry/components/core/avatar/baseAvatar';
43
import type {Actor} from 'sentry/types/core';
54
import type {AvatarUser} from 'sentry/types/user';
65
import {userDisplayName} from 'sentry/utils/formatters';
76

7+
import {BaseAvatar, type BaseAvatarProps} from './baseAvatar';
8+
89
export interface UserAvatarProps extends BaseAvatarProps {
910
gravatar?: boolean;
1011
ref?: React.Ref<HTMLSpanElement | SVGSVGElement | HTMLImageElement>;

0 commit comments

Comments
 (0)