@@ -25,18 +25,13 @@ import {useRelease} from 'sentry/utils/useRelease';
25
25
import { useRepositories } from 'sentry/utils/useRepositories' ;
26
26
import { parseVersion } from 'sentry/utils/versions/parseVersion' ;
27
27
28
- interface Props extends React . ComponentProps < typeof Hovercard > {
28
+ interface BodyProps {
29
29
organization : Organization ;
30
30
projectSlug : string ;
31
31
releaseVersion : string ;
32
32
}
33
33
34
- function VersionHoverCard ( {
35
- organization,
36
- projectSlug,
37
- releaseVersion,
38
- ...hovercardProps
39
- } : Props ) {
34
+ function VersionHoverCardBody ( { organization, releaseVersion, projectSlug} : BodyProps ) {
40
35
const {
41
36
data : repositories ,
42
37
isPending : isRepositoriesLoading ,
@@ -62,22 +57,19 @@ function VersionHoverCard({
62
57
63
58
function getRepoLink ( ) {
64
59
const orgSlug = organization . slug ;
65
- return {
66
- header : null ,
67
- body : (
68
- < ConnectRepo >
69
- < h5 > { t ( 'Releases are better with commit data!' ) } </ h5 >
70
- < p >
71
- { t (
72
- 'Connect a repository to see commit info, files changed, and authors involved in future releases.'
73
- ) }
74
- </ p >
75
- < LinkButton to = { `/settings/${ orgSlug } /repos/` } priority = "primary" >
76
- { t ( 'Connect a repository' ) }
77
- </ LinkButton >
78
- </ ConnectRepo >
79
- ) ,
80
- } ;
60
+ return (
61
+ < ConnectRepo >
62
+ < h5 > { t ( 'Releases are better with commit data!' ) } </ h5 >
63
+ < p >
64
+ { t (
65
+ 'Connect a repository to see commit info, files changed, and authors involved in future releases.'
66
+ ) }
67
+ </ p >
68
+ < LinkButton to = { `/settings/${ orgSlug } /repos/` } priority = "primary" >
69
+ { t ( 'Connect a repository' ) }
70
+ </ LinkButton >
71
+ </ ConnectRepo >
72
+ ) ;
81
73
}
82
74
83
75
const authors = useMemo (
@@ -95,7 +87,7 @@ function VersionHoverCard({
95
87
96
88
function getBody ( ) {
97
89
if ( release === undefined || ! defined ( deploys ) ) {
98
- return { header : null , body : null } ;
90
+ return null ;
99
91
}
100
92
101
93
const parsedVersion = parseVersion ( releaseVersion ) ;
@@ -106,93 +98,108 @@ function VersionHoverCard({
106
98
)
107
99
. slice ( 0 , 3 ) ;
108
100
109
- return {
110
- header : < VersionHoverHeader releaseVersion = { releaseVersion } /> ,
111
- body : (
112
- < Flex direction = "column" gap = { space ( 2 ) } >
113
- < Flex gap = { space ( 2 ) } justify = "space-between" >
114
- < div >
115
- < h6 > { t ( 'New Issues' ) } </ h6 >
116
- < CountSince > { release . newGroups } </ CountSince >
117
- </ div >
118
- < div >
119
- < h6 style = { { textAlign : 'right' } } > { t ( 'Date Created' ) } </ h6 >
120
- < DateTime date = { release . dateCreated } seconds = { false } />
121
- </ div >
122
- </ Flex >
123
- { parsedVersion ?. package && (
124
- < Flex direction = "column" gap = { space ( 2 ) } justify = "space-between" >
125
- { parsedVersion . package && (
126
- < div >
127
- < h6 > { t ( 'Package' ) } </ h6 >
128
- < div > { parsedVersion . package } </ div >
129
- </ div >
130
- ) }
131
- { release . commitCount > 0 ? (
132
- < div >
133
- < h6 >
134
- { release . commitCount } { ' ' }
135
- { release . commitCount === 1 ? t ( 'commit ' ) : t ( 'commits ' ) } { t ( 'by ' ) } { ' ' }
136
- { release . authors . length } { ' ' }
137
- { release . authors . length === 1 ? t ( 'author' ) : t ( 'authors' ) } { ' ' }
138
- </ h6 >
139
- < AvatarListContainer >
140
- < AvatarList
141
- users = { authors }
142
- avatarSize = { 25 }
143
- tooltipOptions = { { container : 'body' } as any }
144
- typeAvatars = "authors"
145
- />
146
- </ AvatarListContainer >
147
- </ div >
148
- ) : null }
149
- </ Flex >
150
- ) }
151
- { release . lastCommit && < LastCommit commit = { release . lastCommit } /> }
152
- { deploys . length > 0 && (
153
- < Flex direction = "column" gap = { space ( 0.5 ) } >
154
- < h6 > { t ( 'Deploys' ) } </ h6 >
155
- { recentDeploysByEnvironment . map ( deploy => {
156
- return (
157
- < Flex
158
- key = { deploy . id }
159
- align = "center"
160
- gap = { space ( 1 ) }
161
- justify = "space-between"
162
- >
163
- < Tag type = "highlight" > { deploy . environment } </ Tag >
164
- { deploy . dateFinished && (
165
- < StyledTimeSince date = { deploy . dateFinished } />
166
- ) }
167
- </ Flex >
168
- ) ;
169
- } ) }
170
- </ Flex >
171
- ) }
101
+ return (
102
+ < Flex direction = "column" gap = { space ( 2 ) } >
103
+ < Flex gap = { space ( 2 ) } justify = "space-between" >
104
+ < div >
105
+ < h6 > { t ( 'New Issues' ) } </ h6 >
106
+ < CountSince > { release . newGroups } </ CountSince >
107
+ </ div >
108
+ < div >
109
+ < h6 style = { { textAlign : 'right' } } > { t ( 'Date Created' ) } </ h6 >
110
+ < DateTime date = { release . dateCreated } seconds = { false } />
111
+ </ div >
172
112
</ Flex >
173
- ) ,
174
- } ;
113
+ { parsedVersion ?. package && (
114
+ < Flex direction = "column" gap = { space ( 2 ) } justify = "space-between" >
115
+ { parsedVersion . package && (
116
+ < div >
117
+ < h6 > { t ( 'Package' ) } </ h6 >
118
+ < div > { parsedVersion . package } </ div >
119
+ </ div >
120
+ ) }
121
+ { release . commitCount > 0 ? (
122
+ < div >
123
+ < h6 >
124
+ { release . commitCount } { ' ' }
125
+ { release . commitCount === 1 ? t ( 'commit ' ) : t ( 'commits ' ) } { t ( 'by ' ) } { ' ' }
126
+ { release . authors . length } { ' ' }
127
+ { release . authors . length === 1 ? t ( 'author' ) : t ( 'authors' ) } { ' ' }
128
+ </ h6 >
129
+ < AvatarListContainer >
130
+ < AvatarList
131
+ users = { authors }
132
+ avatarSize = { 25 }
133
+ tooltipOptions = { { container : 'body' } as any }
134
+ typeAvatars = "authors"
135
+ />
136
+ </ AvatarListContainer >
137
+ </ div >
138
+ ) : null }
139
+ </ Flex >
140
+ ) }
141
+ { release . lastCommit && < LastCommit commit = { release . lastCommit } /> }
142
+ { deploys . length > 0 && (
143
+ < Flex direction = "column" gap = { space ( 0.5 ) } >
144
+ < h6 > { t ( 'Deploys' ) } </ h6 >
145
+ { recentDeploysByEnvironment . map ( deploy => {
146
+ return (
147
+ < Flex
148
+ key = { deploy . id }
149
+ align = "center"
150
+ gap = { space ( 1 ) }
151
+ justify = "space-between"
152
+ >
153
+ < Tag type = "highlight" > { deploy . environment } </ Tag >
154
+ { deploy . dateFinished && < StyledTimeSince date = { deploy . dateFinished } /> }
155
+ </ Flex >
156
+ ) ;
157
+ } ) }
158
+ </ Flex >
159
+ ) }
160
+ </ Flex >
161
+ ) ;
175
162
}
176
163
177
- let header : React . ReactNode = null ;
178
- let body : React . ReactNode = null ;
179
-
180
- const loading = ! ! ( isDeploysLoading || isReleaseLoading || isRepositoriesLoading ) ;
164
+ const loading = isDeploysLoading || isReleaseLoading || isRepositoriesLoading ;
181
165
const error = isDeploysError ?? isReleaseError ?? isRepositoriesError ;
182
166
const hasRepos = repositories && repositories . length > 0 ;
183
167
184
168
if ( loading ) {
185
- body = < LoadingIndicator mini /> ;
186
- } else if ( error ) {
187
- body = < LoadingError /> ;
188
- } else {
189
- const renderObj : { body : React . ReactNode ; header : React . ReactNode } =
190
- hasRepos && release ? getBody ( ) : getRepoLink ( ) ;
191
- header = renderObj . header ;
192
- body = renderObj . body ;
169
+ return (
170
+ < Flex justify = "center" >
171
+ < LoadingIndicator mini />
172
+ </ Flex >
173
+ ) ;
193
174
}
175
+ if ( error ) {
176
+ return < LoadingError /> ;
177
+ }
178
+
179
+ return hasRepos && release ? getBody ( ) : getRepoLink ( ) ;
180
+ }
181
+
182
+ interface Props extends React . ComponentProps < typeof Hovercard > , BodyProps { }
194
183
195
- return < Hovercard { ...hovercardProps } header = { header } body = { body } /> ;
184
+ function VersionHoverCard ( {
185
+ organization,
186
+ projectSlug,
187
+ releaseVersion,
188
+ ...hovercardProps
189
+ } : Props ) {
190
+ return (
191
+ < Hovercard
192
+ { ...hovercardProps }
193
+ header = { < VersionHoverHeader releaseVersion = { releaseVersion } /> }
194
+ body = {
195
+ < VersionHoverCardBody
196
+ organization = { organization }
197
+ projectSlug = { projectSlug }
198
+ releaseVersion = { releaseVersion }
199
+ />
200
+ }
201
+ />
202
+ ) ;
196
203
}
197
204
198
205
interface VersionHoverHeaderProps {
0 commit comments