mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
(refs #103) Add issue comment deletion.
This commit is contained in:
@@ -155,6 +155,16 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ajaxPost("/:owner/:repository/issue_comments/delete/:id")(readableUsersOnly { repository =>
|
||||||
|
defining(repository.owner, repository.name){ case (owner, name) =>
|
||||||
|
getComment(owner, name, params("id")).map { comment =>
|
||||||
|
if(isEditable(owner, name, comment.commentedUserName)){
|
||||||
|
Ok(deleteComment(comment.commentId))
|
||||||
|
} else Unauthorized
|
||||||
|
} getOrElse NotFound
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly { repository =>
|
ajaxGet("/:owner/:repository/issues/_data/:id")(readableUsersOnly { repository =>
|
||||||
getIssue(repository.owner, repository.name, params("id")) map { x =>
|
getIssue(repository.owner, repository.name, params("id")) map { x =>
|
||||||
if(isEditable(x.userName, x.repositoryName, x.openedUserName)){
|
if(isEditable(x.userName, x.repositoryName, x.openedUserName)){
|
||||||
|
|||||||
@@ -249,6 +249,9 @@ trait IssuesService {
|
|||||||
}
|
}
|
||||||
.update (content, currentDate)
|
.update (content, currentDate)
|
||||||
|
|
||||||
|
def deleteComment(commentId: Int) =
|
||||||
|
IssueComments filter (_.byPrimaryKey(commentId)) delete
|
||||||
|
|
||||||
def updateClosed(owner: String, repository: String, issueId: Int, closed: Boolean) =
|
def updateClosed(owner: String, repository: String, issueId: Int, closed: Boolean) =
|
||||||
Issues
|
Issues
|
||||||
.filter (_.byPrimaryKey(owner, repository, issueId))
|
.filter (_.byPrimaryKey(owner, repository, issueId))
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
@datetime(comment.registeredDate)
|
@datetime(comment.registeredDate)
|
||||||
@if(comment.action != "commit" && comment.action != "merge" && (hasWritePermission || loginAccount.map(_.userName == comment.commentedUserName).getOrElse(false))){
|
@if(comment.action != "commit" && comment.action != "merge" && (hasWritePermission || loginAccount.map(_.userName == comment.commentedUserName).getOrElse(false))){
|
||||||
<a href="#" data-comment-id="@comment.commentId"><i class="icon-pencil"></i></a>
|
<a href="#" data-comment-id="@comment.commentId"><i class="icon-pencil"></i></a>
|
||||||
|
<a href="#" data-comment-id="@comment.commentId"><i class="icon-remove-circle"></i></a>
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,5 +70,18 @@ $(function(){
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
$('i.icon-remove-circle').click(function(){
|
||||||
|
if(confirm('Are you sure you want to delete this?')) {
|
||||||
|
var id = $(this).closest('a').data('comment-id');
|
||||||
|
$.post('@url(repository)/issue_comments/delete/' + id,
|
||||||
|
function(data){
|
||||||
|
if(data > 0) {
|
||||||
|
$('#comment-' + id).prev('div.issue-avatar-image').remove();
|
||||||
|
$('#comment-' + id).remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user