From: Anton Khorev Date: Tue, 17 Dec 2024 00:34:14 +0000 (+0300) Subject: Show 'api offline' message on new note page X-Git-Tag: live~77^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/ca4ee6faa9378e7610356e36cbd4931a2657eeed Show 'api offline' message on new note page --- diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index c47a3abfb..c40e776b4 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -44,5 +44,7 @@ class NotesController < ApplicationController render :template => "browse/not_found", :status => :not_found end - def new; end + def new + render :action => :new_readonly if api_status != "online" + end end diff --git a/app/views/notes/new_readonly.html.erb b/app/views/notes/new_readonly.html.erb new file mode 100644 index 000000000..033530c71 --- /dev/null +++ b/app/views/notes/new_readonly.html.erb @@ -0,0 +1,7 @@ +<% set_title(t(".title")) %> + +<%= render "sidebar_header", :title => t(".title") %> + +
+

<%= t(".warning") %>

+
diff --git a/config/locales/en.yml b/config/locales/en.yml index 94fc77247..a6fee55f4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3032,6 +3032,9 @@ en: anonymous_warning_sign_up: "sign up" advice: "Your note is public and may be used to update the map, so don't enter personal information, or information from copyrighted maps or directory listings." add: Add Note + new_readonly: + title: "New Note" + warning: "New notes cannot be created because the OpenStreetMap API is currently in read-only mode." notes_paging_nav: showing_page: "Page %{page}" next: "Next" diff --git a/test/system/create_note_test.rb b/test/system/create_note_test.rb new file mode 100644 index 000000000..ccb2ed32f --- /dev/null +++ b/test/system/create_note_test.rb @@ -0,0 +1,23 @@ +require "application_system_test_case" + +class CreateNoteTest < ApplicationSystemTestCase + test "can create note" do + visit new_note_path(:anchor => "map=18/0/0") + + assert_button "Add Note", :disabled => true + + fill_in "text", :with => "Some newly added note description" + click_on "Add Note" + + assert_content "Unresolved note ##{Note.last.id}" + assert_content "Some newly added note description" + end + + test "cannot create note when api is readonly" do + with_settings(:status => "api_readonly") do + visit new_note_path(:anchor => "map=18/0/0") + + assert_no_button "Add Note", :disabled => true + end + end +end