Skip to content

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

routers/web/repo/issue_content_history.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
"code.gitea.io/gitea/models/avatars"
1313
issues_model "code.gitea.io/gitea/models/issues"
14-
"code.gitea.io/gitea/models/unit"
1514
"code.gitea.io/gitea/modules/context"
1615
"code.gitea.io/gitea/modules/log"
1716
"code.gitea.io/gitea/modules/setting"
@@ -91,11 +90,16 @@ func GetContentHistoryList(ctx *context.Context) {
9190
// Admins or owners can always delete history revisions. Normal users can only delete own history revisions.
9291
func canSoftDeleteContentHistory(ctx *context.Context, issue *issues_model.Issue, comment *issues_model.Comment,
9392
history *issues_model.ContentHistory,
94-
) bool {
95-
canSoftDelete := false
96-
if ctx.Repo.IsOwner() {
93+
) (canSoftDelete bool) {
94+
// CanWrite means the doer can manage the issue/PR list
95+
if ctx.Repo.IsOwner() || ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) {
9796
canSoftDelete = true
98-
} else if ctx.Repo.CanWrite(unit.TypeIssues) {
97+
} else {
98+
// for read-only users, they could still post issues or comments,
99+
// they should be able to delete the history related to their own issue/comment, a case is:
100+
// 1. the user posts some sensitive data
101+
// 2. then the repo owner edits the post but didn't remove the sensitive data
102+
// 3. the poster wants to delete the edited history revision
99103
if comment == nil {
100104
// the issue poster or the history poster can soft-delete
101105
canSoftDelete = ctx.Doer.ID == issue.PosterID || ctx.Doer.ID == history.PosterID

web_src/css/modules/modal.css

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
width: fit-content;
44
}
55

6-
.ui.modal.g-modal-confirm > .inside.close {
6+
.ui.modal.g-modal-confirm > .inside.close.icon {
77
padding: 0;
88
width: 1em;
99
height: 1em;
1010
top: 1.2em;
1111
}
1212

13+
.ui.modal > .close.icon[height="16"] {
14+
top: 0.7em; /* fomantic uses absolute layout, so if we have special icon size, it needs this trick to align vertically */
15+
color: var(--color-text-dark);
16+
}
17+
1318
.ui.modal > .header {
1419
/* can't use display:flex, because some headers have space-separated elements, eg: delete branch modal */
1520
color: var(--color-text-dark);

web_src/css/repo.css

+2
Original file line numberDiff line numberDiff line change
@@ -2578,12 +2578,14 @@ tbody.commit-list {
25782578

25792579
.comment-diff-data {
25802580
background: var(--color-code-bg);
2581+
min-height: 12em;
25812582
max-height: calc(100vh - 10.5rem);
25822583
overflow-y: auto;
25832584
}
25842585

25852586
.comment-diff-data pre {
25862587
line-height: 18px;
2588+
margin: 1em;
25872589
white-space: pre-wrap;
25882590
word-break: break-all;
25892591
overflow-wrap: break-word;

web_src/js/features/repo-issue-content.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH
1717
${svg('octicon-x', 16, 'close icon inside')}
1818
<div class="header gt-df gt-ac gt-sb">
1919
<div>${itemTitleHtml}</div>
20-
<div class="ui dropdown dialog-header-options gt-df gt-ac gt-mr-5 gt-hidden">
21-
${i18nTextOptions}${svg('octicon-triangle-down', 14, 'dropdown icon')}
20+
<div class="ui dropdown dialog-header-options gt-mr-5 gt-hidden">
21+
${i18nTextOptions}
22+
${svg('octicon-triangle-down', 14, 'dropdown icon')}
2223
<div class="menu">
2324
<div class="item red text" data-option-item="delete">${i18nTextDeleteFromHistory}</div>
2425
</div>
2526
</div>
2627
</div>
27-
<div class="comment-diff-data gt-text-left gt-p-3 is-loading"></div>
28+
<div class="comment-diff-data is-loading"></div>
2829
</div>`);
2930
$dialog.appendTo($('body'));
3031
$dialog.find('.dialog-header-options').dropdown({

0 commit comments

Comments
 (0)