]> git.openstreetmap.org Git - rails.git/commitdiff
Show blocked api response when reopening notes
authorAnton Khorev <tony29@yandex.ru>
Sun, 7 Jan 2024 16:19:57 +0000 (19:19 +0300)
committerAnton Khorev <tony29@yandex.ru>
Tue, 16 Jan 2024 23:15:14 +0000 (02:15 +0300)
app/assets/javascripts/index/note.js
app/views/notes/show.html.erb
test/system/note_comments_test.rb

index 0c0be716b4bba5e5c46d1ef0537e9fd422a55eef..15fedb1d113b52bbd8d402427af3d38c8c7f23ed 100644 (file)
@@ -83,7 +83,7 @@ OSM.Note = function (map) {
   }
 
   function updateButtons(form) {
-    $(form.close).prop("disabled", false);
+    $(form).find("input[type=submit]").prop("disabled", false);
     if ($(form.text).val() === "") {
       $(form.close).val($(form.close).data("defaultActionText"));
       $(form.comment).prop("disabled", true);
index 3a1224676e47b7e5afb0c8deba255b48a32a65a1..a7baccf856dec921056d6c40fd8da7a8c75ff685 100644 (file)
@@ -75,6 +75,8 @@
   <% else %>
     <form class="mb-3" action="#">
       <input type="hidden" name="text" value="" autocomplete="off">
+      <div id="comment-error" class="alert alert-danger p-2 mb-3" hidden>
+      </div>
       <div class="btn-wrapper">
         <% if @note.status != "hidden" and current_user and current_user.moderator? -%>
           <input type="submit" name="hide" value="<%= t(".hide") %>" class="btn btn-light" data-method="DELETE" data-url="<%= api_note_url(@note, "json") %>">
index a629dfce3ca9f0e7f2ea09ef19c133880c917860..7c830cc373c5d4955f42888216a52b1c5e672942 100644 (file)
@@ -103,4 +103,26 @@ class NoteCommentsTest < ApplicationSystemTestCase
       assert_button "Comment", :disabled => true
     end
   end
+
+  test "can't reactivate a note when blocked" do
+    note = create(:note_with_comments, :closed)
+    user = create(:user)
+    sign_in_as(user)
+    visit note_path(note)
+    create(:user_block, :user => user)
+
+    within_sidebar do
+      assert_no_text "Unresolved note"
+      assert_text "Resolved note"
+      assert_no_text "Your access to the API has been blocked"
+      assert_button "Reactivate", :disabled => false
+
+      click_on "Reactivate"
+
+      assert_no_text "Unresolved note"
+      assert_text "Resolved note"
+      assert_text "Your access to the API has been blocked"
+      assert_button "Reactivate", :disabled => false
+    end
+  end
 end