diff --git a/app/views/active_admin/devise/sessions/new.html.erb b/app/views/active_admin/devise/sessions/new.html.erb index efdb1f5..4e86b49 100644 --- a/app/views/active_admin/devise/sessions/new.html.erb +++ b/app/views/active_admin/devise/sessions/new.html.erb @@ -1,13 +1,29 @@ <% if ActiveAdmin::Oidc.aa_v4? %>
-

- <%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %> -

+
+

+ <%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %> +

+ + <%# Active Admin's own dark mode toggle. The logged out layout renders + active_admin/html_head, which loads the JS that delegates clicks on + .dark-mode-toggle, so the button needs no script of its own. %> + +
<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> -

+ <%# Classes copied from Active Admin's own error flash. The gem's views are + outside the host's Tailwind content path, so only utilities Active Admin + itself already emits are compiled. %> +

+ Stub login is enabled: the button below signs in without contacting the identity provider. -

+
<% end %> <%= button_to ActiveAdmin::Oidc.config.login_button_label, diff --git a/lib/activeadmin/oidc/version.rb b/lib/activeadmin/oidc/version.rb index 458ffdb..12e877b 100644 --- a/lib/activeadmin/oidc/version.rb +++ b/lib/activeadmin/oidc/version.rb @@ -2,6 +2,6 @@ module ActiveAdmin module Oidc - VERSION = "2.2.0" + VERSION = "2.2.1" end end diff --git a/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb b/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb index 1d7832d..345d7d0 100644 --- a/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb +++ b/lib/generators/active_admin/oidc/install/templates/sessions_new_v4.html.erb @@ -2,14 +2,30 @@ route while ActiveAdmin::Oidc.config.stub_dev_env_login! is on, which only ever happens in the development environment. %>
-

- <%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %> -

+
+

+ <%= site_title %> <%= set_page_title t('active_admin.devise.login.title') %> +

+ + <%# Active Admin's own dark mode toggle. The logged out layout renders + active_admin/html_head, which loads the JS that delegates clicks on + .dark-mode-toggle, so the button needs no script of its own. %> + +
<% if ActiveAdmin::Oidc.config.stub_dev_env_login_enabled? %> - <% end %> <%= button_to ActiveAdmin::Oidc.config.login_button_label, diff --git a/spec/requests/login_page_spec.rb b/spec/requests/login_page_spec.rb index fa01c7a..b47f879 100644 --- a/spec/requests/login_page_spec.rb +++ b/spec/requests/login_page_spec.rb @@ -38,6 +38,29 @@ expect(response.body).to include(ActiveAdmin::Oidc::Configuration::DEFAULT_LOGIN_BUTTON_LABEL) end + # Active Admin renders its dark mode toggle only in the signed-in top + # bar, so the login page carries its own. The logged out layout already + # loads the JS that delegates clicks on `.dark-mode-toggle`, so the + # markup is the whole feature -- and losing it is silent. + describe "the dark mode toggle" do + it "renders on AA v4" do + skip "AA v3 has no dark mode" unless ActiveAdmin::Oidc.aa_v4? + + get "/admin/login" + + expect(response.body).to include("dark-mode-toggle") + expect(response.body).to match(/aria-label="[^"]+"[^>]*>/) + end + + it "is not rendered on AA v3" do + skip "AA v4 branch renders the toggle" if ActiveAdmin::Oidc.aa_v4? + + get "/admin/login" + + expect(response.body).not_to include("dark-mode-toggle") + end + end + # Regression: AA v3's formtastic stylesheet targets # `#login input[type="submit"]`, so a