fix(ui): disable PR review button in archived repos (#6729)

* disable the "Finish review" button on PR/files page for archived repos - trying to review PRs in such repos results in JS error
* wrap the button in a div and move tooltips here to make them actually display on a disabled button - currently they do not
* added simple testing

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6729
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Co-committed-by: 0ko <0ko@noreply.codeberg.org>
This commit is contained in:
0ko 2025-01-31 10:39:30 +00:00 committed by Gusted
parent 4ef00fe6f9
commit b1590068a7
3 changed files with 59 additions and 5 deletions

View file

@ -1,9 +1,16 @@
<div id="review-box">
<button class="ui tiny primary button tw-pr-1 tw-flex js-btn-review {{if not $.IsShowingAllCommits}}disabled{{end}}" {{if not $.IsShowingAllCommits}}data-tooltip-content="{{ctx.Locale.Tr "repo.pulls.review_only_possible_for_full_diff"}}"{{end}}>
{{ctx.Locale.Tr "repo.diff.review"}}
<span class="ui small label review-comments-counter" data-pending-comment-number="{{.PendingCodeCommentNumber}}">{{.PendingCodeCommentNumber}}</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
</button>
<div
{{if not $.IsShowingAllCommits}}
data-tooltip-content="{{ctx.Locale.Tr "repo.pulls.review_only_possible_for_full_diff"}}"
{{else if .Repository.IsArchived}}
data-tooltip-content="{{ctx.Locale.Tr "repo.archive.pull.noreview"}}"
{{end}}>
<button class="ui tiny primary button tw-pr-1 tw-flex js-btn-review {{if or (not $.IsShowingAllCommits) .Repository.IsArchived}}disabled{{end}}">
{{ctx.Locale.Tr "repo.diff.review"}}
<span class="ui small label review-comments-counter" data-pending-comment-number="{{.PendingCodeCommentNumber}}">{{.PendingCodeCommentNumber}}</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
</button>
</div>
{{if $.IsShowingAllCommits}}
<div class="review-box-panel tippy-target">
<div class="ui segment">