Facelift offline.html and use Bootstrap classes for "notifications"

Update site_controller_test.rb

Update site_controller_test.rb

Remove whitespace

Reset Settings.status after test is done

Update test for offline page

Update site_controller.rb

Fix indentation

Update offline controller

Update offline.html.erb

Remove flash CSS classes and fix missed tests

Updated tests

Address most PR comments

Update _flash.html.erb

Update _flash.html.erb

Update edit.html.erb

Update offline.html.erb
This commit is contained in:
Dimitar 2023-01-22 12:25:42 +02:00 committed by Sky
parent 1becffcbf5
commit 318064b2a7
12 changed files with 58 additions and 70 deletions

View file

@ -1253,22 +1253,6 @@ tr.turn:hover {
display: none; display: none;
} }
/* Rules for "flash" notice boxes shown at the top of the content area */
.flash {
&.error {
background-color: #ff7070;
}
&.warning {
background-color: #ffe0cc;
}
&.notice {
background-color: #CBEEA7;
}
}
/* Rules for highlighting fields with rails validation errors */ /* Rules for highlighting fields with rails validation errors */
.formError { .formError {

View file

@ -113,7 +113,14 @@ class SiteController < ApplicationController
def export; end def export; end
def offline; end def offline
flash.now[:warning] = if Settings.status == "database_offline"
t("layouts.osm_offline")
else
t("layouts.osm_read_only")
end
render :html => nil, :layout => true
end
def preview def preview
render :html => RichText.new(params[:type], params[:text]).to_html render :html => RichText.new(params[:type], params[:text]).to_html

View file

@ -1,5 +1,5 @@
<% if flash[:error] %> <% if flash[:error] %>
<div class="flash error row mx-0 p-3 align-items-center"> <div class="alert alert-danger row mx-0 mb-0 p-3 rounded-0 align-items-center">
<div class="col-auto"> <div class="col-auto">
<picture> <picture>
<source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml" /> <source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml" />
@ -11,7 +11,7 @@
<% end %> <% end %>
<% if flash[:warning] %> <% if flash[:warning] %>
<div class="flash warning row mx-0 p-3 align-items-center"> <div class="alert alert-warning row mx-0 mb-0 p-3 rounded-0 align-items-center">
<div class="col-auto"> <div class="col-auto">
<picture> <picture>
<source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml"></source> <source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml"></source>
@ -23,7 +23,7 @@
<% end %> <% end %>
<% if flash[:notice] %> <% if flash[:notice] %>
<div class="flash notice row mx-0 p-3 align-items-center"> <div class="alert alert-success row mx-0 mb-0 p-3 rounded-0 align-items-center">
<div class="col-auto"> <div class="col-auto">
<picture> <picture>
<source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml"></source> <source srcset="<%= image_path "notice.svg" %>" type="image/svg+xml"></source>

View file

@ -1,8 +1,12 @@
<% content_for :content do %> <% content_for :content do %>
<% if Settings.status == "database_offline" or Settings.status == "api_offline" %> <% if Settings.status == "database_offline" or Settings.status == "api_offline" %>
<p><%= t "layouts.osm_offline" %></p> <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" %> <% elsif Settings.status == "database_readonly" or Settings.status == "api_readonly" %>
<p><%= t "layouts.osm_read_only" %></p> <div class="alert alert-warning text-center">
<p class="my-2"><%= t "layouts.osm_read_only" %></p>
</div>
<% elsif !current_user.data_public? %> <% elsif !current_user.data_public? %>
<p><%= t ".not_public" %></p> <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 ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %></p>

View file

@ -1,7 +0,0 @@
<% if Settings.status == "database_offline" %>
<p><%= t "layouts.osm_offline" %>
</p>
<% else %>
<p><%= t "layouts.osm_read_only" %>
</p>
<% end %>

View file

@ -60,7 +60,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
patch account_path, :params => { :user => new_attributes } patch account_path, :params => { :user => new_attributes }
assert_response :success assert_response :success
assert_template :edit assert_template :edit
assert_select ".notice", false assert_select ".alert-success", false
assert_select "form#accountForm > div > input.is-invalid#user_display_name" assert_select "form#accountForm > div > input.is-invalid#user_display_name"
# Changing name to one that exists should fail, regardless of case # Changing name to one that exists should fail, regardless of case
@ -68,7 +68,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
patch account_path, :params => { :user => new_attributes } patch account_path, :params => { :user => new_attributes }
assert_response :success assert_response :success
assert_template :edit assert_template :edit
assert_select ".notice", false assert_select ".alert-success", false
assert_select "form#accountForm > div > input.is-invalid#user_display_name" assert_select "form#accountForm > div > input.is-invalid#user_display_name"
# Changing name to one that doesn't exist should work # Changing name to one that doesn't exist should work
@ -79,7 +79,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
get edit_account_path get edit_account_path
assert_response :success assert_response :success
assert_template :edit assert_template :edit
assert_select ".notice", /^User information updated successfully/ assert_select ".alert-success", /^User information updated successfully/
assert_select "form#accountForm > div > input#user_display_name[value=?]", "new tester" assert_select "form#accountForm > div > input#user_display_name[value=?]", "new tester"
# Record the change of name # Record the change of name
@ -94,7 +94,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
end end
assert_response :success assert_response :success
assert_template :edit assert_template :edit
assert_select ".notice", false assert_select ".alert-success", false
assert_select "form#accountForm > div > input.is-invalid#user_new_email" assert_select "form#accountForm > div > input.is-invalid#user_new_email"
# Changing email to one that exists should fail, regardless of case # Changing email to one that exists should fail, regardless of case
@ -106,7 +106,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
end end
assert_response :success assert_response :success
assert_template :edit assert_template :edit
assert_select ".notice", false assert_select ".alert-success", false
assert_select "form#accountForm > div > input.is-invalid#user_new_email" assert_select "form#accountForm > div > input.is-invalid#user_new_email"
# Changing email to one that doesn't exist should work # Changing email to one that doesn't exist should work
@ -121,7 +121,7 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
get edit_account_path get edit_account_path
assert_response :success assert_response :success
assert_template :edit assert_template :edit
assert_select ".notice", /^User information updated successfully/ assert_select ".alert-success", /^User information updated successfully/
assert_select "form#accountForm > div > input#user_new_email[value=?]", user.new_email assert_select "form#accountForm > div > input#user_new_email[value=?]", user.new_email
email = ActionMailer::Base.deliveries.first email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count assert_equal 1, email.to.count

View file

@ -220,7 +220,7 @@ class MessagesControllerTest < ActionDispatch::IntegrationTest
:message => { :title => "Test Message", :body => "Test message body" }) :message => { :title => "Test Message", :body => "Test message body" })
assert_response :success assert_response :success
assert_template "new" assert_template "new"
assert_select ".error", /wait a while/ assert_select ".alert.alert-danger", /wait a while/
end end
end end
end end

