15
15
*/
16
16
17
17
/* eslint-disable eqeqeq */
18
- import { useState } from 'react'
19
18
import moment from 'moment'
20
19
import Tippy from '@tippyjs/react'
21
20
import ClipboardButton from '@Common/ClipboardButton/ClipboardButton'
@@ -48,8 +47,6 @@ const GitCommitInfoGeneric = ({
48
47
index,
49
48
isExcluded = false ,
50
49
} : GitCommitInfoGenericProps ) => {
51
- const [ showSeeMore , setShowSeeMore ] = useState ( true )
52
-
53
50
const lowerCaseCommitInfo = getLowerCaseObject ( commitInfo )
54
51
const _isWebhook =
55
52
materialSourceType === SourceTypeMap . WEBHOOK ||
@@ -111,80 +108,6 @@ const GitCommitInfoGeneric = ({
111
108
)
112
109
}
113
110
114
- function renderMoreDataForWebhook ( _moreData ) {
115
- return ! showSeeMore ? (
116
- < div className = "material-history__all-changes" >
117
- < div className = "material-history__body mt-4" >
118
- { Object . keys ( _moreData ) . map ( ( _key , idx ) => {
119
- let classes
120
- if ( idx % 2 == 0 ) {
121
- classes = 'bcn-1'
122
- }
123
- return (
124
- < div
125
- key = { _key }
126
- className = { `material-history__text material-history__grid left pt-4 pb-4 ${ classes } ` }
127
- >
128
- < div > { _key } </ div >
129
- < div > { _moreData [ _key ] } </ div >
130
- </ div >
131
- )
132
- } ) }
133
- </ div >
134
- </ div >
135
- ) : null
136
- }
137
-
138
- function renderSeeMoreButtonForWebhook ( ) {
139
- return (
140
- < button
141
- type = "button"
142
- className = "fs-12 fw-6 pt-12 mt-12 pl-12 pr-12 w-100 bcn-0 flex left br-4 dc__box-shadow-top cb-5 dc__no-border"
143
- onClick = { ( event ) => {
144
- event . stopPropagation ( )
145
- setShowSeeMore ( ! showSeeMore )
146
- } }
147
- >
148
- { showSeeMore ? 'See More' : 'See Less' }
149
- </ button >
150
- )
151
- }
152
-
153
- function handleMoreDataForWebhook ( ) {
154
- const _moreData = { }
155
- if ( _webhookData . eventactiontype === WEBHOOK_EVENT_ACTION_TYPE . MERGED ) {
156
- Object . keys ( _webhookData . data ) . forEach ( ( _key ) => {
157
- if (
158
- _key != 'author' &&
159
- _key != 'date' &&
160
- _key != 'git url' &&
161
- _key != 'source branch name' &&
162
- _key != 'source checkout' &&
163
- _key != 'target branch name' &&
164
- _key != 'target checkout' &&
165
- _key != 'title'
166
- ) {
167
- _moreData [ _key ] = _webhookData . data [ _key ]
168
- }
169
- } )
170
- } else if ( _webhookData . eventactiontype === WEBHOOK_EVENT_ACTION_TYPE . NON_MERGED ) {
171
- Object . keys ( _webhookData . data ) . forEach ( ( _key ) => {
172
- if ( _key !== 'author' && _key !== 'date' && _key !== 'target checkout' ) {
173
- _moreData [ _key ] = _webhookData . data [ _key ]
174
- }
175
- } )
176
- }
177
-
178
- const _hasMoreData = Object . keys ( _moreData ) . length > 0
179
-
180
- return (
181
- < >
182
- { _hasMoreData && renderMoreDataForWebhook ( _moreData ) }
183
- { _hasMoreData && renderSeeMoreButtonForWebhook ( ) }
184
- </ >
185
- )
186
- }
187
-
188
111
const matSelectionText = ( ) : JSX . Element => {
189
112
if ( isExcluded ) {
190
113
return (
@@ -220,7 +143,7 @@ const GitCommitInfoGeneric = ({
220
143
_webhookData . data . title ? < span className = "flex left cn-9 fw-6 fs-13" > { _webhookData . data . title } </ span > : null
221
144
222
145
const renderPullRequestId = ( pullRequestUrl : string ) => {
223
- const pullRequestId = pullRequestUrl . split ( '/' ) . pop ( )
146
+ const pullRequestId = pullRequestUrl ? .split ( '/' ) . pop ( )
224
147
225
148
return (
226
149
< div className = "w-100 flex left dc__gap-4" >
@@ -240,10 +163,10 @@ const GitCommitInfoGeneric = ({
240
163
)
241
164
}
242
165
243
- const renderTagCreationId = ( ) => (
166
+ const renderTagCreationId = ( tagRequestUrl : string ) => (
244
167
< div className = "commit-hash px-6 dc__w-fit-content dc__gap-4 fs-13" >
245
168
< Tag className = "icon-dim-14 scb-5" />
246
- { _webhookData . data [ 'target checkout' ] }
169
+ { tagRequestUrl }
247
170
</ div >
248
171
)
249
172
@@ -267,7 +190,6 @@ const GitCommitInfoGeneric = ({
267
190
</ div >
268
191
{ renderWebhookTitle ( ) }
269
192
{ renderBasicGitCommitInfoForWebhook ( true ) }
270
- { handleMoreDataForWebhook ( ) }
271
193
</ div >
272
194
)
273
195
@@ -276,11 +198,10 @@ const GitCommitInfoGeneric = ({
276
198
_webhookData . eventactiontype === WEBHOOK_EVENT_ACTION_TYPE . NON_MERGED && (
277
199
< >
278
200
< div className = "flex left dc__content-space" >
279
- { renderTagCreationId ( ) }
201
+ { renderTagCreationId ( _webhookData . data [ 'target checkout' ] ) }
280
202
{ getCheckUncheckIcon ( ) }
281
203
</ div >
282
204
{ renderBasicGitCommitInfoForWebhook ( ) }
283
- { handleMoreDataForWebhook ( ) }
284
205
</ >
285
206
)
286
207
0 commit comments