diff --git a/models/issues/review.go b/models/issues/review.go index 3e787273be8..1c5c2ee30ac 100644 --- a/models/issues/review.go +++ b/models/issues/review.go @@ -930,17 +930,19 @@ func MarkConversation(ctx context.Context, comment *Comment, doer *user_model.Us } // CanMarkConversation Add or remove Conversation mark for a code comment permission check -// the PR writer , offfcial reviewer and poster can do it +// the PR writer , official reviewer and poster can do it func CanMarkConversation(ctx context.Context, issue *Issue, doer *user_model.User) (permResult bool, err error) { if doer == nil || issue == nil { return false, fmt.Errorf("issue or doer is nil") } + if err = issue.LoadRepo(ctx); err != nil { + return false, err + } + if issue.Repo.IsArchived { + return false, nil + } if doer.ID != issue.PosterID { - if err = issue.LoadRepo(ctx); err != nil { - return false, err - } - p, err := access_model.GetUserRepoPermission(ctx, issue.Repo, doer) if err != nil { return false, err diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index ea01d96928c..a3b64b8a11f 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -24,7 +24,7 @@ {{end}}
- {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived) (not .DiffNotAvailable)}} + {{if and .PageIsPullFiles $.SignedUserID (not .DiffNotAvailable)}}
{{end}} - {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}} + {{if and .PageIsPullFiles $.SignedUserID}} {{template "repo/diff/new_review" .}} {{end}} @@ -105,7 +105,7 @@ {{$isCsv := (call $.IsCsvFile $file)}} {{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv)}} {{$isExpandable := or (gt $file.Addition 0) (gt $file.Deletion 0) $file.IsBin}} - {{$isReviewFile := and $.IsSigned $.PageIsPullFiles (not $.IsArchived) $.IsShowingAllCommits}} + {{$isReviewFile := and $.IsSigned $.PageIsPullFiles (not $.Repository.IsArchived) $.IsShowingAllCommits}}

diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index ec52934a9d4..2e8261e479a 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -48,7 +48,9 @@
{{end}} {{end}} - {{template "repo/issue/view_content/add_reaction" dict "ActionURL" (printf "%s/comments/%d/reactions" $.root.RepoLink .ID)}} + {{if not $.root.Repository.IsArchived}} + {{template "repo/issue/view_content/add_reaction" dict "ActionURL" (printf "%s/comments/%d/reactions" $.root.RepoLink .ID)}} + {{end}} {{template "repo/issue/view_content/context_menu" dict "item" . "delete" true "issue" false "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}}

diff --git a/templates/repo/diff/new_review.tmpl b/templates/repo/diff/new_review.tmpl index 2febc6303aa..3bb01a139aa 100644 --- a/templates/repo/diff/new_review.tmpl +++ b/templates/repo/diff/new_review.tmpl @@ -1,56 +1,59 @@ -
- - {{if $.IsShowingAllCommits}} -
-
-
- {{.CsrfTokenHtml}} - -
-
{{ctx.Locale.Tr "repo.diff.review.header"}}
- {{svg "octicon-x" 16}} -
-
- {{template "shared/combomarkdowneditor" (dict - "MarkdownPreviewInRepo" $.Repository - "MarkdownPreviewMode" "comment" - "TextareaName" "content" - "TextareaPlaceholder" (ctx.Locale.Tr "repo.diff.review.placeholder") - "DropzoneParentContainer" "form" - )}} -
- {{if .IsAttachmentEnabled}} -
- {{template "repo/upload" .}} -
- {{end}} -
- {{$showSelfTooltip := (and $.IsSigned ($.Issue.IsPoster $.SignedUser.ID))}} - {{if not $.Issue.IsClosed}} - {{if $showSelfTooltip}} - - - - {{else}} - - {{end}} - {{end}} - - {{if not $.Issue.IsClosed}} - {{if $showSelfTooltip}} - - - - {{else}} - - {{end}} - {{end}} -
-
-
- {{end}}
+{{if $.IsShowingAllCommits}} +
+
+
+ {{.CsrfTokenHtml}} + +
+
{{ctx.Locale.Tr "repo.diff.review.header"}}
+ {{svg "octicon-x" 16}} +
+
+ {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewInRepo" $.Repository + "MarkdownPreviewMode" "comment" + "TextareaName" "content" + "TextareaPlaceholder" (ctx.Locale.Tr "repo.diff.review.placeholder") + "DropzoneParentContainer" "form" + )}} +
+ {{if .IsAttachmentEnabled}} +
+ {{template "repo/upload" .}} +
+ {{end}} +
+ {{$showSelfTooltip := (and $.IsSigned ($.Issue.IsPoster $.SignedUser.ID))}} + {{if not $.Issue.IsClosed}} + {{if $showSelfTooltip}} + + + + {{else}} + + {{end}} + {{end}} + + {{if not $.Issue.IsClosed}} + {{if $showSelfTooltip}} + + + + {{else}} + + {{end}} + {{end}} +
+
+
+{{end}} diff --git a/web_src/js/features/repo-issue.ts b/web_src/js/features/repo-issue.ts index a0cb875a877..f5455393b27 100644 --- a/web_src/js/features/repo-issue.ts +++ b/web_src/js/features/repo-issue.ts @@ -421,13 +421,11 @@ export function initRepoPullRequestReview() { // The following part is only for diff views if (!$('.repository.pull.diff').length) return; - const $reviewBtn = $('.js-btn-review'); - const $panel = $reviewBtn.parent().find('.review-box-panel'); - const $closeBtn = $panel.find('.close'); - - if ($reviewBtn.length && $panel.length) { - const tippy = createTippy($reviewBtn[0], { - content: $panel[0], + const elReviewBtn = document.querySelector('.js-btn-review'); + const elReviewPanel = document.querySelector('.review-box-panel.tippy-target'); + if (elReviewBtn && elReviewPanel) { + const tippy = createTippy(elReviewBtn, { + content: elReviewPanel, theme: 'default', placement: 'bottom', trigger: 'click', @@ -435,11 +433,7 @@ export function initRepoPullRequestReview() { interactive: true, hideOnClick: true, }); - - $closeBtn.on('click', (e) => { - e.preventDefault(); - tippy.hide(); - }); + elReviewPanel.querySelector('.close').addEventListener('click', () => tippy.hide()); } addDelegatedEventListener(document, 'click', '.add-code-comment', async (el, e) => {