Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ trait GistControllerBase extends ControllerBase {
redirect(s"/gist/${userName}/${repoName}")
})

get("/gist/:userName/:repoName/delete")(editorOnly {
post("/gist/:userName/:repoName/delete")(editorOnly {
val userName = params("userName")
val repoName = params("repoName")

Expand Down
7 changes: 0 additions & 7 deletions src/main/twirl/gitbucket/gist/detail.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,4 @@
</div>
</div>
</div>
<script>
$(function(){
$('#delete').click(function(){
return confirm('Are you positive you want to delete this Gist?');
});
});
</script>
}
11 changes: 8 additions & 3 deletions src/main/twirl/gitbucket/gist/edit.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ <h1 style="margin: 0px;">New snippet</h1>
<span class="label label-warning">Private</span>
}
<div class="pull-right">
<a href="@context.path/gist/@gist.get.userName/@gist.get.repositoryName/delete" class="btn btn-danger" id="delete">Delete</a>
<a href="javascript:void(0);" class="btn btn-danger" id="delete">Delete</a>
<form id="delete-form" method="post" action="@context.path/gist/@gist.get.userName/@gist.get.repositoryName/delete">
</form>
</div>
<div class="muted" style="margin-left: 30px; font-size: 80%;">
Created at @gist.get.registeredDate
Expand Down Expand Up @@ -121,8 +123,11 @@ <h1 style="margin: 0px;">New snippet</h1>
return true;
});

$('#delete').click(function(){
return confirm('Are you positive you want to delete this Gist?');
$('#delete').click(function(e){
e.preventDefault();
if(confirm('Are you positive you want to delete this Gist?')){
$('#delete-form').submit();
}
});

function displayError(message){
Expand Down
12 changes: 11 additions & 1 deletion src/main/twirl/gitbucket/gist/header.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
<div class="pull-right">
@if(editable){
<a href="@context.path/gist/@gist.userName/@gist.repositoryName/edit" class="btn btn-default">Edit</a>
<a href="@context.path/gist/@gist.userName/@gist.repositoryName/delete" class="btn btn-danger" id="delete">Delete</a>
<a href="javascript:void(0);" class="btn btn-danger" id="delete">Delete</a>
<form id="delete-form" method="post" action="@context.path/gist/@gist.userName/@gist.repositoryName/delete">
</form>
}
@if(gist.originUserName.isEmpty){
@if(context.loginAccount.isEmpty){
Expand Down Expand Up @@ -45,5 +47,13 @@
$('#fork-form').submit();
});
}
@if(editable){
$('#delete').click(function(e){
e.preventDefault();
if(confirm('Are you positive you want to delete this Gist?')){
$('#delete-form').submit();
}
});
}
});
</script>
Loading