Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[admin] dark mode #5511

Merged
merged 9 commits into from
Nov 15, 2023
Prev Previous commit
Next Next commit
Keep the account navigation menu open when changing the locale
  • Loading branch information
elia committed Nov 15, 2023
commit 74efa667f106d99833ceaef3e4b3e4218e93465f
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
data-controller="details-click-outside"
class="relative w-full"
aria-label="<%= t('.account') %>"
<%= :open if params[:account_menu_open] %>
>
<summary
class="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def update_user_locale
session[set_user_language_locale_key] = requested_locale

flash[:notice] = t('spree.locale_changed')
redirect_to url_for(request.params.except(:switch_to_locale))
redirect_to params.except(:switch_to_locale).permit!.to_h.merge(account_menu_open: true)
end
end

Expand Down
18 changes: 18 additions & 0 deletions admin/spec/features/accounts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,22 @@
expect(page).to have_content(user.email)
expect(current_path).to eq("/admin/users/#{user.id}/edit")
end

it "can change locale", :js do
I18n.config.available_locales_set << :"en-UK"
I18n.config.available_locales_set << "en-UK"
I18n.backend.store_translations('en-UK', spree: { i18n: { this_file_language: "English (UK)" } })

user = create(:admin_user, email: '[email protected]')
stub_authorization! user
sign_in user

visit "/admin/products"
find('summary', text: user.email).click
expect(page).to have_content("English (US)")
select "English (UK)", from: "switch_to_locale"
expect(page).to have_content("English (UK)")
select "English (US)", from: 'switch_to_locale'
expect(page).to have_content("English (US)")
end
end