) : null}
{_webhookData.data.message ? (
-
+
{_webhookData.data.message}
) : null}
- >
- )
- }
-
- function renderMoreDataForWebhook(_moreData) {
- return !showSeeMore ? (
-
-
- {Object.keys(_moreData).map((_key, idx) => {
- let classes
- if (idx % 2 == 0) {
- classes = 'bcn-1'
- }
- return (
-
-
{_key}
-
{_moreData[_key]}
-
- )
- })}
-
- ) : null
- }
-
- function renderSeeMoreButtonForWebhook() {
- return (
-
- )
- }
-
- function handleMoreDataForWebhook() {
- const _moreData = {}
- if (_webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED) {
- Object.keys(_webhookData.data).forEach((_key) => {
- if (
- _key != 'author' &&
- _key != 'date' &&
- _key != 'git url' &&
- _key != 'source branch name' &&
- _key != 'source checkout' &&
- _key != 'target branch name' &&
- _key != 'target checkout' &&
- _key != 'title'
- ) {
- _moreData[_key] = _webhookData.data[_key]
- }
- })
- } else if (_webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED) {
- Object.keys(_webhookData.data).forEach((_key) => {
- if (_key !== 'author' && _key !== 'date' && _key !== 'target checkout') {
- _moreData[_key] = _webhookData.data[_key]
- }
- })
- }
-
- const _hasMoreData = Object.keys(_moreData).length > 0
-
- return (
- <>
- {_hasMoreData && renderMoreDataForWebhook(_moreData)}
- {_hasMoreData && renderSeeMoreButtonForWebhook()}
- >
)
}
@@ -207,15 +133,89 @@ const GitCommitInfoGeneric = ({
}
const renderCommitStatus = () => {
- if (_lowerCaseCommitInfo.isselected) {
+ if (lowerCaseCommitInfo.isselected) {
return
}
return matSelectionText()
}
+ const renderWebhookTitle = () =>
+ _webhookData.data.title ?
{_webhookData.data.title} : null
+
+ const renderPullRequestId = (pullRequestUrl: string) => {
+ const pullRequestId = pullRequestUrl?.split('/').pop()
+
+ return (
+
+ )
+ }
+
+ const renderTagCreationId = (tagRequestUrl: string) => (
+
+
+ {tagRequestUrl}
+
+ )
+
+ const getCheckUncheckIcon = () => {
+ if (selectedCommitInfo) {
+ if (lowerCaseCommitInfo.isselected) {
+ return
+ }
+ return
+ }
+ return null
+ }
+
+ const renderPRInfoCard = () => (
+
+
+ {renderPullRequestId(_webhookData.data['git url'])}
+ {getCheckUncheckIcon()}
+
+ {renderWebhookTitle()}
+ {renderBasicGitCommitInfoForWebhook(true)}
+
+ )
+
+ const renderTagInfoCard = () => (
+ <>
+
+ {renderTagCreationId(_webhookData.data['target checkout'])}
+ {getCheckUncheckIcon()}
+
+ {renderBasicGitCommitInfoForWebhook()}
+ >
+ )
+
+ const renderWebhookGitInfoCard = () => {
+ if (!_isWebhook) return null
+
+ const isMerged = _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED
+
+ if (materialUrl.includes(GitProviderType.GITLAB)) {
+ // TODO: This is a temporary fix for the issue where the eventActionType data incorrect
+ return isMerged ? renderTagInfoCard() : renderPRInfoCard()
+ }
+ return isMerged ? renderPRInfoCard() : renderTagInfoCard()
+ }
+
return (
- {showMaterialInfoHeader && (_isWebhook || _lowerCaseCommitInfo.commit) && (
+ {showMaterialInfoHeader && (_isWebhook || lowerCaseCommitInfo.commit) && (
{!_isWebhook && (
<>
- {_lowerCaseCommitInfo.commit && (
+ {lowerCaseCommitInfo.commit && (
{_commitUrl ? (
@@ -243,163 +243,49 @@ const GitCommitInfoGeneric = ({
data-testid={`git-commit-credential${index}`}
>
- {_lowerCaseCommitInfo.commit.slice(0, 7)}
+ {lowerCaseCommitInfo.commit.slice(0, 7)}
-
+
) : null}
{selectedCommitInfo ? renderCommitStatus() : null}
)}
- {_lowerCaseCommitInfo.message ? (
+ {lowerCaseCommitInfo.message ? (
- {_lowerCaseCommitInfo.message}
+ {lowerCaseCommitInfo.message}
) : null}
- {_lowerCaseCommitInfo.author ? (
+ {lowerCaseCommitInfo.author ? (
-
{_lowerCaseCommitInfo.author}
+
{lowerCaseCommitInfo.author}
) : null}
- {_lowerCaseCommitInfo.date ? (
+ {lowerCaseCommitInfo.date ? (
- {moment(_lowerCaseCommitInfo.date).format(
- DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT,
- )}
+ {moment(lowerCaseCommitInfo.date).format(DATE_TIME_FORMATS.TWELVE_HOURS_FORMAT)}
) : null}
>
)}
-
- {_isWebhook && _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.MERGED && (
- <>
-
-
- {_webhookData.data.title ? (
-
{_webhookData.data.title}
- ) : null}
- {_webhookData.data['git url'] ? (
-
- View git url
-
- ) : null}
-
- {selectedCommitInfo ? (
-
- {_lowerCaseCommitInfo.isselected ? (
-
- ) : (
-
- )}
-
- ) : null}
-
-
-
-
-
-
-
- {_webhookData.data['source branch name'] ? (
-
- {' '}
- {_webhookData.data['source branch name']}
-
- ) : null}
- {_webhookData.data['source checkout'] ? (
-
- ) : null}
-
-
-
- {_webhookData.data['target branch name'] ? (
- <>
- {' '}
- {_webhookData.data['target branch name']}{' '}
- >
- ) : null}
-
-
-
-
-
-
- {renderBasicGitCommitInfoForWebhook()}
- {handleMoreDataForWebhook()}
- >
- )}
- {_isWebhook && _webhookData.eventactiontype === WEBHOOK_EVENT_ACTION_TYPE.NON_MERGED && (
- <>
-
-
{_webhookData.data['target checkout']}
- {selectedCommitInfo ? (
-
- {_lowerCaseCommitInfo.isselected ? : 'Select'}
-
- ) : null}
-
- {renderBasicGitCommitInfoForWebhook()}
- {handleMoreDataForWebhook()}
- >
- )}
+ {renderWebhookGitInfoCard()}