summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--routers/repo/editor.go1
-rw-r--r--templates/repo/editor/edit.tmpl1
-rw-r--r--web_src/js/index.js4
3 files changed, 5 insertions, 1 deletions
diff --git a/routers/repo/editor.go b/routers/repo/editor.go
index f91ce1b462..6a3f379f6a 100644
--- a/routers/repo/editor.go
+++ b/routers/repo/editor.go
@@ -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
diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl
index af65813b33..db012728e7 100644
--- a/templates/repo/editor/edit.tmpl
+++ b/templates/repo/editor/edit.tmpl
@@ -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}}">
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 810493a7d6..a8965a437f 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -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({