Skip to content

Commit

Permalink
Do not disable commit changes button on repost (#12644)
Browse files Browse the repository at this point in the history
If the user has pressed commit changes and the post has failed - do not disable
the commit changes button.

Fix #12072

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath authored Aug 29, 2020
1 parent 9abc16a commit 17fbbe9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions routers/repo/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
}

ctx.Data["PageIsEdit"] = true
ctx.Data["PageHasPosted"] = true
ctx.Data["IsNewFile"] = isNewFile
ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireSimpleMDE"] = true
Expand Down
1 change: 1 addition & 0 deletions templates/repo/editor/edit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<form class="ui edit form" method="post">
{{.CsrfTokenHtml}}
<input type="hidden" name="last_commit" value="{{.last_commit}}">
<input type="hidden" name="page_has_posted" value="{{.PageHasPosted}}">
<div class="ui secondary menu">
<div class="fitted item treepath">
<div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}">
Expand Down
4 changes: 3 additions & 1 deletion web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,9 @@ async function initEditor() {
const dirtyFileClass = 'dirty-file';

// Disabling the button at the start
$commitButton.prop('disabled', true);
if ($('input[name="page_has_posted"]').val() !== 'true') {
$commitButton.prop('disabled', true);
}

// Registering a custom listener for the file path and the file content
$editForm.areYouSure({
Expand Down

0 comments on commit 17fbbe9

Please sign in to comment.