From affd938f7eb7cca06267e89682d42594cd7f89e5 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 4 Apr 2024 17:21:30 +0200 Subject: [PATCH] Do not show theme selector if only one theme is configured There is no usecase for selecting from one theme. (cherry picked from commit d7ce8790056e2e7b0bc587cf6b19b5707a3ac4e9) --- .../admin/shared/_theme_selection.html.erb | 36 ++++++++------- .../_theme_selection_solidus_admin.html.erb | 46 ++++++++++--------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/backend/app/views/spree/admin/shared/_theme_selection.html.erb b/backend/app/views/spree/admin/shared/_theme_selection.html.erb index ad138748bce..a9c8aa204b9 100644 --- a/backend/app/views/spree/admin/shared/_theme_selection.html.erb +++ b/backend/app/views/spree/admin/shared/_theme_selection.html.erb @@ -1,21 +1,23 @@ <% theme_options_for_select = Spree::Backend::Config.themes.keys.map { |theme| [theme.to_s.humanize, theme] }.sort %> -<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "light-only") do %> - <%= hidden_field_tag :system_theme, :light %> - -<% end %> +<% if theme_options_for_select.length > 1 %> + <%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "light-only") do %> + <%= hidden_field_tag :system_theme, :light %> + + <% end %> -<%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "dark-only") do %> - <%= hidden_field_tag :system_theme, :dark %> - + <%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "dark-only") do %> + <%= hidden_field_tag :system_theme, :dark %> + + <% end %> <% end %> diff --git a/backend/app/views/spree/admin/shared/_theme_selection_solidus_admin.html.erb b/backend/app/views/spree/admin/shared/_theme_selection_solidus_admin.html.erb index de8531c9277..0b2ffeb783e 100644 --- a/backend/app/views/spree/admin/shared/_theme_selection_solidus_admin.html.erb +++ b/backend/app/views/spree/admin/shared/_theme_selection_solidus_admin.html.erb @@ -1,25 +1,27 @@ <% theme_options_for_select = Spree::Backend::Config.themes.keys.map { |theme| [theme.to_s.humanize, theme] }.sort %> -
  • - <%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "light-only") do %> - <%= hidden_field_tag :system_theme, :light %> - - <% end %> +<% if theme_options_for_select.length > 1 %> +
  • + <%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "light-only") do %> + <%= hidden_field_tag :system_theme, :light %> + + <% end %> - <%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "dark-only") do %> - <%= hidden_field_tag :system_theme, :dark %> - - <% end %> -
  • + <%= form_tag(spree.admin_set_theme_path(format: :html), method: :put, style: "width: 100%;", class: "dark-only") do %> + <%= hidden_field_tag :system_theme, :dark %> + + <% end %> + +<% end %>