View file

@ -81,7 +81,7 @@ class PasswordsControllerTest < ActionDispatch::IntegrationTest
end end
assert_response :success assert_response :success
assert_template :lost_password assert_template :lost_password
assert_select ".error", /^Could not find that email address/ assert_select ".alert.alert-danger", /^Could not find that email address/
# Test resetting using the address as recorded for a user that has an # Test resetting using the address as recorded for a user that has an
# address which is case insensitively unique # address which is case insensitively unique

View file

@ -29,8 +29,8 @@ class PreferencesControllerTest < ActionDispatch::IntegrationTest
put preferences_path, :params => { :user => user.attributes } put preferences_path, :params => { :user => user.attributes }
assert_response :success assert_response :success
assert_template :edit assert_template :edit
assert_select ".notice", false assert_select ".alert-success", false
assert_select ".error", true assert_select ".alert-danger", true
assert_select "form > div > select#user_preferred_editor > option[selected]", false assert_select "form > div > select#user_preferred_editor > option[selected]", false
# Changing to a valid editor should work # Changing to a valid editor should work
@ -40,7 +40,7 @@ class PreferencesControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to preferences_path assert_redirected_to preferences_path
follow_redirect! follow_redirect!
assert_template :show assert_template :show
assert_select ".notice", /^Preferences updated/ assert_select ".alert-success", /^Preferences updated/
assert_select "dd", "iD (in-browser editor)" assert_select "dd", "iD (in-browser editor)"
# Changing to the default editor should work # Changing to the default editor should work
@ -50,7 +50,7 @@ class PreferencesControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to preferences_path assert_redirected_to preferences_path
follow_redirect! follow_redirect!
assert_template :show assert_template :show
assert_select ".notice", /^Preferences updated/ assert_select ".alert-success", /^Preferences updated/
assert_select "dd", "Default (currently iD)" assert_select "dd", "Default (currently iD)"
end end
end end

