Skip to content

Commit

Permalink
Merge branch 'main' into fix-legacy-hide
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Feb 16, 2023
2 parents 50d07da + 3f318a4 commit 10a21f5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 22 deletions.
5 changes: 5 additions & 0 deletions models/issues/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions models/issues/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
12 changes: 8 additions & 4 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
28 changes: 15 additions & 13 deletions templates/repo/issue/view_content/pull.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@
<div class="item text">
{{svg "octicon-x"}}
{{$.locale.Tr "repo.pulls.files_conflicted"}}
{{range .ConflictedFiles}}
<div>{{.}}</div>
{{end}}
<ul>
{{range .ConflictedFiles}}
<li>{{.}}</li>
{{end}}
</ul>
</div>
{{else if .IsPullRequestBroken}}
<div class="item">
Expand Down Expand Up @@ -226,11 +228,11 @@
<div class="item">
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
{{$.locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}}
<div class="ui ordered list">
<ul>
{{range .ChangedProtectedFiles}}
<div data-value="-" class="item">{{.}}</div>
<li>{{.}}</li>
{{end}}
</div>
</ul>
</div>
{{else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsError .RequiredStatusCheckState.IsFailure)}}
<div class="item">
Expand Down Expand Up @@ -378,10 +380,6 @@
</script>

<div id="pull-request-merge-form"></div>

{{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 ...) */}}
<div class="ui divider"></div>
Expand Down Expand Up @@ -428,11 +426,11 @@
<div class="item text red">
<i class="icon icon-octicon">{{svg "octicon-x" 16}}</i>
{{$.locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n" | Safe}}
<div class="ui ordered list">
<ul>
{{range .ChangedProtectedFiles}}
<div data-value="-" class="item">{{.}}</div>
<li>{{.}}</li>
{{end}}
</div>
</ul>
</div>
{{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}}
<div class="item text red">
Expand Down Expand Up @@ -479,6 +477,10 @@
</button>
</div>
{{end}}

{{if and .ShowMergeInstructions .Issue.PullRequest.HeadRepo}}
{{template "repo/issue/view_content/pull_merge_instruction" (dict "locale" .locale "Issue" .Issue)}}
{{end}}
</div>
</div>
</div>
6 changes: 3 additions & 3 deletions templates/repo/issue/view_content/pull_merge_instruction.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="instruct-toggle gt-mt-3"> {{$.locale.Tr "repo.pulls.merge_instruction_hint" | Safe}} </div>
<div class="instruct-content" style="display:none">
<div class="ui divider"></div>
<div class="ui divider"></div>
<div class="instruct-toggle"> {{$.locale.Tr "repo.pulls.merge_instruction_hint" | Safe}} </div>
<div class="instruct-content gt-mt-3" style="display:none">
<div><h3 class="gt-di">{{$.locale.Tr "step1"}} </h3>{{$.locale.Tr "repo.pulls.merge_instruction_step1_desc"}}</div>
<div class="ui secondary segment">
{{if eq $.Issue.PullRequest.Flow 0}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/shabox_badge.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div title="{{if eq .verification.TrustStatus "trusted"}}{{else if eq .verification.TrustStatus "untrusted"}}{{$.root.locale.Tr "repo.commits.signed_by_untrusted_user"}}: {{else}}{{$.root.locale.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}: {{end}}{{.verification.Reason}}">
{{if ne .verification.SigningUser.ID 0}}
{{svg "gitea-lock"}}
{{avatar $.Context .verification.SigningUser 28 "signature"}}
{{avatar $.root.Context .verification.SigningUser 28 "signature"}}
{{else}}
<span title="{{$.root.locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog"}}</span>
{{avatarByEmail $.Context .verification.SigningEmail "" 28 "signature"}}
{{avatarByEmail $.root.Context .verification.SigningEmail "" 28 "signature"}}
{{end}}
</div>
{{else}}
Expand Down

0 comments on commit 10a21f5

Please sign in to comment.