Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ DEFAULT_SHOW_FULL_NAME = false
SEARCH_REPO_DESCRIPTION = true
; Whether to enable a Service Worker to cache frontend assets
USE_SERVICE_WORKER = true
; show `system administrator` tag on comment header
SHOW_SYS_ADMIN_COMMENT_TAG = true

[ui.admin]
; Number of users that are displayed on one page
Expand Down
1 change: 1 addition & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
- `USE_SERVICE_WORKER`: **true**: Whether to enable a Service Worker to cache frontend assets.
- `SHOW_SYS_ADMIN_COMMENT_TAG`: **false**: show `system administrator` tag on comment header

### UI - Admin (`ui.admin`)

Expand Down
1 change: 1 addition & 0 deletions docs/content/doc/advanced/config-cheat-sheet.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ menu:
- `ISSUE_PAGING_NUM`: 工单页面每页显示的工单数量。
- `MEMBERS_PAGING_NUM`: **20**: 组织成员页面每页显示的成员数量。
- `FEED_MAX_COMMIT_NUM`: 活动流页面显示的最大提交数量。
- `SHOW_SYS_ADMIN_COMMENT_TAG`: **false**: 在系统管理员的评论上显示 `系统管理员` 标志

### UI - Admin (`ui.admin`)

Expand Down
1 change: 1 addition & 0 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const (
CommentTagPoster
CommentTagWriter
CommentTagOwner
CommentTagSysAdmin
)

// Comment represents a comment in commit and issue page.
Expand Down
21 changes: 21 additions & 0 deletions models/repo_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,27 @@ func getUserRepoPermission(e Engine, repo *Repository, user *User) (perm Permiss
return
}

// IsUserRealRepoAdmin check if this user is real repo admin
func IsUserRealRepoAdmin(repo *Repository, user *User) (bool, error) {
if repo.OwnerID == user.ID {
return true, nil
}

sess := x.NewSession()
defer sess.Close()

if err := repo.getOwner(sess); err != nil {
return false, err
}

accessMode, err := accessLevel(sess, user, repo)
if err != nil {
return false, err
}

return accessMode >= AccessModeAdmin, nil
}

// IsUserRepoAdmin return true if user has admin right of a repo
func IsUserRepoAdmin(repo *Repository, user *User) (bool, error) {
return isUserRepoAdmin(x, repo, user)
Expand Down
40 changes: 21 additions & 19 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,26 @@ var (

// UI settings
UI = struct {
ExplorePagingNum int
IssuePagingNum int
RepoSearchPagingNum int
MembersPagingNum int
FeedMaxCommitNum int
FeedPagingNum int
GraphMaxCommitNum int
CodeCommentLines int
ReactionMaxUserNum int
ThemeColorMetaTag string
MaxDisplayFileSize int64
ShowUserEmail bool
DefaultShowFullName bool
DefaultTheme string
Themes []string
Reactions []string
ReactionsMap map[string]bool
SearchRepoDescription bool
UseServiceWorker bool
ExplorePagingNum int
IssuePagingNum int
RepoSearchPagingNum int
MembersPagingNum int
FeedMaxCommitNum int
FeedPagingNum int
GraphMaxCommitNum int
CodeCommentLines int
ReactionMaxUserNum int
ThemeColorMetaTag string
MaxDisplayFileSize int64
ShowUserEmail bool
DefaultShowFullName bool
DefaultTheme string
Themes []string
Reactions []string
ReactionsMap map[string]bool
SearchRepoDescription bool
UseServiceWorker bool
ShowSysAdminCommentTag bool

Notification struct {
MinTimeout time.Duration
Expand Down Expand Up @@ -907,6 +908,7 @@ func NewContext() {
UI.DefaultShowFullName = Cfg.Section("ui").Key("DEFAULT_SHOW_FULL_NAME").MustBool(false)
UI.SearchRepoDescription = Cfg.Section("ui").Key("SEARCH_REPO_DESCRIPTION").MustBool(true)
UI.UseServiceWorker = Cfg.Section("ui").Key("USE_SERVICE_WORKER").MustBool(true)
UI.ShowSysAdminCommentTag = Cfg.Section("ui").Key("SHOW_SYS_ADMIN_COMMENT_TAG").MustBool(false)

HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))

Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ issues.ref_from = `from %[1]s`
issues.poster = Poster
issues.collaborator = Collaborator
issues.owner = Owner
issues.sys_admin = system administrator
issues.re_request_review=Re-request review
issues.is_stale = There have been changes to this PR since this review
issues.remove_request_review=Remove review request
Expand Down
19 changes: 17 additions & 2 deletions routers/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,23 @@ func commentTag(repo *models.Repository, poster *models.User, issue *models.Issu
return models.CommentTagNone, err
}
if perm.IsOwner() {
return models.CommentTagOwner, nil
} else if perm.CanWrite(models.UnitTypeCode) {
ok, err := models.IsUserRealRepoAdmin(repo, poster)
if err != nil {
return models.CommentTagNone, err
}

if ok {
return models.CommentTagOwner, nil
}

if setting.UI.ShowSysAdminCommentTag && poster.IsAdmin {
return models.CommentTagSysAdmin, nil
}

return models.CommentTagNone, nil
}

if perm.CanWrite(models.UnitTypeCode) {
return models.CommentTagWriter, nil
}

Expand Down
2 changes: 2 additions & 0 deletions templates/repo/issue/view_content.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
{{$.i18n.Tr "repo.issues.collaborator"}}
{{else if eq .Issue.ShowTag 3}}
{{$.i18n.Tr "repo.issues.owner"}}
{{else if eq .Issue.ShowTag 4}}
{{$.i18n.Tr "repo.issues.sys_admin"}}
{{end}}
</div>
{{end}}
Expand Down
2 changes: 2 additions & 0 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
{{$.i18n.Tr "repo.issues.collaborator"}}
{{else if eq .ShowTag 3}}
{{$.i18n.Tr "repo.issues.owner"}}
{{else if eq .ShowTag 4}}
{{$.i18n.Tr "repo.issues.sys_admin"}}
{{end}}
</div>
{{end}}
Expand Down