mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 11:57:51 +01:00
Update dashboard context for PR reviews (#8995)
* Update dashboard context for PR reviews Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update options/locale/locale_en-US.ini Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Only append head action if it has content or is approval/rejection Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update options/locale/locale_en-US.ini Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
This commit is contained in:
parent
dd1beee2ef
commit
06a8504c78
@ -30,26 +30,28 @@ type ActionType int
|
|||||||
|
|
||||||
// Possible action types.
|
// Possible action types.
|
||||||
const (
|
const (
|
||||||
ActionCreateRepo ActionType = iota + 1 // 1
|
ActionCreateRepo ActionType = iota + 1 // 1
|
||||||
ActionRenameRepo // 2
|
ActionRenameRepo // 2
|
||||||
ActionStarRepo // 3
|
ActionStarRepo // 3
|
||||||
ActionWatchRepo // 4
|
ActionWatchRepo // 4
|
||||||
ActionCommitRepo // 5
|
ActionCommitRepo // 5
|
||||||
ActionCreateIssue // 6
|
ActionCreateIssue // 6
|
||||||
ActionCreatePullRequest // 7
|
ActionCreatePullRequest // 7
|
||||||
ActionTransferRepo // 8
|
ActionTransferRepo // 8
|
||||||
ActionPushTag // 9
|
ActionPushTag // 9
|
||||||
ActionCommentIssue // 10
|
ActionCommentIssue // 10
|
||||||
ActionMergePullRequest // 11
|
ActionMergePullRequest // 11
|
||||||
ActionCloseIssue // 12
|
ActionCloseIssue // 12
|
||||||
ActionReopenIssue // 13
|
ActionReopenIssue // 13
|
||||||
ActionClosePullRequest // 14
|
ActionClosePullRequest // 14
|
||||||
ActionReopenPullRequest // 15
|
ActionReopenPullRequest // 15
|
||||||
ActionDeleteTag // 16
|
ActionDeleteTag // 16
|
||||||
ActionDeleteBranch // 17
|
ActionDeleteBranch // 17
|
||||||
ActionMirrorSyncPush // 18
|
ActionMirrorSyncPush // 18
|
||||||
ActionMirrorSyncCreate // 19
|
ActionMirrorSyncCreate // 19
|
||||||
ActionMirrorSyncDelete // 20
|
ActionMirrorSyncDelete // 20
|
||||||
|
ActionApprovePullRequest // 21
|
||||||
|
ActionRejectPullRequest // 22
|
||||||
)
|
)
|
||||||
|
|
||||||
// Action represents user operation type and other information to
|
// Action represents user operation type and other information to
|
||||||
|
@ -148,18 +148,28 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.TrimSpace(comment.Content) != "" {
|
if review.Type != models.ReviewTypeComment || strings.TrimSpace(comment.Content) != "" {
|
||||||
actions = append(actions, &models.Action{
|
action := &models.Action{
|
||||||
ActUserID: review.Reviewer.ID,
|
ActUserID: review.Reviewer.ID,
|
||||||
ActUser: review.Reviewer,
|
ActUser: review.Reviewer,
|
||||||
Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(comment.Content, "\n")[0]),
|
Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(comment.Content, "\n")[0]),
|
||||||
OpType: models.ActionCommentIssue,
|
|
||||||
RepoID: review.Issue.RepoID,
|
RepoID: review.Issue.RepoID,
|
||||||
Repo: review.Issue.Repo,
|
Repo: review.Issue.Repo,
|
||||||
IsPrivate: review.Issue.Repo.IsPrivate,
|
IsPrivate: review.Issue.Repo.IsPrivate,
|
||||||
Comment: comment,
|
Comment: comment,
|
||||||
CommentID: comment.ID,
|
CommentID: comment.ID,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
switch review.Type {
|
||||||
|
case models.ReviewTypeApprove:
|
||||||
|
action.OpType = models.ActionApprovePullRequest
|
||||||
|
case models.ReviewTypeReject:
|
||||||
|
action.OpType = models.ActionRejectPullRequest
|
||||||
|
default:
|
||||||
|
action.OpType = models.ActionCommentIssue
|
||||||
|
}
|
||||||
|
|
||||||
|
actions = append(actions, action)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := models.NotifyWatchersActions(actions); err != nil {
|
if err := models.NotifyWatchersActions(actions); err != nil {
|
||||||
|
@ -555,6 +555,10 @@ func ActionIcon(opType models.ActionType) string {
|
|||||||
return "issue-reopened"
|
return "issue-reopened"
|
||||||
case models.ActionMirrorSyncPush, models.ActionMirrorSyncCreate, models.ActionMirrorSyncDelete:
|
case models.ActionMirrorSyncPush, models.ActionMirrorSyncCreate, models.ActionMirrorSyncDelete:
|
||||||
return "repo-clone"
|
return "repo-clone"
|
||||||
|
case models.ActionApprovePullRequest:
|
||||||
|
return "eye"
|
||||||
|
case models.ActionRejectPullRequest:
|
||||||
|
return "x"
|
||||||
default:
|
default:
|
||||||
return "invalid type"
|
return "invalid type"
|
||||||
}
|
}
|
||||||
|
@ -2000,6 +2000,8 @@ compare_commits_general = Compare commits
|
|||||||
mirror_sync_push = synced commits to <a href="%[1]s/src/%[2]s">%[3]s</a> at <a href="%[1]s">%[4]s</a> from mirror
|
mirror_sync_push = synced commits to <a href="%[1]s/src/%[2]s">%[3]s</a> at <a href="%[1]s">%[4]s</a> from mirror
|
||||||
mirror_sync_create = synced new reference <a href="%s/src/%s">%[2]s</a> to <a href="%[1]s">%[3]s</a> from mirror
|
mirror_sync_create = synced new reference <a href="%s/src/%s">%[2]s</a> to <a href="%[1]s">%[3]s</a> from mirror
|
||||||
mirror_sync_delete = synced and deleted reference <code>%[2]s</code> at <a href="%[1]s">%[3]s</a> from mirror
|
mirror_sync_delete = synced and deleted reference <code>%[2]s</code> at <a href="%[1]s">%[3]s</a> from mirror
|
||||||
|
approve_pull_request = `approved <a href="%s/pulls/%s">%s#%[2]s</a>`
|
||||||
|
reject_pull_request = `suggested changes for <a href="%s/pulls/%s">%s#%[2]s</a>`
|
||||||
|
|
||||||
[tool]
|
[tool]
|
||||||
ago = %s ago
|
ago = %s ago
|
||||||
|
@ -61,6 +61,12 @@
|
|||||||
{{$.i18n.Tr "action.mirror_sync_create" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}}
|
{{$.i18n.Tr "action.mirror_sync_create" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}}
|
||||||
{{else if eq .GetOpType 20}}
|
{{else if eq .GetOpType 20}}
|
||||||
{{$.i18n.Tr "action.mirror_sync_delete" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}}
|
{{$.i18n.Tr "action.mirror_sync_delete" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}}
|
||||||
|
{{else if eq .GetOpType 21}}
|
||||||
|
{{ $index := index .GetIssueInfos 0}}
|
||||||
|
{{$.i18n.Tr "action.approve_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}}
|
||||||
|
{{else if eq .GetOpType 22}}
|
||||||
|
{{ $index := index .GetIssueInfos 0}}
|
||||||
|
{{$.i18n.Tr "action.reject_pull_request" .GetRepoLink $index .ShortRepoPath | Str2html}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</p>
|
</p>
|
||||||
{{if or (eq .GetOpType 5) (eq .GetOpType 18)}}
|
{{if or (eq .GetOpType 5) (eq .GetOpType 18)}}
|
||||||
@ -80,7 +86,7 @@
|
|||||||
<span class="text truncate issue title has-emoji">{{index .GetIssueInfos 1}}</span>
|
<span class="text truncate issue title has-emoji">{{index .GetIssueInfos 1}}</span>
|
||||||
{{else if eq .GetOpType 7}}
|
{{else if eq .GetOpType 7}}
|
||||||
<span class="text truncate issue title has-emoji">{{index .GetIssueInfos 1}}</span>
|
<span class="text truncate issue title has-emoji">{{index .GetIssueInfos 1}}</span>
|
||||||
{{else if eq .GetOpType 10}}
|
{{else if or (eq .GetOpType 10) (eq .GetOpType 21) (eq .GetOpType 22)}}
|
||||||
<a href="{{.GetCommentLink}}" class="text truncate issue title has-emoji">{{.GetIssueTitle}}</a>
|
<a href="{{.GetCommentLink}}" class="text truncate issue title has-emoji">{{.GetIssueTitle}}</a>
|
||||||
<p class="text light grey has-emoji">{{index .GetIssueInfos 1}}</p>
|
<p class="text light grey has-emoji">{{index .GetIssueInfos 1}}</p>
|
||||||
{{else if eq .GetOpType 11}}
|
{{else if eq .GetOpType 11}}
|
||||||
|
Loading…
Reference in New Issue
Block a user