diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl
index 28b7bfc89c..c7361663b2 100644
--- a/templates/repo/commit_page.tmpl
+++ b/templates/repo/commit_page.tmpl
@@ -278,9 +278,9 @@
{{.NoteCommit.Author.Name}}
{{end}}
{{DateUtils.TimeSince .NoteCommit.Author.When}}
- {{if or ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}
+ {{if and ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}
-
+
diff --git a/tests/integration/repo_git_note_test.go b/tests/integration/repo_git_note_test.go
index 9c2423c892..6ad57c81b0 100644
--- a/tests/integration/repo_git_note_test.go
+++ b/tests/integration/repo_git_note_test.go
@@ -5,6 +5,8 @@ import (
"net/url"
"testing"
+ "code.gitea.io/gitea/tests"
+
"github.com/stretchr/testify/assert"
)
@@ -42,3 +44,29 @@ func TestRepoModifyGitNotes(t *testing.T) {
})
})
}
+
+func TestRepoGitNotesButtonsVisible(t *testing.T) {
+ onGiteaRun(t, func(*testing.T, *url.URL) {
+ t.Run("With Permission", func(t *testing.T) {
+ defer tests.PrintCurrentTest(t)()
+
+ session := loginUser(t, "user2")
+
+ req := NewRequest(t, "GET", "/user2/repo1/commit/65f1bf27bc3bf70f64657658635e66094edbcb4d")
+ resp := session.MakeRequest(t, req, http.StatusOK)
+
+ assert.Contains(t, resp.Body.String(), "id=\"commit-notes-edit-button\"")
+ assert.Contains(t, resp.Body.String(), "data-modal=\"#delete-note-modal\"")
+ })
+
+ t.Run("Without Permission", func(t *testing.T) {
+ defer tests.PrintCurrentTest(t)()
+
+ req := NewRequest(t, "GET", "/user2/repo1/commit/65f1bf27bc3bf70f64657658635e66094edbcb4d")
+ resp := MakeRequest(t, req, http.StatusOK)
+
+ assert.NotContains(t, resp.Body.String(), "id=\"commit-notes-edit-button\"")
+ assert.NotContains(t, resp.Body.String(), "data-modal=\"#delete-note-modal\"")
+ })
+ })
+}