diff --git a/models/issues/comment.go b/models/issues/comment.go index c935e4ac91a6..36e7b8e785e3 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -1244,3 +1244,8 @@ func FixCommentTypeLabelWithOutsideLabels(ctx context.Context) (int64, error) { return res.RowsAffected() } + +// HasOriginalAuthor returns if a comment was migrated and has an original author. +func (c *Comment) HasOriginalAuthor() bool { + return c.OriginalAuthor != "" && c.OriginalAuthorID != 0 +} diff --git a/models/issues/issue.go b/models/issues/issue.go index 62b936331b92..e0dcf3d269ee 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -2403,3 +2403,8 @@ func DeleteOrphanedIssues(ctx context.Context) error { } return nil } + +// HasOriginalAuthor returns if an issue was migrated and has an original author. +func (issue *Issue) HasOriginalAuthor() bool { + return issue.OriginalAuthor != "" && issue.OriginalAuthorID != 0 +} diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 4d799c24b8f0..42dcfb382d8d 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1142,7 +1142,11 @@ func NewIssuePost(ctx *context.Context) { } // roleDescriptor returns the Role Descriptor for a comment in/with the given repo, poster and issue -func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *user_model.User, issue *issues_model.Issue) (issues_model.RoleDescriptor, error) { +func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *user_model.User, issue *issues_model.Issue, hasOriginalAuthor bool) (issues_model.RoleDescriptor, error) { + if hasOriginalAuthor { + return issues_model.RoleDescriptorNone, nil + } + perm, err := access_model.GetUserRepoPermission(ctx, repo, poster) if err != nil { return issues_model.RoleDescriptorNone, err @@ -1444,7 +1448,7 @@ func ViewIssue(ctx *context.Context) { // check if dependencies can be created across repositories ctx.Data["AllowCrossRepositoryDependencies"] = setting.Service.AllowCrossRepositoryDependencies - if issue.ShowRole, err = roleDescriptor(ctx, repo, issue.Poster, issue); err != nil { + if issue.ShowRole, err = roleDescriptor(ctx, repo, issue.Poster, issue, issue.HasOriginalAuthor()); err != nil { ctx.ServerError("roleDescriptor", err) return } @@ -1483,7 +1487,7 @@ func ViewIssue(ctx *context.Context) { continue } - comment.ShowRole, err = roleDescriptor(ctx, repo, comment.Poster, issue) + comment.ShowRole, err = roleDescriptor(ctx, repo, comment.Poster, issue, comment.HasOriginalAuthor()) if err != nil { ctx.ServerError("roleDescriptor", err) return @@ -1582,7 +1586,7 @@ func ViewIssue(ctx *context.Context) { continue } - c.ShowRole, err = roleDescriptor(ctx, repo, c.Poster, issue) + c.ShowRole, err = roleDescriptor(ctx, repo, c.Poster, issue, c.HasOriginalAuthor()) if err != nil { ctx.ServerError("roleDescriptor", err) return diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index 663264171b2b..dff6b5daaa16 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -167,9 +167,11 @@
{{svg "octicon-x"}} {{$.locale.Tr "repo.pulls.files_conflicted"}} - {{range .ConflictedFiles}} -
{{.}}
- {{end}} +
{{else if .IsPullRequestBroken}}
@@ -226,11 +228,11 @@
{{svg "octicon-x" 16}} {{$.locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}} -
+
    {{range .ChangedProtectedFiles}} -
    {{.}}
    +
  • {{.}}
  • {{end}} -
+
{{else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsError .RequiredStatusCheckState.IsFailure)}}
@@ -378,10 +380,6 @@
- - {{if .ShowMergeInstructions}} - {{template "repo/issue/view_content/pull_merge_instruction" (dict "locale" .locale "Issue" .Issue)}} - {{end}} {{else}} {{/* no merge style was set in repo setting: not or ($prUnit.PullRequestsConfig.AllowMerge ...) */}}
@@ -428,11 +426,11 @@
{{svg "octicon-x" 16}} {{$.locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}} -
+
    {{range .ChangedProtectedFiles}} -
    {{.}}
    +
  • {{.}}
  • {{end}} -
+
{{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
@@ -479,6 +477,10 @@
{{end}} + + {{if and .ShowMergeInstructions .Issue.PullRequest.HeadRepo}} + {{template "repo/issue/view_content/pull_merge_instruction" (dict "locale" .locale "Issue" .Issue)}} + {{end}}
diff --git a/templates/repo/issue/view_content/pull_merge_instruction.tmpl b/templates/repo/issue/view_content/pull_merge_instruction.tmpl index 5669b2fb69bb..39349d6ca42f 100644 --- a/templates/repo/issue/view_content/pull_merge_instruction.tmpl +++ b/templates/repo/issue/view_content/pull_merge_instruction.tmpl @@ -1,6 +1,6 @@ -
{{$.locale.Tr "repo.pulls.merge_instruction_hint" | Safe}}
-