View file

@ -26,7 +26,7 @@ class ProfilesControllerTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template :show assert_template :show
assert_select ".notice", /^Profile updated./ assert_select ".alert-success", /^Profile updated./
assert_select "div", "new description" assert_select "div", "new description"
# Changing to an uploaded image should work # Changing to an uploaded image should work
@ -37,7 +37,7 @@ class ProfilesControllerTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template :show assert_template :show
assert_select ".notice", /^Profile updated./ assert_select ".alert-success", /^Profile updated./
get edit_profile_path get edit_profile_path
assert_select "form > fieldset > div > div.col-sm-10 > div.form-check > input[name=avatar_action][checked][value=?]", "keep" assert_select "form > fieldset > div > div.col-sm-10 > div.form-check > input[name=avatar_action][checked][value=?]", "keep"
@ -48,7 +48,7 @@ class ProfilesControllerTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template :show assert_template :show
assert_select ".notice", /^Profile updated./ assert_select ".alert-success", /^Profile updated./
get edit_profile_path get edit_profile_path
assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked][value=?]", "gravatar" assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked][value=?]", "gravatar"
@ -59,7 +59,7 @@ class ProfilesControllerTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template :show assert_template :show
assert_select ".notice", /^Profile updated./ assert_select ".alert-success", /^Profile updated./
get edit_profile_path get edit_profile_path
assert_select "form > fieldset > div > div.col-sm-10 > div > input[name=avatar_action][checked]", false assert_select "form > fieldset > div > div.col-sm-10 > div > input[name=avatar_action][checked]", false
assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked]", false assert_select "form > fieldset > div > div.col-sm-10 > div > div.form-check > input[name=avatar_action][checked]", false

View file

@ -495,7 +495,7 @@ class SiteControllerTest < ActionDispatch::IntegrationTest
def test_offline def test_offline
get offline_path get offline_path
assert_response :success assert_response :success
assert_template "offline" assert_select ".alert-warning"
end end
# Test the rich text preview # Test the rich text preview

View file

@ -113,7 +113,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -125,7 +125,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -137,7 +137,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -270,7 +270,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -282,7 +282,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -294,7 +294,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -409,7 +409,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -457,7 +457,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Connection to authentication provider failed" assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false assert_select "span.username", false
end end
@ -482,7 +482,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Invalid authentication credentials" assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false assert_select "span.username", false
end end
@ -572,7 +572,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -621,7 +621,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Connection to authentication provider failed" assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false assert_select "span.username", false
end end
@ -645,7 +645,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Invalid authentication credentials" assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false assert_select "span.username", false
end end
@ -758,7 +758,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -805,7 +805,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Connection to authentication provider failed" assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false assert_select "span.username", false
end end
@ -829,7 +829,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Invalid authentication credentials" assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false assert_select "span.username", false
end end
@ -913,7 +913,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -960,7 +960,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Connection to authentication provider failed" assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false assert_select "span.username", false
end end
@ -984,7 +984,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Invalid authentication credentials" assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false assert_select "span.username", false
end end
@ -1068,7 +1068,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -1115,7 +1115,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Connection to authentication provider failed" assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false assert_select "span.username", false
end end
@ -1139,7 +1139,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Invalid authentication credentials" assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false assert_select "span.username", false
end end
@ -1223,7 +1223,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "span.username", false assert_select "span.username", false
assert_select "div.flash.error", /your account has been suspended/ do assert_select "div.alert.alert-danger", /your account has been suspended/ do
assert_select "a[href='mailto:openstreetmap@example.com']", "support" assert_select "a[href='mailto:openstreetmap@example.com']", "support"
end end
end end
@ -1270,7 +1270,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Connection to authentication provider failed" assert_select "div.alert.alert-danger", "Connection to authentication provider failed"
assert_select "span.username", false assert_select "span.username", false
end end
@ -1294,7 +1294,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template "sessions/new" assert_template "sessions/new"
assert_select "div.flash.error", "Invalid authentication credentials" assert_select "div.alert.alert-danger", "Invalid authentication credentials"
assert_select "span.username", false assert_select "span.username", false
end end