loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve issue history dialog and make poster can delete their own history (#27323)

Fix #27313 (see the comment)

And some UI improvements:

### Before


![image](https://github.com/go-gitea/gitea/assets/2114189/420a314d-8f34-4e30-a557-f41cf4f0d2f2)


![image](https://github.com/go-gitea/gitea/assets/2114189/60ca0be4-b55e-4e65-be73-fd53e0d4fc36)


### After


![image](https://github.com/go-gitea/gitea/assets/2114189/d354f815-5a0c-4e63-8d59-d03ed344dbea)


![image](https://github.com/go-gitea/gitea/assets/2114189/6ef437a4-aa6f-4917-a260-00625ee71e79)


![image](https://github.com/go-gitea/gitea/assets/2114189/9d88a36c-616b-4dc9-8c6b-76adaad8acf6)

authored by

wxiaoguang and committed by
GitHub
72c68177 7ea2a910

+21 -9
+9 -5
routers/web/repo/issue_content_history.go
··· 11 11 12 12 "code.gitea.io/gitea/models/avatars" 13 13 issues_model "code.gitea.io/gitea/models/issues" 14 - "code.gitea.io/gitea/models/unit" 15 14 "code.gitea.io/gitea/modules/context" 16 15 "code.gitea.io/gitea/modules/log" 17 16 "code.gitea.io/gitea/modules/setting" ··· 91 90 // Admins or owners can always delete history revisions. Normal users can only delete own history revisions. 92 91 func canSoftDeleteContentHistory(ctx *context.Context, issue *issues_model.Issue, comment *issues_model.Comment, 93 92 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) { 97 96 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 99 103 if comment == nil { 100 104 // the issue poster or the history poster can soft-delete 101 105 canSoftDelete = ctx.Doer.ID == issue.PosterID || ctx.Doer.ID == history.PosterID
+6 -1
web_src/css/modules/modal.css
··· 3 3 width: fit-content; 4 4 } 5 5 6 - .ui.modal.g-modal-confirm > .inside.close { 6 + .ui.modal.g-modal-confirm > .inside.close.icon { 7 7 padding: 0; 8 8 width: 1em; 9 9 height: 1em; 10 10 top: 1.2em; 11 + } 12 + 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); 11 16 } 12 17 13 18 .ui.modal > .header {
+2
web_src/css/repo.css
··· 2578 2578 2579 2579 .comment-diff-data { 2580 2580 background: var(--color-code-bg); 2581 + min-height: 12em; 2581 2582 max-height: calc(100vh - 10.5rem); 2582 2583 overflow-y: auto; 2583 2584 } 2584 2585 2585 2586 .comment-diff-data pre { 2586 2587 line-height: 18px; 2588 + margin: 1em; 2587 2589 white-space: pre-wrap; 2588 2590 word-break: break-all; 2589 2591 overflow-wrap: break-word;
+4 -3
web_src/js/features/repo-issue-content.js
··· 17 17 ${svg('octicon-x', 16, 'close icon inside')} 18 18 <div class="header gt-df gt-ac gt-sb"> 19 19 <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')} 22 23 <div class="menu"> 23 24 <div class="item red text" data-option-item="delete">${i18nTextDeleteFromHistory}</div> 24 25 </div> 25 26 </div> 26 27 </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> 28 29 </div>`); 29 30 $dialog.appendTo($('body')); 30 31 $dialog.find('.dialog-header-options').dropdown({