mirror of
https://github.com/go-gitea/gitea.git
synced 2025-02-21 11:22:26 +08:00
Hide/disable unusable UI elements when a repository is archived (#33459)
And by the way, remove some jQuery code
This commit is contained in:
parent
0e8738b4b6
commit
1ab5938e82
@ -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
|
// 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) {
|
func CanMarkConversation(ctx context.Context, issue *Issue, doer *user_model.User) (permResult bool, err error) {
|
||||||
if doer == nil || issue == nil {
|
if doer == nil || issue == nil {
|
||||||
return false, fmt.Errorf("issue or doer is 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 doer.ID != issue.PosterID {
|
||||||
if err = issue.LoadRepo(ctx); err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
p, err := access_model.GetUserRepoPermission(ctx, issue.Repo, doer)
|
p, err := access_model.GetUserRepoPermission(ctx, issue.Repo, doer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div class="diff-detail-actions">
|
<div class="diff-detail-actions">
|
||||||
{{if and .PageIsPullFiles $.SignedUserID (not .IsArchived) (not .DiffNotAvailable)}}
|
{{if and .PageIsPullFiles $.SignedUserID (not .DiffNotAvailable)}}
|
||||||
<div class="not-mobile tw-flex tw-items-center tw-flex-col tw-whitespace-nowrap tw-mr-1">
|
<div class="not-mobile tw-flex tw-items-center tw-flex-col tw-whitespace-nowrap tw-mr-1">
|
||||||
<label for="viewed-files-summary" id="viewed-files-summary-label" data-text-changed-template="{{ctx.Locale.Tr "repo.pulls.viewed_files_label"}}">
|
<label for="viewed-files-summary" id="viewed-files-summary-label" data-text-changed-template="{{ctx.Locale.Tr "repo.pulls.viewed_files_label"}}">
|
||||||
{{ctx.Locale.Tr "repo.pulls.viewed_files_label" .Diff.NumViewedFiles .Diff.NumFiles}}
|
{{ctx.Locale.Tr "repo.pulls.viewed_files_label" .Diff.NumViewedFiles .Diff.NumFiles}}
|
||||||
@ -42,7 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}}
|
{{if and .PageIsPullFiles $.SignedUserID}}
|
||||||
{{template "repo/diff/new_review" .}}
|
{{template "repo/diff/new_review" .}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
@ -105,7 +105,7 @@
|
|||||||
{{$isCsv := (call $.IsCsvFile $file)}}
|
{{$isCsv := (call $.IsCsvFile $file)}}
|
||||||
{{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv)}}
|
{{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv)}}
|
||||||
{{$isExpandable := or (gt $file.Addition 0) (gt $file.Deletion 0) $file.IsBin}}
|
{{$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}}
|
||||||
<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}} tw-mt-0" id="diff-{{$file.NameHash}}" data-old-filename="{{$file.OldName}}" data-new-filename="{{$file.Name}}" {{if or ($file.ShouldBeHidden) (not $isExpandable)}}data-folded="true"{{end}}>
|
<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}} tw-mt-0" id="diff-{{$file.NameHash}}" data-old-filename="{{$file.OldName}}" data-new-filename="{{$file.Name}}" {{if or ($file.ShouldBeHidden) (not $isExpandable)}}data-folded="true"{{end}}>
|
||||||
<h4 class="diff-file-header sticky-2nd-row ui top attached header">
|
<h4 class="diff-file-header sticky-2nd-row ui top attached header">
|
||||||
<div class="diff-file-name tw-flex tw-flex-1 tw-items-center tw-gap-1 tw-flex-wrap">
|
<div class="diff-file-name tw-flex tw-flex-1 tw-items-center tw-gap-1 tw-flex-wrap">
|
||||||
|
@ -48,7 +48,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{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))}}
|
{{template "repo/issue/view_content/context_menu" dict "item" . "delete" true "issue" false "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,56 +1,59 @@
|
|||||||
<div id="review-box">
|
<div id="review-box" {{if $.Repository.IsArchived}}data-tooltip-content="{{ctx.Locale.Tr "repo.archive.pull.nocomment"}}"{{end}}>
|
||||||
<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}}>
|
<button class="ui tiny primary button tw-pr-1 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}}
|
||||||
|
{{if $.Repository.IsArchived}}disabled{{end}}
|
||||||
|
>
|
||||||
{{ctx.Locale.Tr "repo.diff.review"}}
|
{{ctx.Locale.Tr "repo.diff.review"}}
|
||||||
<span class="ui small label review-comments-counter" data-pending-comment-number="{{.PendingCodeCommentNumber}}">{{.PendingCodeCommentNumber}}</span>
|
<span class="ui small label review-comments-counter" data-pending-comment-number="{{.PendingCodeCommentNumber}}">{{.PendingCodeCommentNumber}}</span>
|
||||||
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
||||||
</button>
|
</button>
|
||||||
{{if $.IsShowingAllCommits}}
|
|
||||||
<div class="review-box-panel tippy-target">
|
|
||||||
<div class="ui segment">
|
|
||||||
<form class="ui form form-fetch-action" action="{{.Link}}/reviews/submit" method="post">
|
|
||||||
{{.CsrfTokenHtml}}
|
|
||||||
<input type="hidden" name="commit_id" value="{{.AfterCommitID}}">
|
|
||||||
<div class="field tw-flex tw-items-center">
|
|
||||||
<div class="tw-flex-1">{{ctx.Locale.Tr "repo.diff.review.header"}}</div>
|
|
||||||
<a class="muted close">{{svg "octicon-x" 16}}</a>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
{{template "shared/combomarkdowneditor" (dict
|
|
||||||
"MarkdownPreviewInRepo" $.Repository
|
|
||||||
"MarkdownPreviewMode" "comment"
|
|
||||||
"TextareaName" "content"
|
|
||||||
"TextareaPlaceholder" (ctx.Locale.Tr "repo.diff.review.placeholder")
|
|
||||||
"DropzoneParentContainer" "form"
|
|
||||||
)}}
|
|
||||||
</div>
|
|
||||||
{{if .IsAttachmentEnabled}}
|
|
||||||
<div class="field">
|
|
||||||
{{template "repo/upload" .}}
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
<div class="divider"></div>
|
|
||||||
{{$showSelfTooltip := (and $.IsSigned ($.Issue.IsPoster $.SignedUser.ID))}}
|
|
||||||
{{if not $.Issue.IsClosed}}
|
|
||||||
{{if $showSelfTooltip}}
|
|
||||||
<span class="tw-inline-block" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.review.self_approve"}}">
|
|
||||||
<button type="submit" name="type" value="approve" disabled class="ui submit primary tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.approve"}}</button>
|
|
||||||
</span>
|
|
||||||
{{else}}
|
|
||||||
<button type="submit" name="type" value="approve" class="ui submit primary tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.approve"}}</button>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
<button type="submit" name="type" value="comment" class="ui submit tiny basic button btn-submit">{{ctx.Locale.Tr "repo.diff.review.comment"}}</button>
|
|
||||||
{{if not $.Issue.IsClosed}}
|
|
||||||
{{if $showSelfTooltip}}
|
|
||||||
<span class="tw-inline-block" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.review.self_reject"}}">
|
|
||||||
<button type="submit" name="type" value="reject" disabled class="ui submit red tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.reject"}}</button>
|
|
||||||
</span>
|
|
||||||
{{else}}
|
|
||||||
<button type="submit" name="type" value="reject" class="ui submit red tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.reject"}}</button>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
</div>
|
||||||
|
{{if $.IsShowingAllCommits}}
|
||||||
|
<div class="review-box-panel tippy-target">
|
||||||
|
<div class="ui segment">
|
||||||
|
<form class="ui form form-fetch-action" action="{{.Link}}/reviews/submit" method="post">
|
||||||
|
{{.CsrfTokenHtml}}
|
||||||
|
<input type="hidden" name="commit_id" value="{{.AfterCommitID}}">
|
||||||
|
<div class="field tw-flex tw-items-center">
|
||||||
|
<div class="tw-flex-1">{{ctx.Locale.Tr "repo.diff.review.header"}}</div>
|
||||||
|
<a class="muted close">{{svg "octicon-x" 16}}</a>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
{{template "shared/combomarkdowneditor" (dict
|
||||||
|
"MarkdownPreviewInRepo" $.Repository
|
||||||
|
"MarkdownPreviewMode" "comment"
|
||||||
|
"TextareaName" "content"
|
||||||
|
"TextareaPlaceholder" (ctx.Locale.Tr "repo.diff.review.placeholder")
|
||||||
|
"DropzoneParentContainer" "form"
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
{{if .IsAttachmentEnabled}}
|
||||||
|
<div class="field">
|
||||||
|
{{template "repo/upload" .}}
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
<div class="divider"></div>
|
||||||
|
{{$showSelfTooltip := (and $.IsSigned ($.Issue.IsPoster $.SignedUser.ID))}}
|
||||||
|
{{if not $.Issue.IsClosed}}
|
||||||
|
{{if $showSelfTooltip}}
|
||||||
|
<span class="tw-inline-block" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.review.self_approve"}}">
|
||||||
|
<button type="submit" name="type" value="approve" disabled class="ui submit primary tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.approve"}}</button>
|
||||||
|
</span>
|
||||||
|
{{else}}
|
||||||
|
<button type="submit" name="type" value="approve" class="ui submit primary tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.approve"}}</button>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
<button type="submit" name="type" value="comment" class="ui submit tiny basic button btn-submit">{{ctx.Locale.Tr "repo.diff.review.comment"}}</button>
|
||||||
|
{{if not $.Issue.IsClosed}}
|
||||||
|
{{if $showSelfTooltip}}
|
||||||
|
<span class="tw-inline-block" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.review.self_reject"}}">
|
||||||
|
<button type="submit" name="type" value="reject" disabled class="ui submit red tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.reject"}}</button>
|
||||||
|
</span>
|
||||||
|
{{else}}
|
||||||
|
<button type="submit" name="type" value="reject" class="ui submit red tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.reject"}}</button>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
@ -421,13 +421,11 @@ export function initRepoPullRequestReview() {
|
|||||||
// The following part is only for diff views
|
// The following part is only for diff views
|
||||||
if (!$('.repository.pull.diff').length) return;
|
if (!$('.repository.pull.diff').length) return;
|
||||||
|
|
||||||
const $reviewBtn = $('.js-btn-review');
|
const elReviewBtn = document.querySelector('.js-btn-review');
|
||||||
const $panel = $reviewBtn.parent().find('.review-box-panel');
|
const elReviewPanel = document.querySelector('.review-box-panel.tippy-target');
|
||||||
const $closeBtn = $panel.find('.close');
|
if (elReviewBtn && elReviewPanel) {
|
||||||
|
const tippy = createTippy(elReviewBtn, {
|
||||||
if ($reviewBtn.length && $panel.length) {
|
content: elReviewPanel,
|
||||||
const tippy = createTippy($reviewBtn[0], {
|
|
||||||
content: $panel[0],
|
|
||||||
theme: 'default',
|
theme: 'default',
|
||||||
placement: 'bottom',
|
placement: 'bottom',
|
||||||
trigger: 'click',
|
trigger: 'click',
|
||||||
@ -435,11 +433,7 @@ export function initRepoPullRequestReview() {
|
|||||||
interactive: true,
|
interactive: true,
|
||||||
hideOnClick: true,
|
hideOnClick: true,
|
||||||
});
|
});
|
||||||
|
elReviewPanel.querySelector('.close').addEventListener('click', () => tippy.hide());
|
||||||
$closeBtn.on('click', (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
tippy.hide();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addDelegatedEventListener(document, 'click', '.add-code-comment', async (el, e) => {
|
addDelegatedEventListener(document, 'click', '.add-code-comment', async (el, e) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user