]> git.openstreetmap.org Git - rails.git/commitdiff
Use offline flash partial on edit page
authorAnton Khorev <tony29@yandex.ru>
Mon, 16 Dec 2024 15:49:10 +0000 (18:49 +0300)
committerAnton Khorev <tony29@yandex.ru>
Wed, 18 Dec 2024 15:59:49 +0000 (18:59 +0300)
app/controllers/site_controller.rb
app/views/site/_not_public_flash.erb [new file with mode: 0644]
app/views/site/edit.html.erb
config/locales/en.yml

index 58f0a11c9340bbd796082622f3d6dcdbe852d13d..13a97a6640f052cb64a2828cb743dd066a0c1876 100644 (file)
@@ -107,6 +107,14 @@ class SiteController < ApplicationController
     rescue ActiveRecord::RecordNotFound
       # don't try and derive a location from a missing/deleted object
     end
+
+    if api_status != "online"
+      flash.now[:warning] = { :partial => "layouts/offline_flash" }
+    elsif current_user && !current_user.data_public?
+      flash.now[:warning] = { :partial => "not_public_flash" }
+    else
+      @enable_editor = true
+    end
   end
 
   def copyright
diff --git a/app/views/site/_not_public_flash.erb b/app/views/site/_not_public_flash.erb
new file mode 100644 (file)
index 0000000..bcd010f
--- /dev/null
@@ -0,0 +1,3 @@
+<p><%= t ".not_public" %></p>
+<p><%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %></p>
+<p><%= t ".anon_edits_html", :link => link_to(t(".anon_edits_link_text"), t(".anon_edits_link")) %></p>
index 1eb73382279b638866d08af61e302681e5cff858..6d463df7848dbd52138ebad1c12640d2671d61af 100644 (file)
@@ -1,17 +1,5 @@
 <% content_for :content do %>
-  <% if Settings.status == "database_offline" or Settings.status == "api_offline" %>
-    <div class="alert alert-warning text-center">
-        <p class="my-2"><%= t "layouts.osm_offline" %></p>
-    </div>
-  <% elsif Settings.status == "database_readonly" or Settings.status == "api_readonly" %>
-    <div class="alert alert-warning text-center">
-        <p class="my-2"><%= t "layouts.osm_read_only" %></p>
-    </div>
-  <% elsif !current_user.data_public? %>
-    <p><%= t ".not_public" %></p>
-    <p><%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %></p>
-    <p><%= t ".anon_edits_html", :link => link_to(t(".anon_edits_link_text"), t(".anon_edits_link")) %></p>
-  <% else %>
+  <% if @enable_editor %>
     <%= render :partial => preferred_editor %>
   <% end %>
 <% end %>
index 0e7946c0faa89954dd1c185023296859fbcc4274..53b4217a10c0913a59e3c2d906259b47fac4fcc8 100644 (file)
@@ -2217,13 +2217,14 @@ en:
         license_url: "https://openstreetmap.org/copyright"
         project_url: "https://openstreetmap.org"
       remote_failed: "Editing failed - make sure JOSM or Merkaartor is loaded and the remote control option is enabled"
-    edit:
+    not_public_flash:
       not_public: "You have not set your edits to be public."
       not_public_description_html: "You can no longer edit the map unless you do so. You can set your edits as public from your %{user_page}."
       user_page_link: user page
       anon_edits_html: "(%{link})"
       anon_edits_link: "https://wiki.openstreetmap.org/wiki/Disabling_anonymous_edits"
       anon_edits_link_text: "Find out why this is the case."
+    edit:
       id_not_configured: "iD has not been configured"
     export:
       title: "Export"