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