Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions routers/web/repo/issue_content_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,15 @@ func canSoftDeleteContentHistory(ctx *context.Context, issue *issues_model.Issue
history *issues_model.ContentHistory,
) bool {
canSoftDelete := false
if ctx.Repo.IsOwner() {
// CanWrite means the doer can manage the issue/PR list
if ctx.Repo.IsOwner() || (!issue.IsPull && ctx.Repo.CanWrite(unit.TypeIssues)) || (issue.IsPull && ctx.Repo.CanWrite(unit.TypePullRequests)) {
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
canSoftDelete = true
} else if ctx.Repo.CanWrite(unit.TypeIssues) {
} else {
// for read-only users, they could still post issues or comments,
// they should be able to delete the history related to their own issue/comment, a case is:
// 1. the user posts some sensitive data
// 2. then the repo owner edits the post but didn't remove the sensitive data
// 3. the poster wants to delete the edited history revision
if comment == nil {
// the issue poster or the history poster can soft-delete
canSoftDelete = ctx.Doer.ID == issue.PosterID || ctx.Doer.ID == history.PosterID
Expand Down
7 changes: 6 additions & 1 deletion web_src/css/modules/modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
width: fit-content;
}

.ui.modal.g-modal-confirm > .inside.close {
.ui.modal.g-modal-confirm > .inside.close.icon {
padding: 0;
width: 1em;
height: 1em;
top: 1.2em;
}

.ui.modal > .close.icon[height="16"] {
top: 0.7em; /* fomantic uses absolute layout, so if we have special icon size, it needs this trick to align vertically */
color: var(--color-text-dark);
}

.ui.modal > .header {
/* can't use display:flex, because some headers have space-separated elements, eg: delete branch modal */
color: var(--color-text-dark);
Expand Down
2 changes: 2 additions & 0 deletions web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -2578,12 +2578,14 @@ tbody.commit-list {

.comment-diff-data {
background: var(--color-code-bg);
min-height: 12em;
max-height: calc(100vh - 10.5rem);
overflow-y: auto;
}

.comment-diff-data pre {
line-height: 18px;
margin: 1em;
white-space: pre-wrap;
word-break: break-all;
overflow-wrap: break-word;
Expand Down
7 changes: 4 additions & 3 deletions web_src/js/features/repo-issue-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH
${svg('octicon-x', 16, 'close icon inside')}
<div class="header gt-df gt-ac gt-sb">
<div>${itemTitleHtml}</div>
<div class="ui dropdown dialog-header-options gt-df gt-ac gt-mr-5 gt-hidden">
${i18nTextOptions}${svg('octicon-triangle-down', 14, 'dropdown icon')}
<div class="ui dropdown dialog-header-options gt-mr-5 gt-hidden">
${i18nTextOptions}
${svg('octicon-triangle-down', 14, 'dropdown icon')}
<div class="menu">
<div class="item red text" data-option-item="delete">${i18nTextDeleteFromHistory}</div>
</div>
</div>
</div>
<div class="comment-diff-data gt-text-left gt-p-3 is-loading"></div>
<div class="comment-diff-data is-loading"></div>
</div>`);
$dialog.appendTo($('body'));
$dialog.find('.dialog-header-options').dropdown({
Expand Down
Loading