diff --git a/models/action.go b/models/action.go index 8793a4a24d3..e6873362298 100644 --- a/models/action.go +++ b/models/action.go @@ -98,9 +98,8 @@ func (a *Action) AfterSet(colName string, _ xorm.Cell) { } // GetOpType gets the ActionType of this action. -// TODO: change return type to ActionType ? -func (a *Action) GetOpType() int { - return int(a.OpType) +func (a *Action) GetOpType() ActionType { + return a.OpType } func (a *Action) loadActUser() { diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 181d3ff159f..e9613b54451 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -277,7 +277,7 @@ func RenderCommitMessage(full bool, msg, urlPrefix string, metas map[string]stri // Actioner describes an action type Actioner interface { - GetOpType() int + GetOpType() models.ActionType GetActUserName() string GetRepoUserName() string GetRepoName() string @@ -289,25 +289,24 @@ type Actioner interface { GetIssueInfos() []string } -// ActionIcon accepts a int that represents action operation type -// and returns a icon class name. -func ActionIcon(opType int) string { +// ActionIcon accepts an action operation type and returns an icon class name. +func ActionIcon(opType models.ActionType) string { switch opType { - case 1, 8: // Create and transfer repository + case models.ActionCreateRepo, models.ActionTransferRepo: return "repo" - case 5, 9: // Commit repository + case models.ActionCommitRepo, models.ActionPushTag: return "git-commit" - case 6: // Create issue + case models.ActionCreateIssue: return "issue-opened" - case 7: // New pull request + case models.ActionCreatePullRequest: return "git-pull-request" - case 10: // Comment issue + case models.ActionCommentIssue: return "comment-discussion" - case 11: // Merge pull request + case models.ActionMergePullRequest: return "git-merge" - case 12, 14: // Close issue or pull request + case models.ActionCloseIssue, models.ActionClosePullRequest: return "issue-closed" - case 13, 15: // Reopen issue or pull request + case models.ActionReopenIssue, models.ActionReopenPullRequest: return "issue-reopened" default: return "invalid type"