From 4b3c92206cee50802561ae9abb04880ff3beec03 Mon Sep 17 00:00:00 2001
From: caicandong <1290147055@qq.com>
Date: Thu, 7 Sep 2023 13:31:27 +0800
Subject: [PATCH 1/3] Refactor dashboard/feed.tmpl
---
models/activities/action.go | 95 -------------
models/activities/action_type.go | 209 ++++++++++++++++++++++++++++
templates/user/dashboard/feeds.tmpl | 60 ++++----
3 files changed, 239 insertions(+), 125 deletions(-)
create mode 100644 models/activities/action_type.go
diff --git a/models/activities/action.go b/models/activities/action.go
index 432bf8bf3fec0..953d1e8c01aee 100644
--- a/models/activities/action.go
+++ b/models/activities/action.go
@@ -31,101 +31,6 @@ import (
"xorm.io/xorm/schemas"
)
-// ActionType represents the type of an action.
-type ActionType int
-
-// Possible action types.
-const (
- ActionCreateRepo ActionType = iota + 1 // 1
- ActionRenameRepo // 2
- ActionStarRepo // 3
- ActionWatchRepo // 4
- ActionCommitRepo // 5
- ActionCreateIssue // 6
- ActionCreatePullRequest // 7
- ActionTransferRepo // 8
- ActionPushTag // 9
- ActionCommentIssue // 10
- ActionMergePullRequest // 11
- ActionCloseIssue // 12
- ActionReopenIssue // 13
- ActionClosePullRequest // 14
- ActionReopenPullRequest // 15
- ActionDeleteTag // 16
- ActionDeleteBranch // 17
- ActionMirrorSyncPush // 18
- ActionMirrorSyncCreate // 19
- ActionMirrorSyncDelete // 20
- ActionApprovePullRequest // 21
- ActionRejectPullRequest // 22
- ActionCommentPull // 23
- ActionPublishRelease // 24
- ActionPullReviewDismissed // 25
- ActionPullRequestReadyForReview // 26
- ActionAutoMergePullRequest // 27
-)
-
-func (at ActionType) String() string {
- switch at {
- case ActionCreateRepo:
- return "create_repo"
- case ActionRenameRepo:
- return "rename_repo"
- case ActionStarRepo:
- return "star_repo"
- case ActionWatchRepo:
- return "watch_repo"
- case ActionCommitRepo:
- return "commit_repo"
- case ActionCreateIssue:
- return "create_issue"
- case ActionCreatePullRequest:
- return "create_pull_request"
- case ActionTransferRepo:
- return "transfer_repo"
- case ActionPushTag:
- return "push_tag"
- case ActionCommentIssue:
- return "comment_issue"
- case ActionMergePullRequest:
- return "merge_pull_request"
- case ActionCloseIssue:
- return "close_issue"
- case ActionReopenIssue:
- return "reopen_issue"
- case ActionClosePullRequest:
- return "close_pull_request"
- case ActionReopenPullRequest:
- return "reopen_pull_request"
- case ActionDeleteTag:
- return "delete_tag"
- case ActionDeleteBranch:
- return "delete_branch"
- case ActionMirrorSyncPush:
- return "mirror_sync_push"
- case ActionMirrorSyncCreate:
- return "mirror_sync_create"
- case ActionMirrorSyncDelete:
- return "mirror_sync_delete"
- case ActionApprovePullRequest:
- return "approve_pull_request"
- case ActionRejectPullRequest:
- return "reject_pull_request"
- case ActionCommentPull:
- return "comment_pull"
- case ActionPublishRelease:
- return "publish_release"
- case ActionPullReviewDismissed:
- return "pull_review_dismissed"
- case ActionPullRequestReadyForReview:
- return "pull_request_ready_for_review"
- case ActionAutoMergePullRequest:
- return "auto_merge_pull_request"
- default:
- return "action-" + strconv.Itoa(int(at))
- }
-}
-
// Action represents user operation type and other information to
// repository. It implemented interface base.Actioner so that can be
// used in template render.
diff --git a/models/activities/action_type.go b/models/activities/action_type.go
new file mode 100644
index 0000000000000..66ba6db5c60cb
--- /dev/null
+++ b/models/activities/action_type.go
@@ -0,0 +1,209 @@
+// Copyright 2023 The Gitea Authors. All rights reserved.
+// SPDX-License-Identifier: MIT
+
+package activities
+
+import "strconv"
+
+// ActionType represents the type of an action.
+type ActionType int
+
+// Possible action types.
+const (
+ ActionCreateRepo ActionType = iota + 1 // 1
+ ActionRenameRepo // 2
+ ActionStarRepo // 3
+ ActionWatchRepo // 4
+ ActionCommitRepo // 5
+ ActionCreateIssue // 6
+ ActionCreatePullRequest // 7
+ ActionTransferRepo // 8
+ ActionPushTag // 9
+ ActionCommentIssue // 10
+ ActionMergePullRequest // 11
+ ActionCloseIssue // 12
+ ActionReopenIssue // 13
+ ActionClosePullRequest // 14
+ ActionReopenPullRequest // 15
+ ActionDeleteTag // 16
+ ActionDeleteBranch // 17
+ ActionMirrorSyncPush // 18
+ ActionMirrorSyncCreate // 19
+ ActionMirrorSyncDelete // 20
+ ActionApprovePullRequest // 21
+ ActionRejectPullRequest // 22
+ ActionCommentPull // 23
+ ActionPublishRelease // 24
+ ActionPullReviewDismissed // 25
+ ActionPullRequestReadyForReview // 26
+ ActionAutoMergePullRequest // 27
+)
+
+func (at ActionType) IsActionCreateRepo() bool {
+ return at == ActionCreateRepo
+}
+
+func (at ActionType) IsActionRenameRepo() bool {
+ return at == ActionRenameRepo
+}
+
+func (at ActionType) IsActionStarRepo() bool {
+ return at == ActionStarRepo
+}
+
+func (at ActionType) IsActionWatchRepo() bool {
+ return at == ActionWatchRepo
+}
+
+func (at ActionType) IsActionCommitRepo() bool {
+ return at == ActionCommitRepo
+}
+
+func (at ActionType) IsActionCreateIssue() bool {
+ return at == ActionCreateIssue
+}
+
+func (at ActionType) IsActionCreatePullRequest() bool {
+ return at == ActionCreatePullRequest
+}
+
+func (at ActionType) IsActionTransferRepo() bool {
+ return at == ActionTransferRepo
+}
+
+func (at ActionType) IsActionPushTag() bool {
+ return at == ActionPushTag
+}
+
+func (at ActionType) IsActionCommentIssue() bool {
+ return at == ActionCommentIssue
+}
+
+func (at ActionType) IsActionMergePullRequest() bool {
+ return at == ActionMergePullRequest
+}
+
+func (at ActionType) IsActionCloseIssue() bool {
+ return at == ActionCloseIssue
+}
+
+func (at ActionType) IsActionReopenIssue() bool {
+ return at == ActionReopenIssue
+}
+
+func (at ActionType) IsActionClosePullRequest() bool {
+ return at == ActionClosePullRequest
+}
+
+func (at ActionType) IsActionReopenPullRequest() bool {
+ return at == ActionReopenPullRequest
+}
+
+func (at ActionType) IsActionDeleteTag() bool {
+ return at == ActionDeleteTag
+}
+
+func (at ActionType) IsActionDeleteBranch() bool {
+ return at == ActionDeleteBranch
+}
+
+func (at ActionType) IsActionMirrorSyncPush() bool {
+ return at == ActionMirrorSyncPush
+}
+
+func (at ActionType) IsActionMirrorSyncCreate() bool {
+ return at == ActionMirrorSyncCreate
+}
+
+func (at ActionType) IsActionMirrorSyncDelete() bool {
+ return at == ActionMirrorSyncDelete
+}
+
+func (at ActionType) IsActionApprovePullRequest() bool {
+ return at == ActionApprovePullRequest
+}
+
+func (at ActionType) IsActionRejectPullRequest() bool {
+ return at == ActionRejectPullRequest
+}
+
+func (at ActionType) IsActionCommentPull() bool {
+ return at == ActionCommentPull
+}
+
+func (at ActionType) IsActionPublishRelease() bool {
+ return at == ActionPublishRelease
+}
+
+func (at ActionType) IsActionPullReviewDismissed() bool {
+ return at == ActionPullReviewDismissed
+}
+
+func (at ActionType) IsActionPullRequestReadyForReview() bool {
+ return at == ActionPullRequestReadyForReview
+}
+
+func (at ActionType) IsActionAutoMergePullRequest() bool {
+ return at == ActionAutoMergePullRequest
+}
+
+func (at ActionType) String() string {
+ switch at {
+ case ActionCreateRepo:
+ return "create_repo"
+ case ActionRenameRepo:
+ return "rename_repo"
+ case ActionStarRepo:
+ return "star_repo"
+ case ActionWatchRepo:
+ return "watch_repo"
+ case ActionCommitRepo:
+ return "commit_repo"
+ case ActionCreateIssue:
+ return "create_issue"
+ case ActionCreatePullRequest:
+ return "create_pull_request"
+ case ActionTransferRepo:
+ return "transfer_repo"
+ case ActionPushTag:
+ return "push_tag"
+ case ActionCommentIssue:
+ return "comment_issue"
+ case ActionMergePullRequest:
+ return "merge_pull_request"
+ case ActionCloseIssue:
+ return "close_issue"
+ case ActionReopenIssue:
+ return "reopen_issue"
+ case ActionClosePullRequest:
+ return "close_pull_request"
+ case ActionReopenPullRequest:
+ return "reopen_pull_request"
+ case ActionDeleteTag:
+ return "delete_tag"
+ case ActionDeleteBranch:
+ return "delete_branch"
+ case ActionMirrorSyncPush:
+ return "mirror_sync_push"
+ case ActionMirrorSyncCreate:
+ return "mirror_sync_create"
+ case ActionMirrorSyncDelete:
+ return "mirror_sync_delete"
+ case ActionApprovePullRequest:
+ return "approve_pull_request"
+ case ActionRejectPullRequest:
+ return "reject_pull_request"
+ case ActionCommentPull:
+ return "comment_pull"
+ case ActionPublishRelease:
+ return "publish_release"
+ case ActionPullReviewDismissed:
+ return "pull_review_dismissed"
+ case ActionPullRequestReadyForReview:
+ return "pull_request_ready_for_review"
+ case ActionAutoMergePullRequest:
+ return "auto_merge_pull_request"
+ default:
+ return "action-" + strconv.Itoa(int(at))
+ }
+}
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index bf697634741ad..9e47867d97c16 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -11,75 +11,75 @@
{{else}}
{{.ShortActUserName}}
{{end}}
- {{if eq .GetOpType 1}}
+ {{if .GetOpType.IsActionCreateRepo}}
{{$.locale.Tr "action.create_repo" (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 2}}
+ {{else if .GetOpType.IsActionRenameRepo}}
{{$.locale.Tr "action.rename_repo" (.GetContent|Escape) (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 5}}
+ {{else if .GetOpType.IsActionCommitRepo}}
{{if .Content}}
{{$.locale.Tr "action.commit_repo" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{else}}
{{$.locale.Tr "action.create_branch" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{end}}
- {{else if eq .GetOpType 6}}
+ {{else if .GetOpType.IsActionCreateIssue}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.create_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 7}}
+ {{else if .GetOpType.IsActionCreatePullRequest}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.create_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 8}}
+ {{else if .GetOpType.IsActionTransferRepo}}
{{$.locale.Tr "action.transfer_repo" .GetContent (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 9}}
+ {{else if .GetOpType.IsActionTransferRepo}}
{{$.locale.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 10}}
+ {{else if .GetOpType.IsActionCommentIssue}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.comment_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 11}}
+ {{else if .GetOpType.IsActionMergePullRequest}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.merge_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 12}}
+ {{else if .GetOpType.IsActionCloseIssue}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.close_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 13}}
+ {{else if .GetOpType.IsActionReopenIssue}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.reopen_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 14}}
+ {{else if .GetOpType.IsActionClosePullRequest}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.close_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 15}}
+ {{else if .GetOpType.IsActionReopenPullRequest}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.reopen_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 16}}
+ {{else if .GetOpType.IsActionDeleteTag}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.delete_tag" (.GetRepoLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 17}}
+ {{else if .GetOpType.IsActionDeleteBranch}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.delete_branch" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 18}}
+ {{else if .GetOpType.IsActionMirrorSyncPush}}
{{$.locale.Tr "action.mirror_sync_push" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 19}}
+ {{else if .GetOpType.IsActionMirrorSyncCreate}}
{{$.locale.Tr "action.mirror_sync_create" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 20}}
+ {{else if .GetOpType.IsActionMirrorSyncDelete}}
{{$.locale.Tr "action.mirror_sync_delete" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 21}}
+ {{else if .GetOpType.IsActionApprovePullRequest}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.approve_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 22}}
+ {{else if .GetOpType.IsActionRejectPullRequest}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.reject_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 23}}
+ {{else if .GetOpType.IsActionCommentPull}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.comment_pull" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 24}}
+ {{else if .GetOpType.IsActionPublishRelease}}
{{$linkText := .Content | RenderEmoji $.Context}}
{{$.locale.Tr "action.publish_release" (.GetRepoLink|Escape) ((printf "%s/releases/tag/%s" .GetRepoLink .GetTag)|Escape) (.ShortRepoPath|Escape) $linkText | Str2html}}
- {{else if eq .GetOpType 25}}
+ {{else if .GetOpType.IsActionPullReviewDismissed}}
{{$index := index .GetIssueInfos 0}}
{{$reviewer := index .GetIssueInfos 1}}
{{$.locale.Tr "action.review_dismissed" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) $reviewer | Str2html}}
{{end}}
- {{if or (eq .GetOpType 5) (eq .GetOpType 18)}}
+ {{if or .GetOpType.IsActionCommitRepo .GetOpType.IsActionMirrorSyncPush}}
{{$push := ActionContent2Commits .}}
{{$repoLink := .GetRepoLink}}
{{range $push.Commits}}
@@ -95,21 +95,21 @@
{{if and (gt $push.Len 1) $push.CompareURL}}
{{$.locale.Tr "action.compare_commits" $push.Len}} »
{{end}}
- {{else if eq .GetOpType 6}}
+ {{else if .GetOpType.IsActionCreateIssue}}
{{index .GetIssueInfos 1 | RenderEmoji $.Context | RenderCodeBlock}}
- {{else if eq .GetOpType 7}}
+ {{else if .GetOpType.IsActionCreatePullRequest}}
{{index .GetIssueInfos 1 | RenderEmoji $.Context | RenderCodeBlock}}
- {{else if or (eq .GetOpType 10) (eq .GetOpType 21) (eq .GetOpType 22) (eq .GetOpType 23)}}
+ {{else if or .GetOpType.IsActionCommentIssue .GetOpType.IsActionApprovePullRequest .GetOpType.IsActionRejectPullRequest .GetOpType.IsActionCommentPull}}
{{.GetIssueTitle | RenderEmoji $.Context | RenderCodeBlock}}
{{$comment := index .GetIssueInfos 1}}
{{if gt (len $comment) 0}}
{{$comment | RenderEmoji $.Context | RenderCodeBlock}}
{{end}}
- {{else if eq .GetOpType 11}}
+ {{else if .GetOpType.IsActionMergePullRequest}}
{{index .GetIssueInfos 1}}
- {{else if or (eq .GetOpType 12) (eq .GetOpType 13) (eq .GetOpType 14) (eq .GetOpType 15)}}
+ {{else if or .GetOpType.IsActionCloseIssue .GetOpType.IsActionReopenIssue .GetOpType.IsActionClosePullRequest .GetOpType.IsActionReopenPullRequest}}
{{.GetIssueTitle | RenderEmoji $.Context | RenderCodeBlock}}
- {{else if eq .GetOpType 25}}
+ {{else if .GetOpType.IsActionPullReviewDismissed}}
{{$.locale.Tr "action.review_dismissed_reason"}}
{{index .GetIssueInfos 2 | RenderEmoji $.Context}}
{{end}}
From 4a7953c0eed43254e1291b96ad62f73e1bdb4217 Mon Sep 17 00:00:00 2001
From: caicandong <1290147055@qq.com>
Date: Thu, 7 Sep 2023 15:17:10 +0800
Subject: [PATCH 2/3] Revert "Refactor dashboard/feed.tmpl"
This reverts commit 4b3c92206cee50802561ae9abb04880ff3beec03.
---
models/activities/action.go | 95 +++++++++++++
models/activities/action_type.go | 209 ----------------------------
templates/user/dashboard/feeds.tmpl | 60 ++++----
3 files changed, 125 insertions(+), 239 deletions(-)
delete mode 100644 models/activities/action_type.go
diff --git a/models/activities/action.go b/models/activities/action.go
index 953d1e8c01aee..432bf8bf3fec0 100644
--- a/models/activities/action.go
+++ b/models/activities/action.go
@@ -31,6 +31,101 @@ import (
"xorm.io/xorm/schemas"
)
+// ActionType represents the type of an action.
+type ActionType int
+
+// Possible action types.
+const (
+ ActionCreateRepo ActionType = iota + 1 // 1
+ ActionRenameRepo // 2
+ ActionStarRepo // 3
+ ActionWatchRepo // 4
+ ActionCommitRepo // 5
+ ActionCreateIssue // 6
+ ActionCreatePullRequest // 7
+ ActionTransferRepo // 8
+ ActionPushTag // 9
+ ActionCommentIssue // 10
+ ActionMergePullRequest // 11
+ ActionCloseIssue // 12
+ ActionReopenIssue // 13
+ ActionClosePullRequest // 14
+ ActionReopenPullRequest // 15
+ ActionDeleteTag // 16
+ ActionDeleteBranch // 17
+ ActionMirrorSyncPush // 18
+ ActionMirrorSyncCreate // 19
+ ActionMirrorSyncDelete // 20
+ ActionApprovePullRequest // 21
+ ActionRejectPullRequest // 22
+ ActionCommentPull // 23
+ ActionPublishRelease // 24
+ ActionPullReviewDismissed // 25
+ ActionPullRequestReadyForReview // 26
+ ActionAutoMergePullRequest // 27
+)
+
+func (at ActionType) String() string {
+ switch at {
+ case ActionCreateRepo:
+ return "create_repo"
+ case ActionRenameRepo:
+ return "rename_repo"
+ case ActionStarRepo:
+ return "star_repo"
+ case ActionWatchRepo:
+ return "watch_repo"
+ case ActionCommitRepo:
+ return "commit_repo"
+ case ActionCreateIssue:
+ return "create_issue"
+ case ActionCreatePullRequest:
+ return "create_pull_request"
+ case ActionTransferRepo:
+ return "transfer_repo"
+ case ActionPushTag:
+ return "push_tag"
+ case ActionCommentIssue:
+ return "comment_issue"
+ case ActionMergePullRequest:
+ return "merge_pull_request"
+ case ActionCloseIssue:
+ return "close_issue"
+ case ActionReopenIssue:
+ return "reopen_issue"
+ case ActionClosePullRequest:
+ return "close_pull_request"
+ case ActionReopenPullRequest:
+ return "reopen_pull_request"
+ case ActionDeleteTag:
+ return "delete_tag"
+ case ActionDeleteBranch:
+ return "delete_branch"
+ case ActionMirrorSyncPush:
+ return "mirror_sync_push"
+ case ActionMirrorSyncCreate:
+ return "mirror_sync_create"
+ case ActionMirrorSyncDelete:
+ return "mirror_sync_delete"
+ case ActionApprovePullRequest:
+ return "approve_pull_request"
+ case ActionRejectPullRequest:
+ return "reject_pull_request"
+ case ActionCommentPull:
+ return "comment_pull"
+ case ActionPublishRelease:
+ return "publish_release"
+ case ActionPullReviewDismissed:
+ return "pull_review_dismissed"
+ case ActionPullRequestReadyForReview:
+ return "pull_request_ready_for_review"
+ case ActionAutoMergePullRequest:
+ return "auto_merge_pull_request"
+ default:
+ return "action-" + strconv.Itoa(int(at))
+ }
+}
+
// Action represents user operation type and other information to
// repository. It implemented interface base.Actioner so that can be
// used in template render.
diff --git a/models/activities/action_type.go b/models/activities/action_type.go
deleted file mode 100644
index 66ba6db5c60cb..0000000000000
--- a/models/activities/action_type.go
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright 2023 The Gitea Authors. All rights reserved.
-// SPDX-License-Identifier: MIT
-
-package activities
-
-import "strconv"
-
-// ActionType represents the type of an action.
-type ActionType int
-
-// Possible action types.
-const (
- ActionCreateRepo ActionType = iota + 1 // 1
- ActionRenameRepo // 2
- ActionStarRepo // 3
- ActionWatchRepo // 4
- ActionCommitRepo // 5
- ActionCreateIssue // 6
- ActionCreatePullRequest // 7
- ActionTransferRepo // 8
- ActionPushTag // 9
- ActionCommentIssue // 10
- ActionMergePullRequest // 11
- ActionCloseIssue // 12
- ActionReopenIssue // 13
- ActionClosePullRequest // 14
- ActionReopenPullRequest // 15
- ActionDeleteTag // 16
- ActionDeleteBranch // 17
- ActionMirrorSyncPush // 18
- ActionMirrorSyncCreate // 19
- ActionMirrorSyncDelete // 20
- ActionApprovePullRequest // 21
- ActionRejectPullRequest // 22
- ActionCommentPull // 23
- ActionPublishRelease // 24
- ActionPullReviewDismissed // 25
- ActionPullRequestReadyForReview // 26
- ActionAutoMergePullRequest // 27
-)
-
-func (at ActionType) IsActionCreateRepo() bool {
- return at == ActionCreateRepo
-}
-
-func (at ActionType) IsActionRenameRepo() bool {
- return at == ActionRenameRepo
-}
-
-func (at ActionType) IsActionStarRepo() bool {
- return at == ActionStarRepo
-}
-
-func (at ActionType) IsActionWatchRepo() bool {
- return at == ActionWatchRepo
-}
-
-func (at ActionType) IsActionCommitRepo() bool {
- return at == ActionCommitRepo
-}
-
-func (at ActionType) IsActionCreateIssue() bool {
- return at == ActionCreateIssue
-}
-
-func (at ActionType) IsActionCreatePullRequest() bool {
- return at == ActionCreatePullRequest
-}
-
-func (at ActionType) IsActionTransferRepo() bool {
- return at == ActionTransferRepo
-}
-
-func (at ActionType) IsActionPushTag() bool {
- return at == ActionPushTag
-}
-
-func (at ActionType) IsActionCommentIssue() bool {
- return at == ActionCommentIssue
-}
-
-func (at ActionType) IsActionMergePullRequest() bool {
- return at == ActionMergePullRequest
-}
-
-func (at ActionType) IsActionCloseIssue() bool {
- return at == ActionCloseIssue
-}
-
-func (at ActionType) IsActionReopenIssue() bool {
- return at == ActionReopenIssue
-}
-
-func (at ActionType) IsActionClosePullRequest() bool {
- return at == ActionClosePullRequest
-}
-
-func (at ActionType) IsActionReopenPullRequest() bool {
- return at == ActionReopenPullRequest
-}
-
-func (at ActionType) IsActionDeleteTag() bool {
- return at == ActionDeleteTag
-}
-
-func (at ActionType) IsActionDeleteBranch() bool {
- return at == ActionDeleteBranch
-}
-
-func (at ActionType) IsActionMirrorSyncPush() bool {
- return at == ActionMirrorSyncPush
-}
-
-func (at ActionType) IsActionMirrorSyncCreate() bool {
- return at == ActionMirrorSyncCreate
-}
-
-func (at ActionType) IsActionMirrorSyncDelete() bool {
- return at == ActionMirrorSyncDelete
-}
-
-func (at ActionType) IsActionApprovePullRequest() bool {
- return at == ActionApprovePullRequest
-}
-
-func (at ActionType) IsActionRejectPullRequest() bool {
- return at == ActionRejectPullRequest
-}
-
-func (at ActionType) IsActionCommentPull() bool {
- return at == ActionCommentPull
-}
-
-func (at ActionType) IsActionPublishRelease() bool {
- return at == ActionPublishRelease
-}
-
-func (at ActionType) IsActionPullReviewDismissed() bool {
- return at == ActionPullReviewDismissed
-}
-
-func (at ActionType) IsActionPullRequestReadyForReview() bool {
- return at == ActionPullRequestReadyForReview
-}
-
-func (at ActionType) IsActionAutoMergePullRequest() bool {
- return at == ActionAutoMergePullRequest
-}
-
-func (at ActionType) String() string {
- switch at {
- case ActionCreateRepo:
- return "create_repo"
- case ActionRenameRepo:
- return "rename_repo"
- case ActionStarRepo:
- return "star_repo"
- case ActionWatchRepo:
- return "watch_repo"
- case ActionCommitRepo:
- return "commit_repo"
- case ActionCreateIssue:
- return "create_issue"
- case ActionCreatePullRequest:
- return "create_pull_request"
- case ActionTransferRepo:
- return "transfer_repo"
- case ActionPushTag:
- return "push_tag"
- case ActionCommentIssue:
- return "comment_issue"
- case ActionMergePullRequest:
- return "merge_pull_request"
- case ActionCloseIssue:
- return "close_issue"
- case ActionReopenIssue:
- return "reopen_issue"
- case ActionClosePullRequest:
- return "close_pull_request"
- case ActionReopenPullRequest:
- return "reopen_pull_request"
- case ActionDeleteTag:
- return "delete_tag"
- case ActionDeleteBranch:
- return "delete_branch"
- case ActionMirrorSyncPush:
- return "mirror_sync_push"
- case ActionMirrorSyncCreate:
- return "mirror_sync_create"
- case ActionMirrorSyncDelete:
- return "mirror_sync_delete"
- case ActionApprovePullRequest:
- return "approve_pull_request"
- case ActionRejectPullRequest:
- return "reject_pull_request"
- case ActionCommentPull:
- return "comment_pull"
- case ActionPublishRelease:
- return "publish_release"
- case ActionPullReviewDismissed:
- return "pull_review_dismissed"
- case ActionPullRequestReadyForReview:
- return "pull_request_ready_for_review"
- case ActionAutoMergePullRequest:
- return "auto_merge_pull_request"
- default:
- return "action-" + strconv.Itoa(int(at))
- }
-}
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index 9e47867d97c16..bf697634741ad 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -11,75 +11,75 @@
{{else}}
{{.ShortActUserName}}
{{end}}
- {{if .GetOpType.IsActionCreateRepo}}
+ {{if eq .GetOpType 1}}
{{$.locale.Tr "action.create_repo" (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionRenameRepo}}
+ {{else if eq .GetOpType 2}}
{{$.locale.Tr "action.rename_repo" (.GetContent|Escape) (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionCommitRepo}}
+ {{else if eq .GetOpType 5}}
{{if .Content}}
{{$.locale.Tr "action.commit_repo" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{else}}
{{$.locale.Tr "action.create_branch" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{end}}
- {{else if .GetOpType.IsActionCreateIssue}}
+ {{else if eq .GetOpType 6}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.create_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionCreatePullRequest}}
+ {{else if eq .GetOpType 7}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.create_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionTransferRepo}}
+ {{else if eq .GetOpType 8}}
{{$.locale.Tr "action.transfer_repo" .GetContent (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionTransferRepo}}
+ {{else if eq .GetOpType 9}}
{{$.locale.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionCommentIssue}}
+ {{else if eq .GetOpType 10}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.comment_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionMergePullRequest}}
+ {{else if eq .GetOpType 11}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.merge_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionCloseIssue}}
+ {{else if eq .GetOpType 12}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.close_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionReopenIssue}}
+ {{else if eq .GetOpType 13}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.reopen_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionClosePullRequest}}
+ {{else if eq .GetOpType 14}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.close_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionReopenPullRequest}}
+ {{else if eq .GetOpType 15}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.reopen_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionDeleteTag}}
+ {{else if eq .GetOpType 16}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.delete_tag" (.GetRepoLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionDeleteBranch}}
+ {{else if eq .GetOpType 17}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.delete_branch" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionMirrorSyncPush}}
+ {{else if eq .GetOpType 18}}
{{$.locale.Tr "action.mirror_sync_push" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionMirrorSyncCreate}}
+ {{else if eq .GetOpType 19}}
{{$.locale.Tr "action.mirror_sync_create" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionMirrorSyncDelete}}
+ {{else if eq .GetOpType 20}}
{{$.locale.Tr "action.mirror_sync_delete" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionApprovePullRequest}}
+ {{else if eq .GetOpType 21}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.approve_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionRejectPullRequest}}
+ {{else if eq .GetOpType 22}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.reject_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionCommentPull}}
+ {{else if eq .GetOpType 23}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.comment_pull" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if .GetOpType.IsActionPublishRelease}}
+ {{else if eq .GetOpType 24}}
{{$linkText := .Content | RenderEmoji $.Context}}
{{$.locale.Tr "action.publish_release" (.GetRepoLink|Escape) ((printf "%s/releases/tag/%s" .GetRepoLink .GetTag)|Escape) (.ShortRepoPath|Escape) $linkText | Str2html}}
- {{else if .GetOpType.IsActionPullReviewDismissed}}
+ {{else if eq .GetOpType 25}}
{{$index := index .GetIssueInfos 0}}
{{$reviewer := index .GetIssueInfos 1}}
{{$.locale.Tr "action.review_dismissed" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) $reviewer | Str2html}}
{{end}}
- {{if or .GetOpType.IsActionCommitRepo .GetOpType.IsActionMirrorSyncPush}}
+ {{if or (eq .GetOpType 5) (eq .GetOpType 18)}}
{{$push := ActionContent2Commits .}}
{{$repoLink := .GetRepoLink}}
{{range $push.Commits}}
@@ -95,21 +95,21 @@
{{if and (gt $push.Len 1) $push.CompareURL}}
{{$.locale.Tr "action.compare_commits" $push.Len}} »
{{end}}
- {{else if .GetOpType.IsActionCreateIssue}}
+ {{else if eq .GetOpType 6}}
{{index .GetIssueInfos 1 | RenderEmoji $.Context | RenderCodeBlock}}
- {{else if .GetOpType.IsActionCreatePullRequest}}
+ {{else if eq .GetOpType 7}}
{{index .GetIssueInfos 1 | RenderEmoji $.Context | RenderCodeBlock}}
- {{else if or .GetOpType.IsActionCommentIssue .GetOpType.IsActionApprovePullRequest .GetOpType.IsActionRejectPullRequest .GetOpType.IsActionCommentPull}}
+ {{else if or (eq .GetOpType 10) (eq .GetOpType 21) (eq .GetOpType 22) (eq .GetOpType 23)}}
{{.GetIssueTitle | RenderEmoji $.Context | RenderCodeBlock}}
{{$comment := index .GetIssueInfos 1}}
{{if gt (len $comment) 0}}
{{$comment | RenderEmoji $.Context | RenderCodeBlock}}
{{end}}
- {{else if .GetOpType.IsActionMergePullRequest}}
+ {{else if eq .GetOpType 11}}
{{index .GetIssueInfos 1}}
- {{else if or .GetOpType.IsActionCloseIssue .GetOpType.IsActionReopenIssue .GetOpType.IsActionClosePullRequest .GetOpType.IsActionReopenPullRequest}}
+ {{else if or (eq .GetOpType 12) (eq .GetOpType 13) (eq .GetOpType 14) (eq .GetOpType 15)}}
{{.GetIssueTitle | RenderEmoji $.Context | RenderCodeBlock}}
- {{else if .GetOpType.IsActionPullReviewDismissed}}
+ {{else if eq .GetOpType 25}}
{{$.locale.Tr "action.review_dismissed_reason"}}
{{index .GetIssueInfos 2 | RenderEmoji $.Context}}
{{end}}
From 17fea1955c935800306ad6b6b177a4c7757a2218 Mon Sep 17 00:00:00 2001
From: caicandong <1290147055@qq.com>
Date: Thu, 7 Sep 2023 15:46:13 +0800
Subject: [PATCH 3/3] refactor
---
models/activities/action.go | 9 +++++
templates/user/dashboard/feeds.tmpl | 60 ++++++++++++++---------------
2 files changed, 39 insertions(+), 30 deletions(-)
diff --git a/models/activities/action.go b/models/activities/action.go
index 432bf8bf3fec0..07c8053425602 100644
--- a/models/activities/action.go
+++ b/models/activities/action.go
@@ -126,6 +126,15 @@ func (at ActionType) String() string {
}
}
+func (at ActionType) InActions(actions ...string) bool {
+ for _, action := range actions {
+ if action == at.String() {
+ return true
+ }
+ }
+ return false
+}
+
// Action represents user operation type and other information to
// repository. It implemented interface base.Actioner so that can be
// used in template render.
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index bf697634741ad..1c5a5f3237774 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -11,75 +11,75 @@
{{else}}
{{.ShortActUserName}}
{{end}}
- {{if eq .GetOpType 1}}
+ {{if .GetOpType.InActions "create_repo"}}
{{$.locale.Tr "action.create_repo" (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 2}}
+ {{else if .GetOpType.InActions "rename_repo"}}
{{$.locale.Tr "action.rename_repo" (.GetContent|Escape) (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 5}}
+ {{else if .GetOpType.InActions "commit_repo"}}
{{if .Content}}
{{$.locale.Tr "action.commit_repo" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{else}}
{{$.locale.Tr "action.create_branch" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}}
{{end}}
- {{else if eq .GetOpType 6}}
+ {{else if .GetOpType.InActions "create_issue"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.create_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 7}}
+ {{else if .GetOpType.InActions "create_pull_request"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.create_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 8}}
+ {{else if .GetOpType.InActions "transfer_repo"}}
{{$.locale.Tr "action.transfer_repo" .GetContent (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 9}}
+ {{else if .GetOpType.InActions "push_tag"}}
{{$.locale.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 10}}
+ {{else if .GetOpType.InActions "comment_issue"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.comment_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 11}}
+ {{else if .GetOpType.InActions "merge_pull_request"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.merge_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 12}}
+ {{else if .GetOpType.InActions "close_issue"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.close_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 13}}
+ {{else if .GetOpType.InActions "reopen_issue"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.reopen_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 14}}
+ {{else if .GetOpType.InActions "close_pull_request"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.close_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 15}}
+ {{else if .GetOpType.InActions "reopen_pull_request"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.reopen_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 16}}
+ {{else if .GetOpType.InActions "delete_tag"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.delete_tag" (.GetRepoLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 17}}
+ {{else if .GetOpType.InActions "delete_branch"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.delete_branch" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 18}}
+ {{else if .GetOpType.InActions "mirror_sync_push"}}
{{$.locale.Tr "action.mirror_sync_push" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 19}}
+ {{else if .GetOpType.InActions "mirror_sync_create"}}
{{$.locale.Tr "action.mirror_sync_create" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 20}}
+ {{else if .GetOpType.InActions "mirror_sync_delete"}}
{{$.locale.Tr "action.mirror_sync_delete" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 21}}
+ {{else if .GetOpType.InActions "approve_pull_request"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.approve_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 22}}
+ {{else if .GetOpType.InActions "reject_pull_request"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.reject_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 23}}
+ {{else if .GetOpType.InActions "comment_pull"}}
{{$index := index .GetIssueInfos 0}}
{{$.locale.Tr "action.comment_pull" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}}
- {{else if eq .GetOpType 24}}
+ {{else if .GetOpType.InActions "publish_release"}}
{{$linkText := .Content | RenderEmoji $.Context}}
{{$.locale.Tr "action.publish_release" (.GetRepoLink|Escape) ((printf "%s/releases/tag/%s" .GetRepoLink .GetTag)|Escape) (.ShortRepoPath|Escape) $linkText | Str2html}}
- {{else if eq .GetOpType 25}}
+ {{else if .GetOpType.InActions "review_dismissed"}}
{{$index := index .GetIssueInfos 0}}
{{$reviewer := index .GetIssueInfos 1}}
{{$.locale.Tr "action.review_dismissed" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) $reviewer | Str2html}}
{{end}}
- {{if or (eq .GetOpType 5) (eq .GetOpType 18)}}
+ {{if .GetOpType.InActions "commit_repo" "mirror_sync_push"}}
{{$push := ActionContent2Commits .}}
{{$repoLink := .GetRepoLink}}
{{range $push.Commits}}
@@ -95,21 +95,21 @@
{{if and (gt $push.Len 1) $push.CompareURL}}
{{$.locale.Tr "action.compare_commits" $push.Len}} »
{{end}}
- {{else if eq .GetOpType 6}}
+ {{else if .GetOpType.InActions "create_issue"}}
{{index .GetIssueInfos 1 | RenderEmoji $.Context | RenderCodeBlock}}
- {{else if eq .GetOpType 7}}
+ {{else if .GetOpType.InActions "create_pull_request"}}
{{index .GetIssueInfos 1 | RenderEmoji $.Context | RenderCodeBlock}}
- {{else if or (eq .GetOpType 10) (eq .GetOpType 21) (eq .GetOpType 22) (eq .GetOpType 23)}}
+ {{else if .GetOpType.InActions "comment_issue" "approve_pull_request" "reject_pull_request" "comment_pull"}}
{{.GetIssueTitle | RenderEmoji $.Context | RenderCodeBlock}}
{{$comment := index .GetIssueInfos 1}}
{{if gt (len $comment) 0}}
{{$comment | RenderEmoji $.Context | RenderCodeBlock}}
{{end}}
- {{else if eq .GetOpType 11}}
+ {{else if .GetOpType.InActions "merge_pull_request"}}
{{index .GetIssueInfos 1}}
- {{else if or (eq .GetOpType 12) (eq .GetOpType 13) (eq .GetOpType 14) (eq .GetOpType 15)}}
+ {{else if .GetOpType.InActions "close_issue" "reopen_issue" "close_pull_request" "reopen_pull_request"}}
{{.GetIssueTitle | RenderEmoji $.Context | RenderCodeBlock}}
- {{else if eq .GetOpType 25}}
+ {{else if .GetOpType.InActions "pull_review_dismissed"}}
{{$.locale.Tr "action.review_dismissed_reason"}}
{{index .GetIssueInfos 2 | RenderEmoji $.Context}}
{{end}}