diff --git a/models/issue_comment.go b/models/issue_comment.go index bf36881a0..34541dc3c 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -99,7 +99,7 @@ const ( // 28 merge pull request CommentTypeMergePull // 29 push to PR head branch - CommentTypePullPush + CommentTypePullRequestPush // 30 Project changed CommentTypeProject // 31 Project board changed @@ -725,7 +725,7 @@ func (c *Comment) CodeCommentURL() string { // LoadPushCommits Load push commits func (c *Comment) LoadPushCommits(ctx context.Context) (err error) { - if c.Content == "" || c.Commits != nil || c.Type != CommentTypePullPush { + if c.Content == "" || c.Commits != nil || c.Type != CommentTypePullRequestPush { return nil } @@ -1325,7 +1325,7 @@ func CreatePushPullComment(ctx context.Context, pusher *user_model.User, pr *Pul } ops := &CreateCommentOptions{ - Type: CommentTypePullPush, + Type: CommentTypePullRequestPush, Doer: pusher, Repo: pr.BaseRepo, } diff --git a/models/user/setting.go b/models/user/setting.go index 5ff18f826..fbb6fbab3 100644 --- a/models/user/setting.go +++ b/models/user/setting.go @@ -31,8 +31,8 @@ func init() { db.RegisterModel(new(Setting)) } -// GetSettings returns specific settings from user -func GetSettings(uid int64, keys []string) (map[string]*Setting, error) { +// GetUserSettings returns specific settings from user +func GetUserSettings(uid int64, keys []string) (map[string]*Setting, error) { settings := make([]*Setting, 0, len(keys)) if err := db.GetEngine(db.DefaultContext). Where("user_id=?", uid). @@ -62,21 +62,53 @@ func GetUserAllSettings(uid int64) (map[string]*Setting, error) { return settingsMap, nil } -// DeleteSetting deletes a specific setting for a user -func DeleteSetting(setting *Setting) error { - _, err := db.GetEngine(db.DefaultContext).Delete(setting) +func validateUserSettingKey(key string) error { + if len(key) == 0 { + return fmt.Errorf("setting key must be set") + } + if strings.ToLower(key) != key { + return fmt.Errorf("setting key should be lowercase") + } + return nil +} + +// GetUserSetting gets a specific setting for a user +func GetUserSetting(userID int64, key string, def ...string) (string, error) { + if err := validateUserSettingKey(key); err != nil { + return "", err + } + setting := &Setting{UserID: userID, SettingKey: key} + has, err := db.GetEngine(db.DefaultContext).Get(setting) + if err != nil { + return "", err + } + if !has { + if len(def) == 1 { + return def[0], nil + } + return "", nil + } + return setting.SettingValue, nil +} + +// DeleteUserSetting deletes a specific setting for a user +func DeleteUserSetting(userID int64, key string) error { + if err := validateUserSettingKey(key); err != nil { + return err + } + _, err := db.GetEngine(db.DefaultContext).Delete(&Setting{UserID: userID, SettingKey: key}) return err } -// SetSetting updates a users' setting for a specific key -func SetSetting(setting *Setting) error { - if strings.ToLower(setting.SettingKey) != setting.SettingKey { - return fmt.Errorf("setting key should be lowercase") +// SetUserSetting updates a users' setting for a specific key +func SetUserSetting(userID int64, key, value string) error { + if err := validateUserSettingKey(key); err != nil { + return err } - return upsertSettingValue(setting.UserID, setting.SettingKey, setting.SettingValue) + return upsertUserSettingValue(userID, key, value) } -func upsertSettingValue(userID int64, key, value string) error { +func upsertUserSettingValue(userID int64, key, value string) error { return db.WithTx(func(ctx context.Context) error { e := db.GetEngine(ctx) diff --git a/models/user/setting_keys.go b/models/user/setting_keys.go new file mode 100644 index 000000000..458b78e35 --- /dev/null +++ b/models/user/setting_keys.go @@ -0,0 +1,10 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package user + +const ( + // SettingsKeyHiddenCommentTypes is the settings key for hidden comment types + SettingsKeyHiddenCommentTypes = "issue.hidden_comment_types" +) diff --git a/models/user/setting_test.go b/models/user/setting_test.go index 81445a9f6..0b42e0fe2 100644 --- a/models/user/setting_test.go +++ b/models/user/setting_test.go @@ -19,21 +19,29 @@ func TestSettings(t *testing.T) { newSetting := &Setting{UserID: 99, SettingKey: keyName, SettingValue: "Gitea User Setting Test"} // create setting - err := SetSetting(newSetting) + err := SetUserSetting(newSetting.UserID, newSetting.SettingKey, newSetting.SettingValue) assert.NoError(t, err) // test about saving unchanged values - err = SetSetting(newSetting) + err = SetUserSetting(newSetting.UserID, newSetting.SettingKey, newSetting.SettingValue) assert.NoError(t, err) // get specific setting - settings, err := GetSettings(99, []string{keyName}) + settings, err := GetUserSettings(99, []string{keyName}) assert.NoError(t, err) assert.Len(t, settings, 1) assert.EqualValues(t, newSetting.SettingValue, settings[keyName].SettingValue) + settingValue, err := GetUserSetting(99, keyName) + assert.NoError(t, err) + assert.EqualValues(t, newSetting.SettingValue, settingValue) + + settingValue, err = GetUserSetting(99, "no_such") + assert.NoError(t, err) + assert.EqualValues(t, "", settingValue) + // updated setting updatedSetting := &Setting{UserID: 99, SettingKey: keyName, SettingValue: "Updated"} - err = SetSetting(updatedSetting) + err = SetUserSetting(updatedSetting.UserID, updatedSetting.SettingKey, updatedSetting.SettingValue) assert.NoError(t, err) // get all settings @@ -43,7 +51,7 @@ func TestSettings(t *testing.T) { assert.EqualValues(t, updatedSetting.SettingValue, settings[updatedSetting.SettingKey].SettingValue) // delete setting - err = DeleteSetting(&Setting{UserID: 99, SettingKey: keyName}) + err = DeleteUserSetting(99, keyName) assert.NoError(t, err) settings, err = GetUserAllSettings(99) assert.NoError(t, err) diff --git a/modules/context/form.go b/modules/context/form.go index 8d1859097..4f48d746b 100644 --- a/modules/context/form.go +++ b/modules/context/form.go @@ -46,9 +46,11 @@ func (ctx *Context) FormInt64(key string) int64 { return v } -// FormBool returns true if the value for the provided key in the form is "1" or "true" +// FormBool returns true if the value for the provided key in the form is "1", "true" or "on" func (ctx *Context) FormBool(key string) bool { - v, _ := strconv.ParseBool(ctx.Req.FormValue(key)) + s := ctx.Req.FormValue(key) + v, _ := strconv.ParseBool(s) + v = v || strings.EqualFold(s, "on") return v } @@ -59,6 +61,8 @@ func (ctx *Context) FormOptionalBool(key string) util.OptionalBool { if len(value) == 0 { return util.OptionalBoolNone } - v, _ := strconv.ParseBool(ctx.Req.FormValue(key)) + s := ctx.Req.FormValue(key) + v, _ := strconv.ParseBool(s) + v = v || strings.EqualFold(s, "on") return util.OptionalBoolOf(v) } diff --git a/modules/notification/mail/mail.go b/modules/notification/mail/mail.go index 94ee16ff8..21709d945 100644 --- a/modules/notification/mail/mail.go +++ b/modules/notification/mail/mail.go @@ -42,7 +42,7 @@ func (m *mailNotifier) NotifyCreateIssueComment(doer *user_model.User, repo *rep act = models.ActionCommentIssue } else if comment.Type == models.CommentTypeCode { act = models.ActionCommentIssue - } else if comment.Type == models.CommentTypePullPush { + } else if comment.Type == models.CommentTypePullRequestPush { act = 0 } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index d8398f6d9..301bd4f66 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -549,6 +549,22 @@ continue = Continue cancel = Cancel language = Language ui = Theme +hidden_comment_types = Hidden comment types +comment_type_group_reference = Reference +comment_type_group_label = Label +comment_type_group_milestone = Milestone +comment_type_group_assignee = Assignee +comment_type_group_title = Title +comment_type_group_branch = Branch +comment_type_group_time_tracking = Time Tracking +comment_type_group_deadline = Deadline +comment_type_group_dependency = Dependency +comment_type_group_lock = Lock Status +comment_type_group_review_request = Review request +comment_type_group_pull_request_push = Added commits +comment_type_group_project = Project +comment_type_group_issue_ref = Issue reference +saved_successfully = Your settings were saved successfully. privacy = Privacy keep_activity_private = Hide the activity from the profile page keep_activity_private_popup = Makes the activity visible only for you and the admins diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index aff5fa849..4f2716763 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -10,6 +10,7 @@ import ( "errors" "fmt" "io" + "math/big" "net/http" "net/url" "path" @@ -1465,7 +1466,7 @@ func ViewIssue(ctx *context.Context) { ctx.ServerError("LoadResolveDoer", err) return } - } else if comment.Type == models.CommentTypePullPush { + } else if comment.Type == models.CommentTypePullRequestPush { participants = addParticipant(comment.Poster, participants) if err = comment.LoadPushCommits(ctx); err != nil { ctx.ServerError("LoadPushCommits", err) @@ -1650,6 +1651,20 @@ func ViewIssue(ctx *context.Context) { ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.User.IsAdmin) ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons ctx.Data["RefEndName"] = git.RefEndName(issue.Ref) + + var hiddenCommentTypes *big.Int + if ctx.IsSigned { + val, err := user_model.GetUserSetting(ctx.User.ID, user_model.SettingsKeyHiddenCommentTypes) + if err != nil { + ctx.ServerError("GetUserSetting", err) + return + } + hiddenCommentTypes, _ = new(big.Int).SetString(val, 10) // we can safely ignore the failed conversion here + } + ctx.Data["ShouldShowCommentType"] = func(commentType models.CommentType) bool { + return hiddenCommentTypes == nil || hiddenCommentTypes.Bit(int(commentType)) == 0 + } + ctx.HTML(http.StatusOK, tplIssueView) } diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 3a61f2f92..e77e02348 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "io" + "math/big" "net/http" "os" "path/filepath" @@ -358,6 +359,18 @@ func Appearance(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsAppearance"] = true + var hiddenCommentTypes *big.Int + val, err := user_model.GetUserSetting(ctx.User.ID, user_model.SettingsKeyHiddenCommentTypes) + if err != nil { + ctx.ServerError("GetUserSetting", err) + return + } + hiddenCommentTypes, _ = new(big.Int).SetString(val, 10) // we can safely ignore the failed conversion here + + ctx.Data["IsCommentTypeGroupChecked"] = func(commentTypeGroup string) bool { + return forms.IsUserHiddenCommentTypeGroupChecked(commentTypeGroup, hiddenCommentTypes) + } + ctx.HTML(http.StatusOK, tplSettingsAppearance) } @@ -416,3 +429,16 @@ func UpdateUserLang(ctx *context.Context) { ctx.Flash.Success(i18n.Tr(ctx.User.Language, "settings.update_language_success")) ctx.Redirect(setting.AppSubURL + "/user/settings/appearance") } + +// UpdateUserHiddenComments update a user's shown comment types +func UpdateUserHiddenComments(ctx *context.Context) { + err := user_model.SetUserSetting(ctx.User.ID, user_model.SettingsKeyHiddenCommentTypes, forms.UserHiddenCommentTypesFromRequest(ctx).String()) + if err != nil { + ctx.ServerError("SetUserSetting", err) + return + } + + log.Trace("User settings updated: %s", ctx.User.Name) + ctx.Flash.Success(ctx.Tr("settings.saved_successfully")) + ctx.Redirect(setting.AppSubURL + "/user/settings/appearance") +} diff --git a/routers/web/web.go b/routers/web/web.go index 698f91b8c..6415788e4 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -323,6 +323,7 @@ func RegisterRoutes(m *web.Route) { m.Group("/appearance", func() { m.Get("", user_setting.Appearance) m.Post("/language", bindIgnErr(forms.UpdateLanguageForm{}), user_setting.UpdateUserLang) + m.Post("/hidden_comments", user_setting.UpdateUserHiddenComments) m.Post("/theme", bindIgnErr(forms.UpdateThemeForm{}), user_setting.UpdateUIThemePost) }) m.Group("/security", func() { diff --git a/services/forms/user_form_hidden_comments.go b/services/forms/user_form_hidden_comments.go new file mode 100644 index 000000000..e0c26e8dd --- /dev/null +++ b/services/forms/user_form_hidden_comments.go @@ -0,0 +1,105 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package forms + +import ( + "math/big" + + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/log" +) + +type hiddenCommentTypeGroupsType map[string][]models.CommentType + +// hiddenCommentTypeGroups maps the group names to comment types, these group names comes from the Web UI (appearance.tmpl) +var hiddenCommentTypeGroups = hiddenCommentTypeGroupsType{ + "reference": { + /*3*/ models.CommentTypeIssueRef, + /*4*/ models.CommentTypeCommitRef, + /*5*/ models.CommentTypeCommentRef, + /*6*/ models.CommentTypePullRef, + }, + "label": { + /*7*/ models.CommentTypeLabel, + }, + "milestone": { + /*8*/ models.CommentTypeMilestone, + }, + "assignee": { + /*9*/ models.CommentTypeAssignees, + }, + "title": { + /*10*/ models.CommentTypeChangeTitle, + }, + "branch": { + /*11*/ models.CommentTypeDeleteBranch, + /*25*/ models.CommentTypeChangeTargetBranch, + }, + "time_tracking": { + /*12*/ models.CommentTypeStartTracking, + /*13*/ models.CommentTypeStopTracking, + /*14*/ models.CommentTypeAddTimeManual, + /*15*/ models.CommentTypeCancelTracking, + /*26*/ models.CommentTypeDeleteTimeManual, + }, + "deadline": { + /*16*/ models.CommentTypeAddedDeadline, + /*17*/ models.CommentTypeModifiedDeadline, + /*18*/ models.CommentTypeRemovedDeadline, + }, + "dependency": { + /*19*/ models.CommentTypeAddDependency, + /*20*/ models.CommentTypeRemoveDependency, + }, + "lock": { + /*23*/ models.CommentTypeLock, + /*24*/ models.CommentTypeUnlock, + }, + "review_request": { + /*27*/ models.CommentTypeReviewRequest, + }, + "pull_request_push": { + /*29*/ models.CommentTypePullRequestPush, + }, + "project": { + /*30*/ models.CommentTypeProject, + /*31*/ models.CommentTypeProjectBoard, + }, + "issue_ref": { + /*33*/ models.CommentTypeChangeIssueRef, + }, +} + +// UserHiddenCommentTypesFromRequest parse the form to hidden comment types bitset +func UserHiddenCommentTypesFromRequest(ctx *context.Context) *big.Int { + bitset := new(big.Int) + for group, commentTypes := range hiddenCommentTypeGroups { + if ctx.FormBool(group) { + for _, commentType := range commentTypes { + bitset = bitset.SetBit(bitset, int(commentType), 1) + } + } + } + return bitset +} + +// IsUserHiddenCommentTypeGroupChecked check whether a hidden comment type group is "enabled" (checked on UI) +func IsUserHiddenCommentTypeGroupChecked(group string, hiddenCommentTypes *big.Int) (ret bool) { + commentTypes, ok := hiddenCommentTypeGroups[group] + if !ok { + log.Critical("the group map for hidden comment types is out of sync, unknown group: %v", group) + return + } + if hiddenCommentTypes == nil { + return false + } + for _, commentType := range commentTypes { + if hiddenCommentTypes.Bit(int(commentType)) == 1 { + return true + } + } + return false +} diff --git a/services/mailer/mail.go b/services/mailer/mail.go index 5244cd043..e5aa25008 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -449,7 +449,7 @@ func actionToTemplate(issue *models.Issue, actionType models.ActionType, name = "code" case models.CommentTypeAssignees: name = "assigned" - case models.CommentTypePullPush: + case models.CommentTypePullRequestPush: name = "push" default: name = "default" diff --git a/services/mailer/mail_comment.go b/services/mailer/mail_comment.go index a42458b2c..baecd2a10 100644 --- a/services/mailer/mail_comment.go +++ b/services/mailer/mail_comment.go @@ -21,7 +21,7 @@ func MailParticipantsComment(ctx context.Context, c *models.Comment, opType mode } content := c.Content - if c.Type == models.CommentTypePullPush { + if c.Type == models.CommentTypePullRequestPush { content = "" } if err := mailIssueCommentToParticipants( diff --git a/services/pull/pull.go b/services/pull/pull.go index 4f691c0eb..10fbc124a 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -108,7 +108,7 @@ func NewPullRequest(ctx context.Context, repo *repo_model.Repository, pull *mode } ops := &models.CreateCommentOptions{ - Type: models.CommentTypePullPush, + Type: models.CommentTypePullRequestPush, Doer: pull.Poster, Repo: repo, Issue: pr.Issue, diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 73057248c..e7c161a3f 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -1,835 +1,837 @@ {{ template "base/alert" }} {{range .Issue.Comments}} - {{ $createdStr:= TimeSinceUnix .CreatedUnix $.Lang }} + {{if call $.ShouldShowCommentType .Type}} + {{ $createdStr:= TimeSinceUnix .CreatedUnix $.Lang }} - - {{if eq .Type 0}} -
- {{if .OriginalAuthor }} - - {{else}} - - {{avatar .Poster}} - - {{end}} -
-
-
- {{if .OriginalAuthor }} - - {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} - {{ .OriginalAuthor }} - - - {{$.i18n.Tr "repo.issues.commented_at" (.Issue.HashTag|Escape) $createdStr | Safe}} {{if $.Repository.OriginalURL}} - - - ({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}} - - {{else}} - - - {{.Poster.GetDisplayName}} - - {{$.i18n.Tr "repo.issues.commented_at" (.HashTag|Escape) $createdStr | Safe}} - - {{end}} -
-
- {{if (.ShowRole.HasRole "Poster")}} -
- {{$.i18n.Tr "repo.issues.poster"}} -
- {{end}} - {{if (.ShowRole.HasRole "Writer")}} -
- {{$.i18n.Tr "repo.issues.collaborator"}} -
- {{end}} - {{if (.ShowRole.HasRole "Owner")}} -
- {{$.i18n.Tr "repo.issues.owner"}} -
- {{end}} - {{if not $.Repository.IsArchived}} - {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} - {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} - {{end}} + + {{if eq .Type 0}} +
+ {{if .OriginalAuthor }} + + {{else}} + + {{avatar .Poster}} + + {{end}} +
+
+
+ {{if .OriginalAuthor }} + + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} + {{ .OriginalAuthor }} + + + {{$.i18n.Tr "repo.issues.commented_at" (.Issue.HashTag|Escape) $createdStr | Safe}} {{if $.Repository.OriginalURL}} + + + ({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}} + + {{else}} + + + {{.Poster.GetDisplayName}} + + {{$.i18n.Tr "repo.issues.commented_at" (.HashTag|Escape) $createdStr | Safe}} + + {{end}} +
+
+ {{if (.ShowRole.HasRole "Poster")}} +
+ {{$.i18n.Tr "repo.issues.poster"}} +
+ {{end}} + {{if (.ShowRole.HasRole "Writer")}} +
+ {{$.i18n.Tr "repo.issues.collaborator"}} +
+ {{end}} + {{if (.ShowRole.HasRole "Owner")}} +
+ {{$.i18n.Tr "repo.issues.owner"}} +
+ {{end}} + {{if not $.Repository.IsArchived}} + {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + {{end}} +
-
-
-
- {{if .RenderedContent}} - {{.RenderedContent|Str2html}} - {{else}} - {{$.i18n.Tr "repo.issues.no_content"}} +
+
+ {{if .RenderedContent}} + {{.RenderedContent|Str2html}} + {{else}} + {{$.i18n.Tr "repo.issues.no_content"}} + {{end}} +
+
{{.Content}}
+
+ {{if .Attachments}} + {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments "Content" .RenderedContent}} {{end}}
-
{{.Content}}
-
- {{if .Attachments}} - {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments "Content" .RenderedContent}} + {{$reactions := .Reactions.GroupByType}} + {{if $reactions}} +
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} +
{{end}}
- {{$reactions := .Reactions.GroupByType}} - {{if $reactions}} -
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} -
- {{end}}
-
- {{else if eq .Type 1}} -
- {{svg "octicon-dot-fill"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{if .Issue.IsPull }} - {{$.i18n.Tr "repo.pulls.reopened_at" .EventTag $createdStr | Safe}} - {{else}} - {{$.i18n.Tr "repo.issues.reopened_at" .EventTag $createdStr | Safe}} - {{end}} - -
- {{else if eq .Type 2}} -
- {{svg "octicon-circle-slash"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{if .Issue.IsPull }} - {{$.i18n.Tr "repo.pulls.closed_at" .EventTag $createdStr | Safe}} - {{else}} - {{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}} - {{end}} - -
- {{else if eq .Type 28}} -
- {{svg "octicon-git-merge"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$link := printf "%s/commit/%s" $.Repository.HTMLURL ($.Issue.PullRequest.MergedCommitID|PathEscape)}} - {{if eq $.Issue.PullRequest.Status 3}} - {{$.i18n.Tr "repo.issues.manually_pull_merged_at" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID) ($.BaseTarget|Escape) $createdStr | Str2html}} - {{else}} - {{$.i18n.Tr "repo.issues.pull_merged_at" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID) ($.BaseTarget|Escape) $createdStr | Str2html}} - {{end}} - -
- {{else if eq .Type 3 5 6}} - {{ $refFrom:= "" }} - {{if ne .RefRepoID .Issue.RepoID}} - {{ $refFrom = $.i18n.Tr "repo.issues.ref_from" (.RefRepo.FullName|Escape) }} - {{end}} - {{ $refTr := "repo.issues.ref_issue_from" }} - {{if .Issue.IsPull}} - {{ $refTr = "repo.issues.ref_pull_from" }} - {{else if eq .RefAction 1 }} - {{ $refTr = "repo.issues.ref_closing_from" }} - {{else if eq .RefAction 2 }} - {{ $refTr = "repo.issues.ref_reopening_from" }} - {{end}} - {{ $createdStr:= TimeSinceUnix .CreatedUnix $.Lang }} -
- {{svg "octicon-bookmark"}} - - {{avatar .Poster}} - - {{if eq .RefAction 3}}{{end}} - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr $refTr (.EventTag|Escape) $createdStr (.RefCommentHTMLURL|Escape) $refFrom | Safe}} - - {{if eq .RefAction 3}}{{end}} - -
- {{.RefIssueTitle}} {{.RefIssueIdent}} + {{else if eq .Type 1}} +
+ {{svg "octicon-dot-fill"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{if .Issue.IsPull }} + {{$.i18n.Tr "repo.pulls.reopened_at" .EventTag $createdStr | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.reopened_at" .EventTag $createdStr | Safe}} + {{end}} +
-
- {{else if eq .Type 4}} -
- {{svg "octicon-bookmark"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.commit_ref_at" .EventTag $createdStr | Safe}} - -
- {{svg "octicon-git-commit"}} - {{.Content | Str2html}} + {{else if eq .Type 2}} +
+ {{svg "octicon-circle-slash"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{if .Issue.IsPull }} + {{$.i18n.Tr "repo.pulls.closed_at" .EventTag $createdStr | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}} + {{end}} +
-
- {{else if eq .Type 7}} - {{if or .AddedLabels .RemovedLabels}} + {{else if eq .Type 28}}
- {{svg "octicon-tag"}} + {{svg "octicon-git-merge"}} {{avatar .Poster}} {{.Poster.GetDisplayName}} - {{if and .AddedLabels (not .RemovedLabels)}} - {{$.i18n.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels .AddedLabels) $createdStr | Safe}} - {{else if and (not .AddedLabels) .RemovedLabels}} - {{$.i18n.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels .RemovedLabels) $createdStr | Safe}} + {{$link := printf "%s/commit/%s" $.Repository.HTMLURL ($.Issue.PullRequest.MergedCommitID|PathEscape)}} + {{if eq $.Issue.PullRequest.Status 3}} + {{$.i18n.Tr "repo.issues.manually_pull_merged_at" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID) ($.BaseTarget|Escape) $createdStr | Str2html}} {{else}} - {{$.i18n.Tr "repo.issues.add_remove_labels" (RenderLabels .AddedLabels) (RenderLabels .RemovedLabels) $createdStr | Safe}} + {{$.i18n.Tr "repo.issues.pull_merged_at" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID) ($.BaseTarget|Escape) $createdStr | Str2html}} {{end}}
- {{end}} - {{else if eq .Type 8}} -
- {{svg "octicon-milestone"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{if gt .OldMilestoneID 0}}{{if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.change_milestone_at" (.OldMilestone.Name|Escape) (.Milestone.Name|Escape) $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_milestone_at" (.OldMilestone.Name|Escape) $createdStr | Safe}}{{end}}{{else if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.add_milestone_at" (.Milestone.Name|Escape) $createdStr | Safe}}{{end}} - -
- {{else if eq .Type 9}} -
- {{svg "octicon-person"}} - {{if gt .AssigneeID 0}} - {{if .RemovedAssignee}} - - {{avatar .Assignee}} - - - {{.Assignee.GetDisplayName}} - {{ if eq .Poster.ID .Assignee.ID }} - {{$.i18n.Tr "repo.issues.remove_self_assignment" $createdStr | Safe}} - {{ else }} - {{$.i18n.Tr "repo.issues.remove_assignee_at" (.Poster.GetDisplayName|Escape) $createdStr | Safe}} - {{ end }} - - {{else}} - - {{avatar .Assignee}} + {{else if eq .Type 3 5 6}} + {{ $refFrom:= "" }} + {{if ne .RefRepoID .Issue.RepoID}} + {{ $refFrom = $.i18n.Tr "repo.issues.ref_from" (.RefRepo.FullName|Escape) }} + {{end}} + {{ $refTr := "repo.issues.ref_issue_from" }} + {{if .Issue.IsPull}} + {{ $refTr = "repo.issues.ref_pull_from" }} + {{else if eq .RefAction 1 }} + {{ $refTr = "repo.issues.ref_closing_from" }} + {{else if eq .RefAction 2 }} + {{ $refTr = "repo.issues.ref_reopening_from" }} + {{end}} + {{ $createdStr:= TimeSinceUnix .CreatedUnix $.Lang }} +
+ {{svg "octicon-bookmark"}} + + {{avatar .Poster}} + + {{if eq .RefAction 3}}{{end}} + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr $refTr (.EventTag|Escape) $createdStr (.RefCommentHTMLURL|Escape) $refFrom | Safe}} + + {{if eq .RefAction 3}}{{end}} + + +
+ {{else if eq .Type 4}} +
+ {{svg "octicon-bookmark"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.commit_ref_at" .EventTag $createdStr | Safe}} + +
+ {{svg "octicon-git-commit"}} + {{.Content | Str2html}} +
+
+ {{else if eq .Type 7}} + {{if or .AddedLabels .RemovedLabels}} +
+ {{svg "octicon-tag"}} + + {{avatar .Poster}} - {{.Assignee.GetDisplayName}} - {{if eq .Poster.ID .AssigneeID}} - {{$.i18n.Tr "repo.issues.self_assign_at" $createdStr | Safe}} + {{.Poster.GetDisplayName}} + {{if and .AddedLabels (not .RemovedLabels)}} + {{$.i18n.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels .AddedLabels) $createdStr | Safe}} + {{else if and (not .AddedLabels) .RemovedLabels}} + {{$.i18n.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels .RemovedLabels) $createdStr | Safe}} {{else}} - {{$.i18n.Tr "repo.issues.add_assignee_at" (.Poster.GetDisplayName|Escape) $createdStr | Safe}} + {{$.i18n.Tr "repo.issues.add_remove_labels" (RenderLabels .AddedLabels) (RenderLabels .RemovedLabels) $createdStr | Safe}} {{end}} - {{end}} +
{{end}} -
- {{else if eq .Type 10}} -
- {{svg "octicon-pencil"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.change_title_at" (.OldTitle|RenderEmoji) (.NewTitle|RenderEmoji) $createdStr | Safe}} - -
- {{else if eq .Type 11}} -
- {{svg "octicon-git-branch"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.delete_branch_at" (.OldRef|Escape) $createdStr | Safe}} - -
- {{else if eq .Type 12}} -
- {{svg "octicon-clock"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.start_tracking_history" $createdStr | Safe}} - -
- {{else if eq .Type 13}} -
- {{svg "octicon-clock"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}} - - {{ template "repo/issue/view_content/comments_delete_time" Dict "ctx" $ "comment" . }} -
- {{svg "octicon-clock"}} - {{.Content}} -
-
- {{else if eq .Type 14}} -
- {{svg "octicon-clock"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.add_time_history" $createdStr | Safe}} - - {{ template "repo/issue/view_content/comments_delete_time" Dict "ctx" $ "comment" . }} -
- {{svg "octicon-clock"}} - {{.Content}} + {{else if eq .Type 8}} +
+ {{svg "octicon-milestone"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{if gt .OldMilestoneID 0}}{{if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.change_milestone_at" (.OldMilestone.Name|Escape) (.Milestone.Name|Escape) $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_milestone_at" (.OldMilestone.Name|Escape) $createdStr | Safe}}{{end}}{{else if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.add_milestone_at" (.Milestone.Name|Escape) $createdStr | Safe}}{{end}} +
-
- {{else if eq .Type 15}} -
- {{svg "octicon-clock"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}} - -
- {{else if eq .Type 16}} -
- {{svg "octicon-clock"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.due_date_added" .Content $createdStr | Safe}} - -
- {{else if eq .Type 17}} -
- {{svg "octicon-clock"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.due_date_modified" (.Content | ParseDeadline) $createdStr | Safe}} - -
- {{else if eq .Type 18}} -
- {{svg "octicon-clock"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.due_date_remove" .Content $createdStr | Safe}} - -
- {{else if eq .Type 19}} -
- {{svg "octicon-package-dependents"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.dependency.added_dependency" $createdStr | Safe}} - - {{if .DependentIssue}} -
- {{svg "octicon-plus"}} - - - {{if eq .DependentIssue.RepoID .Issue.RepoID}} - #{{.DependentIssue.Index}} {{.DependentIssue.Title}} + {{else if eq .Type 9}} +
+ {{svg "octicon-person"}} + {{if gt .AssigneeID 0}} + {{if .RemovedAssignee}} + + {{avatar .Assignee}} + + + {{.Assignee.GetDisplayName}} + {{ if eq .Poster.ID .Assignee.ID }} + {{$.i18n.Tr "repo.issues.remove_self_assignment" $createdStr | Safe}} + {{ else }} + {{$.i18n.Tr "repo.issues.remove_assignee_at" (.Poster.GetDisplayName|Escape) $createdStr | Safe}} + {{ end }} + + {{else}} + + {{avatar .Assignee}} + + + {{.Assignee.GetDisplayName}} + {{if eq .Poster.ID .AssigneeID}} + {{$.i18n.Tr "repo.issues.self_assign_at" $createdStr | Safe}} {{else}} - {{.DependentIssue.Repo.FullName}}#{{.DependentIssue.Index}} - {{.DependentIssue.Title}} + {{$.i18n.Tr "repo.issues.add_assignee_at" (.Poster.GetDisplayName|Escape) $createdStr | Safe}} {{end}} - - + + {{end}} + {{end}} +
+ {{else if eq .Type 10}} +
+ {{svg "octicon-pencil"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.change_title_at" (.OldTitle|RenderEmoji) (.NewTitle|RenderEmoji) $createdStr | Safe}} + +
+ {{else if eq .Type 11}} +
+ {{svg "octicon-git-branch"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.delete_branch_at" (.OldRef|Escape) $createdStr | Safe}} + +
+ {{else if eq .Type 12}} +
+ {{svg "octicon-clock"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.start_tracking_history" $createdStr | Safe}} + +
+ {{else if eq .Type 13}} +
+ {{svg "octicon-clock"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}} + + {{ template "repo/issue/view_content/comments_delete_time" Dict "ctx" $ "comment" . }} +
+ {{svg "octicon-clock"}} + {{.Content}}
- {{end}} -
- {{else if eq .Type 20}} -
- {{svg "octicon-package-dependents"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.dependency.removed_dependency" $createdStr | Safe}} - - {{if .DependentIssue}} +
+ {{else if eq .Type 14}} +
+ {{svg "octicon-clock"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.add_time_history" $createdStr | Safe}} + + {{ template "repo/issue/view_content/comments_delete_time" Dict "ctx" $ "comment" . }} - {{end}} -
- {{else if eq .Type 22}} -
-
- {{if .OriginalAuthor }} - {{else}} - +
+ {{else if eq .Type 15}} +
+ {{svg "octicon-clock"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}} + +
+ {{else if eq .Type 16}} +
+ {{svg "octicon-clock"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.due_date_added" .Content $createdStr | Safe}} + +
+ {{else if eq .Type 17}} +
+ {{svg "octicon-clock"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.due_date_modified" (.Content | ParseDeadline) $createdStr | Safe}} + +
+ {{else if eq .Type 18}} +
+ {{svg "octicon-clock"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.due_date_remove" .Content $createdStr | Safe}} + +
+ {{else if eq .Type 19}} +
+ {{svg "octicon-package-dependents"}} + {{avatar .Poster}} + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.dependency.added_dependency" $createdStr | Safe}} + + {{if .DependentIssue}} + {{end}} - {{svg (printf "octicon-%s" .Review.Type.Icon)}} +
+ {{else if eq .Type 20}} +
+ {{svg "octicon-package-dependents"}} + + {{avatar .Poster}} + - {{if .OriginalAuthor }} - - {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} - {{ .OriginalAuthor }} + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.dependency.removed_dependency" $createdStr | Safe}} + + {{if .DependentIssue}} +
+ {{svg "octicon-trash"}} + + + {{if eq .DependentIssue.RepoID .Issue.RepoID}} + #{{.DependentIssue.Index}} {{.DependentIssue.Title}} + {{else}} + {{.DependentIssue.Repo.FullName}}#{{.DependentIssue.Index}} - {{.DependentIssue.Title}} + {{end}} + - {{if $.Repository.OriginalURL}} - ({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}} +
+ {{end}} +
+ {{else if eq .Type 22}} +
+
+ {{if .OriginalAuthor }} {{else}} - {{.Poster.GetDisplayName}} + + {{avatar .Poster}} + {{end}} + {{svg (printf "octicon-%s" .Review.Type.Icon)}} + + {{if .OriginalAuthor }} + + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} + {{ .OriginalAuthor }} + + {{if $.Repository.OriginalURL}} + ({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}} + {{else}} + {{.Poster.GetDisplayName}} + {{end}} - {{if eq .Review.Type 1}} - {{$.i18n.Tr "repo.issues.review.approve" $createdStr | Safe}} - {{else if eq .Review.Type 2}} - {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}} - {{else if eq .Review.Type 3}} - {{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}} - {{else}} - {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}} - {{end}} - {{if .Review.Dismissed}} -
{{$.i18n.Tr "repo.issues.review.dismissed_label"}}
- {{end}} -
-
- {{if .Content}} -
-
-
-
- - {{if .OriginalAuthor }} - - {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} - {{ .OriginalAuthor }} - - {{if $.Repository.OriginalURL}} - ({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}} - {{else}} - {{.Poster.GetDisplayName}} - {{end}} + {{if eq .Review.Type 1}} + {{$.i18n.Tr "repo.issues.review.approve" $createdStr | Safe}} + {{else if eq .Review.Type 2}} + {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}} + {{else if eq .Review.Type 3}} + {{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}} + {{end}} + {{if .Review.Dismissed}} +
{{$.i18n.Tr "repo.issues.review.dismissed_label"}}
+ {{end}} +
+
+ {{if .Content}} +
+
+
+
+ + {{if .OriginalAuthor }} + + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} + {{ .OriginalAuthor }} + + {{if $.Repository.OriginalURL}} + ({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}} + {{else}} + {{.Poster.GetDisplayName}} + {{end}} - {{$.i18n.Tr "repo.issues.review.left_comment" | Safe}} - + {{$.i18n.Tr "repo.issues.review.left_comment" | Safe}} + +
+
+ {{if (.ShowRole.HasRole "Poster")}} +
+ {{$.i18n.Tr "repo.issues.poster"}} +
+ {{end}} + {{if (.ShowRole.HasRole "Writer")}} +
+ {{$.i18n.Tr "repo.issues.collaborator"}} +
+ {{end}} + {{if (.ShowRole.HasRole "Owner")}} +
+ {{$.i18n.Tr "repo.issues.owner"}} +
+ {{end}} + {{if not $.Repository.IsArchived}} + {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + {{end}} +
-
- {{if (.ShowRole.HasRole "Poster")}} -
- {{$.i18n.Tr "repo.issues.poster"}} -
- {{end}} - {{if (.ShowRole.HasRole "Writer")}} -
- {{$.i18n.Tr "repo.issues.collaborator"}} -
- {{end}} - {{if (.ShowRole.HasRole "Owner")}} -
- {{$.i18n.Tr "repo.issues.owner"}} -
- {{end}} - {{if not $.Repository.IsArchived}} - {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} - {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} +
+
+ {{if .RenderedContent}} + {{.RenderedContent|Str2html}} + {{else}} + {{$.i18n.Tr "repo.issues.no_content"}} {{end}} -
-
-
-
- {{if .RenderedContent}} - {{.RenderedContent|Str2html}} - {{else}} - {{$.i18n.Tr "repo.issues.no_content"}} +
+
{{.Content}}
+
+ {{if .Attachments}} + {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments "Content" .RenderedContent}} {{end}}
-
{{.Content}}
-
- {{if .Attachments}} - {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments "Content" .RenderedContent}} + {{$reactions := .Reactions.GroupByType}} + {{if $reactions}} +
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} +
{{end}}
- {{$reactions := .Reactions.GroupByType}} - {{if $reactions}} -
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} -
- {{end}}
-
- {{end}} + {{end}} - {{if .Review.CodeComments}} -
- {{ range $filename, $lines := .Review.CodeComments}} - {{range $line, $comms := $lines}} -
-
- {{$invalid := (index $comms 0).Invalidated}} - {{$resolved := (index $comms 0).IsResolved}} - {{$resolveDoer := (index $comms 0).ResolveDoer}} - {{$isNotPending := (not (eq (index $comms 0).Review.Type 0))}} -
- {{$filename}} - {{if $invalid }} - - {{$.i18n.Tr "repo.issues.review.outdated"}} - - {{end}} -
-
- {{if or $invalid $resolved}} - - - {{end}} + {{if .Review.CodeComments}} +
+ {{ range $filename, $lines := .Review.CodeComments}} + {{range $line, $comms := $lines}} +
+
+ {{$invalid := (index $comms 0).Invalidated}} + {{$resolved := (index $comms 0).IsResolved}} + {{$resolveDoer := (index $comms 0).ResolveDoer}} + {{$isNotPending := (not (eq (index $comms 0).Review.Type 0))}} +
+ {{$filename}} + {{if $invalid }} + + {{$.i18n.Tr "repo.issues.review.outdated"}} + + {{end}} +
+
+ {{if or $invalid $resolved}} + + + {{end}} +
-
- {{$diff := (CommentMustAsDiff (index $comms 0))}} - {{if $diff}} - {{$file := (index $diff.Files 0)}} -
-
-
- - - {{template "repo/diff/section_unified" dict "file" $file "root" $}} - -
+ {{$diff := (CommentMustAsDiff (index $comms 0))}} + {{if $diff}} + {{$file := (index $diff.Files 0)}} +
+
+
+ + + {{template "repo/diff/section_unified" dict "file" $file "root" $}} + +
+
-
- {{end}} -
-
- {{range $comms}} - {{ $createdSubStr:= TimeSinceUnix .CreatedUnix $.Lang }} -
-
-
-
- {{if not .OriginalAuthor }} - - {{avatar .Poster}} - - {{end}} - - {{if .OriginalAuthor }} - - {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} - {{ .OriginalAuthor }} - - {{if $.Repository.OriginalURL}} - ({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}} - {{else}} - {{.Poster.GetDisplayName}} + {{end}} +
+
+ {{range $comms}} + {{ $createdSubStr:= TimeSinceUnix .CreatedUnix $.Lang }} +
+
+
+
+ {{if not .OriginalAuthor }} + + {{avatar .Poster}} + + {{end}} + + {{if .OriginalAuthor }} + + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} + {{ .OriginalAuthor }} + + {{if $.Repository.OriginalURL}} + ({{$.i18n.Tr "repo.migrated_from" ($.Repository.OriginalURL|Escape) ($.Repository.GetOriginalURLHostname|Escape) | Safe }}){{end}} + {{else}} + {{.Poster.GetDisplayName}} + {{end}} + {{$.i18n.Tr "repo.issues.commented_at" (.HashTag|Escape) $createdSubStr | Safe}} + +
+
+ {{if (.ShowRole.HasRole "Poster")}} +
+ {{$.i18n.Tr "repo.issues.poster"}} +
{{end}} - {{$.i18n.Tr "repo.issues.commented_at" (.HashTag|Escape) $createdSubStr | Safe}} - + {{if (.ShowRole.HasRole "Writer")}} +
+ {{$.i18n.Tr "repo.issues.collaborator"}} +
+ {{end}} + {{if (.ShowRole.HasRole "Owner")}} +
+ {{$.i18n.Tr "repo.issues.owner"}} +
+ {{end}} + {{if not $.Repository.IsArchived}} + {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + {{end}} +
-
- {{if (.ShowRole.HasRole "Poster")}} -
- {{$.i18n.Tr "repo.issues.poster"}} -
- {{end}} - {{if (.ShowRole.HasRole "Writer")}} -
- {{$.i18n.Tr "repo.issues.collaborator"}} -
- {{end}} - {{if (.ShowRole.HasRole "Owner")}} -
- {{$.i18n.Tr "repo.issues.owner"}} -
- {{end}} - {{if not $.Repository.IsArchived}} - {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID)}} - {{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} +
+
+ {{if .RenderedContent}} + {{.RenderedContent|Str2html}} + {{else}} + {{$.i18n.Tr "repo.issues.no_content"}} {{end}} +
+
{{.Content}}
+
-
-
-
- {{if .RenderedContent}} - {{.RenderedContent|Str2html}} - {{else}} - {{$.i18n.Tr "repo.issues.no_content"}} + {{$reactions := .Reactions.GroupByType}} + {{if $reactions}} +
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} +
{{end}} -
-
{{.Content}}
-
- {{$reactions := .Reactions.GroupByType}} - {{if $reactions}} -
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} -
- {{end}} -
-
- {{end}} -
-
-
- {{if $resolved}} -
- {{svg "octicon-check" 16 "mr-2"}} - {{$resolveDoer.Name}} {{$.i18n.Tr "repo.issues.review.resolved_by"}}
{{end}}
-
- {{if and $.CanMarkConversation $isNotPending}} - - {{end}} - {{if and $.SignedUserID (not $.Repository.IsArchived)}} - - {{end}} +
+
+ {{if $resolved}} +
+ {{svg "octicon-check" 16 "mr-2"}} + {{$resolveDoer.Name}} {{$.i18n.Tr "repo.issues.review.resolved_by"}} +
+ {{end}} +
+
+ {{if and $.CanMarkConversation $isNotPending}} + + {{end}} + {{if and $.SignedUserID (not $.Repository.IsArchived)}} + + {{end}} +
+ {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $comms 0).ReviewID "root" $ "comment" (index $comms 0)}}
- {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index $comms 0).ReviewID "root" $ "comment" (index $comms 0)}}
-
+ {{end}} {{end}} +
{{end}}
- {{end}} -
- {{else if eq .Type 23}} -
- {{svg "octicon-lock"}} - - {{avatar .Poster}} - - {{ if .Content }} + {{else if eq .Type 23}} +
+ {{svg "octicon-lock"}} + + {{avatar .Poster}} + + {{ if .Content }} + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.lock_with_reason" .Content $createdStr | Safe}} + + {{ else }} + + {{.Poster.GetDisplayName}} + {{$.i18n.Tr "repo.issues.lock_no_reason" $createdStr | Safe}} + + {{ end }} +
+ {{else if eq .Type 24}} +
+ {{svg "octicon-key"}} + + {{avatar .Poster}} + {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.lock_with_reason" .Content $createdStr | Safe}} + {{$.i18n.Tr "repo.issues.unlock_comment" $createdStr | Safe}} + +
+ {{else if eq .Type 25}} +
+ {{svg "octicon-git-branch"}} + + {{avatar .Poster}} + + + {{.Poster.Name}} + {{$.i18n.Tr "repo.pulls.change_target_branch_at" (.OldRef|Escape) (.NewRef|Escape) $createdStr | Safe}} - {{ else }} +
+ {{else if eq .Type 26}} +
+ {{svg "octicon-clock"}} + + {{avatar .Poster}} + {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.lock_no_reason" $createdStr | Safe}} + {{$.i18n.Tr "repo.issues.del_time_history" $createdStr | Safe}} - {{ end }} -
- {{else if eq .Type 24}} -
- {{svg "octicon-key"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.unlock_comment" $createdStr | Safe}} - -
- {{else if eq .Type 25}} -
- {{svg "octicon-git-branch"}} - - {{avatar .Poster}} - - - {{.Poster.Name}} - {{$.i18n.Tr "repo.pulls.change_target_branch_at" (.OldRef|Escape) (.NewRef|Escape) $createdStr | Safe}} - -
- {{else if eq .Type 26}} -
- {{svg "octicon-clock"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{$.i18n.Tr "repo.issues.del_time_history" $createdStr | Safe}} - -
- {{svg "octicon-clock"}} - {{.Content}} +
+ {{svg "octicon-clock"}} + {{.Content}} +
-
- {{else if eq .Type 27}} -
- {{svg "octicon-eye"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{if (gt .AssigneeID 0)}} - {{if .RemovedAssignee}} - {{if eq .PosterID .AssigneeID}} - {{$.i18n.Tr "repo.issues.review.remove_review_request_self" $createdStr | Safe}} + {{else if eq .Type 27}} +
+ {{svg "octicon-eye"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{if (gt .AssigneeID 0)}} + {{if .RemovedAssignee}} + {{if eq .PosterID .AssigneeID}} + {{$.i18n.Tr "repo.issues.review.remove_review_request_self" $createdStr | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.review.remove_review_request" (.Assignee.GetDisplayName|Escape) $createdStr | Safe}} + {{end}} {{else}} - {{$.i18n.Tr "repo.issues.review.remove_review_request" (.Assignee.GetDisplayName|Escape) $createdStr | Safe}} + {{$.i18n.Tr "repo.issues.review.add_review_request" (.Assignee.GetDisplayName|Escape) $createdStr | Safe}} {{end}} {{else}} - {{$.i18n.Tr "repo.issues.review.add_review_request" (.Assignee.GetDisplayName|Escape) $createdStr | Safe}} - {{end}} - {{else}} - {{if .RemovedAssignee}} - {{$.i18n.Tr "repo.issues.review.remove_review_request" (.AssigneeTeam.Name|Escape) $createdStr | Safe}} - {{else}} - {{$.i18n.Tr "repo.issues.review.add_review_request" (.AssigneeTeam.Name|Escape) $createdStr | Safe}} + {{if .RemovedAssignee}} + {{$.i18n.Tr "repo.issues.review.remove_review_request" (.AssigneeTeam.Name|Escape) $createdStr | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.review.add_review_request" (.AssigneeTeam.Name|Escape) $createdStr | Safe}} + {{end}} {{end}} - {{end}} - -
- {{else if and (eq .Type 29) (or (gt .CommitsNum 0) .IsForcePush)}} -
- {{svg "octicon-repo-push"}} - - {{.Poster.GetDisplayName}} - {{ if .IsForcePush }} - {{$.i18n.Tr "repo.issues.force_push_codes" ($.Issue.PullRequest.HeadBranch|Escape) (ShortSha .OldCommit) (($.Issue.Repo.CommitLink .OldCommit)|Escape) (ShortSha .NewCommit) (($.Issue.Repo.CommitLink .NewCommit)|Escape) $createdStr | Safe}} - {{else}} - {{$.i18n.TrN (len .Commits) "repo.issues.push_commit_1" "repo.issues.push_commits_n" (len .Commits) $createdStr | Safe}} - {{end}} - -
- {{if not .IsForcePush}} - {{template "repo/commits_list_small" dict "comment" . "root" $}} - {{end}} - {{else if eq .Type 30}} - {{if not $.UnitProjectsGlobalDisabled}} -
- {{svg "octicon-project"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{if gt .OldProjectID 0}} - {{if gt .ProjectID 0}} - {{$.i18n.Tr "repo.issues.change_project_at" (.OldProject.Title|Escape) (.Project.Title|Escape) $createdStr | Safe}} + +
+ {{else if and (eq .Type 29) (or (gt .CommitsNum 0) .IsForcePush)}} +
+ {{svg "octicon-repo-push"}} + + {{.Poster.GetDisplayName}} + {{ if .IsForcePush }} + {{$.i18n.Tr "repo.issues.force_push_codes" ($.Issue.PullRequest.HeadBranch|Escape) (ShortSha .OldCommit) (($.Issue.Repo.CommitLink .OldCommit)|Escape) (ShortSha .NewCommit) (($.Issue.Repo.CommitLink .NewCommit)|Escape) $createdStr | Safe}} {{else}} - {{$.i18n.Tr "repo.issues.remove_project_at" (.OldProject.Title|Escape) $createdStr | Safe}} + {{$.i18n.TrN (len .Commits) "repo.issues.push_commit_1" "repo.issues.push_commits_n" (len .Commits) $createdStr | Safe}} {{end}} - {{else if gt .ProjectID 0}} - {{$.i18n.Tr "repo.issues.add_project_at" (.Project.Title|Escape) $createdStr | Safe}} - {{end}} - -
- {{end}} - {{else if eq .Type 32}} -
+ +
+ {{if not .IsForcePush}} + {{template "repo/commits_list_small" dict "comment" . "root" $}} + {{end}} + {{else if eq .Type 30}} + {{if not $.UnitProjectsGlobalDisabled}}
- - + {{svg "octicon-project"}} + + {{avatar .Poster}} - {{svg "octicon-x" 16}} - {{.Poster.GetDisplayName}} - {{$reviewerName := ""}} - {{if eq .Review.OriginalAuthor ""}} - {{$reviewerName = .Review.Reviewer.Name}} - {{else}} - {{$reviewerName = .Review.OriginalAuthor}} + {{.Poster.GetDisplayName}} + {{if gt .OldProjectID 0}} + {{if gt .ProjectID 0}} + {{$.i18n.Tr "repo.issues.change_project_at" (.OldProject.Title|Escape) (.Project.Title|Escape) $createdStr | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.remove_project_at" (.OldProject.Title|Escape) $createdStr | Safe}} + {{end}} + {{else if gt .ProjectID 0}} + {{$.i18n.Tr "repo.issues.add_project_at" (.Project.Title|Escape) $createdStr | Safe}} {{end}} - {{$.i18n.Tr "repo.issues.review.dismissed" $reviewerName $createdStr | Safe}}
- {{if .Content}} -
-
-
- - {{$.i18n.Tr "action.review_dismissed_reason"}} - -
-
-
- {{if .RenderedContent}} - {{.RenderedContent|Str2html}} - {{else}} - {{$.i18n.Tr "repo.issues.no_content"}} - {{end}} + {{end}} + {{else if eq .Type 32}} +
+
+ + + + {{svg "octicon-x" 16}} + + {{.Poster.GetDisplayName}} + {{$reviewerName := ""}} + {{if eq .Review.OriginalAuthor ""}} + {{$reviewerName = .Review.Reviewer.Name}} + {{else}} + {{$reviewerName = .Review.OriginalAuthor}} + {{end}} + {{$.i18n.Tr "repo.issues.review.dismissed" $reviewerName $createdStr | Safe}} + +
+ {{if .Content}} +
+
+
+ + {{$.i18n.Tr "action.review_dismissed_reason"}} + +
+
+
+ {{if .RenderedContent}} + {{.RenderedContent|Str2html}} + {{else}} + {{$.i18n.Tr "repo.issues.no_content"}} + {{end}} +
-
- {{end}} -
- {{else if eq .Type 33}} -
- {{svg "octicon-git-branch"}} - - {{avatar .Poster}} - - - {{.Poster.GetDisplayName}} - {{if and .OldRef .NewRef}} - {{$.i18n.Tr "repo.issues.change_ref_at" (.OldRef|Escape) (.NewRef|Escape) $createdStr | Safe}} - {{else if .OldRef}} - {{$.i18n.Tr "repo.issues.remove_ref_at" (.OldRef|Escape) $createdStr | Safe}} - {{else}} - {{$.i18n.Tr "repo.issues.add_ref_at" (.NewRef|Escape) $createdStr | Safe}} {{end}} - -
+
+ {{else if eq .Type 33}} +
+ {{svg "octicon-git-branch"}} + + {{avatar .Poster}} + + + {{.Poster.GetDisplayName}} + {{if and .OldRef .NewRef}} + {{$.i18n.Tr "repo.issues.change_ref_at" (.OldRef|Escape) (.NewRef|Escape) $createdStr | Safe}} + {{else if .OldRef}} + {{$.i18n.Tr "repo.issues.remove_ref_at" (.OldRef|Escape) $createdStr | Safe}} + {{else}} + {{$.i18n.Tr "repo.issues.add_ref_at" (.NewRef|Escape) $createdStr | Safe}} + {{end}} + +
+ {{end}} {{end}} {{end}} diff --git a/templates/user/settings/appearance.tmpl b/templates/user/settings/appearance.tmpl index 777b89c75..fe4a668dd 100644 --- a/templates/user/settings/appearance.tmpl +++ b/templates/user/settings/appearance.tmpl @@ -68,6 +68,104 @@
+ + +

+ {{.i18n.Tr "settings.hidden_comment_types"}} +

+
+
+ {{.CsrfTokenHtml}} +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+