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

Translations for Menu and Menu Items #11827

Draft
wants to merge 102 commits into
base: feature/mobility_gem
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
fd7d14e
Make schemas publicly visible for better documentation.
MatthewKennedy Nov 9, 2022
c947897
Fix extension generation.
MatthewKennedy Nov 25, 2022
96ee351
Bump version to 4.5.0
rafalcymerys Dec 1, 2022
609ca1e
change functino getting locale to first look at locale saved in user …
wjwitek Dec 15, 2022
ef8cc8e
add saved_locale to platform's user endpoint
wjwitek Dec 15, 2022
0f660fb
add saved_locale to storefront's account endpoint
wjwitek Dec 15, 2022
f377965
change permitted user attributes
wjwitek Dec 15, 2022
5d5ba24
add migration and change saved_locale to selected_locale
wjwitek Dec 15, 2022
26f9f3f
Make sure to use Metadata module from Spree namespace to prevent conf…
lkol Dec 16, 2022
ffab5fc
change using user locale to be configurable
wjwitek Dec 19, 2022
25f0e4e
Bump version to 4.6.0.alpha
rafalcymerys Dec 19, 2022
cec549d
add tests
wjwitek Dec 20, 2022
eaef3b3
reduce complexity
wjwitek Dec 20, 2022
3ccf1a8
fix a mistake
wjwitek Dec 20, 2022
9a29bb4
move long conditions to functions
wjwitek Dec 20, 2022
fb9964b
fix test by mocking a method
wjwitek Dec 20, 2022
521d54c
change migration file to work for other user types
wjwitek Dec 20, 2022
3194686
remove unnecessary selected_locale
wjwitek Dec 21, 2022
3ca1c41
revert taxonomy translation
nciemniak Dec 21, 2022
69752d1
allow controller to reveive spree_current_user more than once
wjwitek Dec 21, 2022
ea13d81
change migration to be compatible with rails 6.1
wjwitek Dec 21, 2022
c391f69
delete taxonomy translation migration files
nciemniak Dec 21, 2022
0eb3495
update methods checking for changes in translated values
nciemniak Dec 21, 2022
02f1ef9
Update api/spec/serializers/spree/api/v2/platform/user_serializer_spe…
wjwitek Dec 21, 2022
737c716
add description to test
wjwitek Dec 21, 2022
0941a33
udate api docs with selected_locale
wjwitek Dec 21, 2022
4359548
use mobility dirty plugin instead of manual checks for saved changes
nciemniak Dec 21, 2022
768a80c
Merge pull request #11814 from wjwitek/locale_in_user
rafalcymerys Dec 21, 2022
bade87b
account for mysql rules for select statements
nciemniak Dec 27, 2022
5cc7847
add brakeman warning to ignore list
nciemniak Dec 27, 2022
7181433
add path to brakeman.ignore for circleci
nciemniak Dec 27, 2022
7ab6da4
add warning to brakeman (spree core)
nciemniak Dec 27, 2022
e63e703
remove translatable resource controller parent class
nciemniak Dec 28, 2022
4b5b90e
refactoring and code climate fixes
nciemniak Dec 28, 2022
21faeda
change how translation fields are passed
nciemniak Dec 28, 2022
eb47edf
move join product translation code into a method
nciemniak Dec 28, 2022
74b012e
add taxon find spec
nciemniak Dec 28, 2022
fc6bb5a
refactor product 'ordered' method
nciemniak Dec 28, 2022
ba6b967
update brakeman.ignore
nciemniak Dec 29, 2022
dd503ab
Fix getting current user (#11820)
wjwitek Dec 29, 2022
2cc296a
remove checks for SpreeGlobalize on product searches
nciemniak Dec 29, 2022
d93d13b
Merge pull request #11804 from spree/fix/spree-extension-generator
rafalcymerys Jan 2, 2023
032d434
Merge pull request #11815 from lkol/lkol/namespace-fix
rafalcymerys Jan 2, 2023
8fbfd9b
Add translations for option types and option values
nciemniak Jan 4, 2023
7d58945
method for joining option value translations, plus tests
nciemniak Jan 5, 2023
2a27238
refactor join translation table methods
nciemniak Jan 5, 2023
de6fc20
valid create params for failing 'resource created' tests
nciemniak Jan 5, 2023
062f1d7
update brakeman.ignore
nciemniak Jan 9, 2023
8f2e005
migration for transferring option data to translations table
nciemniak Jan 9, 2023
ad48660
WIP Add menus to translatable resources
rafalkosla101 Jan 9, 2023
b432cb4
property and product property translations
nciemniak Jan 9, 2023
c3df8d5
make option type sample compatible w mobility
nciemniak Jan 9, 2023
05cdc4e
change rails migration version to 6.1
nciemniak Jan 9, 2023
62cdf6b
add translations to property models + update relevant product scope m…
nciemniak Jan 9, 2023
fe42b68
Merge pull request #11794 from spree/fix/internal-schemas
rafalcymerys Jan 9, 2023
22289fb
Run tests with Ruby 3.1
rafalcymerys Jan 9, 2023
1c62811
apply auto_strip to translation class, plus other test fixes
nciemniak Jan 9, 2023
10245fe
fix broken tests due to Mobility quirks
nciemniak Jan 9, 2023
687d7fd
Merge pull request #11824 from spree/run-specs-with-ruby-3-1
rafalcymerys Jan 10, 2023
307d6ef
update filter by brand to work with mobility
nciemniak Jan 10, 2023
c451f8d
bump version to allow for integration tests
nciemniak Jan 10, 2023
7742c47
code climate style tweaks
nciemniak Jan 10, 2023
74eddad
Run specs with ruby 3.2
rafalcymerys Jan 10, 2023
8f4ceda
Stub i18n.locale to fix flaky webhooks tests (#11830)
nciemniak Jan 11, 2023
8b99d9f
Add fix for YAML deserialization in log entry
rafalcymerys Jan 11, 2023
550e836
Merge pull request #11833 from spree/fix/parsing-log-entry-details-wi…
rafalcymerys Jan 11, 2023
86b531e
Merge pull request #11832 from spree/feature/run-specs-with-ruby-3-2
rafalcymerys Jan 11, 2023
5af3f48
Account for possibility of existing translations from globalize
nciemniak Jan 13, 2023
62ee13c
update brakeman.ignore
nciemniak Jan 13, 2023
a4f6eb5
Mobility Gem integration for products and taxons (#11823)
nciemniak Jan 16, 2023
91f7fed
Merge branch 'main' into feature/option_translations
nciemniak Jan 16, 2023
4b997b7
update migrations for mysql compatibility
nciemniak Jan 17, 2023
ad8f3aa
taxonomy translations + data transfer abstraction class
nciemniak Jan 18, 2023
c703f6f
fix broken taxonomy related tests
nciemniak Jan 18, 2023
b33abc2
update brakeman ignore
nciemniak Jan 18, 2023
05dcff8
menu translations
nciemniak Jan 18, 2023
895d415
fix broken menu tests
nciemniak Jan 18, 2023
3f66724
account for issue with Rails if_exists on dropping indexes
nciemniak Jan 19, 2023
ec416ae
Add translations for Option Type, Option Value, Property, & Product P…
nciemniak Jan 19, 2023
9ce0010
add keyserver and apt-get update
wjwitek Jan 31, 2023
97d01a5
Merge pull request #11843 from spree/fix/circleci_install_libvips
rafalcymerys Jan 31, 2023
db6424b
First working version of feed generation.
wjwitek Jan 2, 2023
519ace4
Refactor service, model and controller.
wjwitek Jan 4, 2023
c3a1133
Tests for DataFeed model and feed generation service.
wjwitek Jan 9, 2023
a26e569
Refactor services to be clearer.
wjwitek Jan 13, 2023
74043ce
Add sample data for DataFeed
wjwitek Jan 16, 2023
f59adcd
add basic api for google feed settings
wjwitek Jan 17, 2023
1027a07
Split DataFeed generation into multiple services.
wjwitek Jan 18, 2023
14d4161
move data feeds api to seperate controller
wjwitek Jan 26, 2023
d82fcff
Add functionalities for admin dashboard: nested attributes for store,…
wjwitek Jan 26, 2023
707dbba
Merge pull request #11825 from wjwitek/export_products_to_rss
rafalcymerys Feb 2, 2023
930e3b4
Remove unnecessary build configurations
rafalcymerys Feb 2, 2023
ed30ad6
taxonomies: rewrite first_or_create for mobility compatibility
nciemniak Feb 6, 2023
e5b9c35
menus: rewrite first_or_create for mobility compatibility
nciemniak Feb 6, 2023
a6972ad
Merge pull request #11844 from spree/chore/remove-unnecessary-build-c…
rafalcymerys Feb 6, 2023
81525b4
change port 3000 to 4000 in api docs and store sample (#11846)
wjwitek Feb 7, 2023
8bec027
add menu item translations
nciemniak Feb 7, 2023
b46d570
Merge branch 'main' into feature/menu_and_cms_translations
nciemniak Feb 8, 2023
077540e
fix tests and cleanup
nciemniak Feb 8, 2023
fa8ced8
make translations accessible for deleted products
nciemniak Feb 9, 2023
939cf10
merge
nciemniak Feb 10, 2023
5a9138c
fix bad merge
nciemniak Feb 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
75 changes: 42 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ defaults: &defaults
- image: &ruby_2_7_image circleci/ruby:2.7-node-browsers
- image: &redis_image circleci/redis:6.2-alpine

defaults_3_0: &defaults_3_0
defaults_3_2: &defaults_3_2
<<: *defaults
docker:
- image: &ruby_3_0_image circleci/ruby:3.0-node-browsers
- image: &ruby_3_2_image cimg/ruby:3.2.0-browsers
- image: *redis_image

run_tests_2_7: &run_tests_2_7
Expand All @@ -28,9 +28,12 @@ run_tests_2_7: &run_tests_2_7
keys:
- spree-bundle-v10-ruby-2-7-{{ .Branch }}
- spree-bundle-v10-ruby-2-7
- run:
name: Add keyserver
command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
- run:
name: Install libvips
command: sudo apt-get install libvips
command: sudo apt-get update && sudo apt-get install libvips
- run:
name: Ensure Bundle Install
command: |
Expand All @@ -48,18 +51,18 @@ run_tests_2_7: &run_tests_2_7
- store_test_results:
path: /tmp/test-results

run_tests_3_0: &run_tests_3_0
<<: *defaults_3_0
run_tests_3_2: &run_tests_3_2
<<: *defaults_3_2
parallelism: 3
steps:
- checkout
- restore_cache:
keys:
- spree-bundle-v10-ruby-3-0-{{ .Branch }}
- spree-bundle-v10-ruby-3-0
- spree-bundle-v10-ruby-3-2-{{ .Branch }}
- spree-bundle-v10-ruby-3-2
- run:
name: Install libvips
command: sudo apt-get install libvips
command: sudo apt-get update && sudo apt-get install libvips42
- run:
name: Ensure Bundle Install
command: |
Expand All @@ -86,9 +89,12 @@ jobs:
keys:
- spree-bundle-v10-ruby-2-7-{{ .Branch }}
- spree-bundle-v10-ruby-2-7
- run:
name: Add keyserver
command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
- run:
name: Install libvips
command: sudo apt-get install libvips
command: sudo apt-get update && sudo apt-get install libvips
- run:
name: Bundle Install
command: |
Expand All @@ -99,29 +105,29 @@ jobs:
paths:
- ~/spree/vendor/bundle

bundle_ruby_3_0:
<<: *defaults_3_0
bundle_ruby_3_2:
<<: *defaults_3_2
steps:
- checkout
- restore_cache:
keys:
- spree-bundle-v10-ruby-3-0-{{ .Branch }}
- spree-bundle-v10-ruby-3-0
- spree-bundle-v10-ruby-3-2-{{ .Branch }}
- spree-bundle-v10-ruby-3-2
- run:
name: Install libvips
command: sudo apt-get install libvips
command: sudo apt-get update && sudo apt-get install libvips42
- run:
name: Bundle Install
command: |
bundle check || bundle install
./bin/build-ci.rb install
- save_cache:
key: spree-bundle-v10-ruby-3-0-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
key: spree-bundle-v10-ruby-3-1-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
paths:
- ~/spree/vendor/bundle

brakeman:
<<: *defaults_3_0
<<: *defaults_3_2
steps:
- checkout
- restore_cache:
Expand All @@ -136,7 +142,7 @@ jobs:
- run:
name: Run Brakeman spree/api
command: |
bundle exec brakeman -p api/ --skip-files app/controllers/spree/api/v1/ --exit-on-warn --exit-on-error
bundle exec brakeman -p api/ --ignore-config api/brakeman.ignore --skip-files app/controllers/spree/api/v1/ --exit-on-warn --exit-on-error
- run:
name: Run Brakeman spree/core
command: |
Expand All @@ -160,12 +166,12 @@ jobs:
environment:
POSTGRES_USER: postgres

tests_ruby_3_0_rails_7_0_postgres:
<<: *run_tests_3_0
tests_ruby_3_2_rails_7_0_postgres:
<<: *run_tests_3_2
environment:
<<: *postgres_environment
docker:
- image: *ruby_3_0_image
- image: *ruby_3_2_image
- image: *postgres_image
- image: *redis_image

Expand All @@ -175,8 +181,8 @@ jobs:
<<: *postgres_environment
RAILS_VERSION: '~> 6.1.0'

tests_ruby_3_0_rails_7_0_mysql:
<<: *run_tests_3_0
tests_ruby_3_2_rails_7_0_mysql:
<<: *run_tests_3_2
environment:
<<: *environment
DB: mysql
Expand All @@ -185,19 +191,22 @@ jobs:
COVERAGE: true
COVERAGE_DIR: /tmp/workspace/simplecov
docker:
- image: *ruby_3_0_image
- image: *ruby_3_2_image
- image: *redis_image
- image: circleci/mysql:8-ram
command: [--default-authentication-plugin=mysql_native_password]
steps:
- checkout
- restore_cache:
keys:
- spree-bundle-v10-ruby-3-0-{{ .Branch }}
- spree-bundle-v10-ruby-3-0
- spree-bundle-v10-ruby-3-2-{{ .Branch }}
- spree-bundle-v10-ruby-3-2
- run:
name: Add keyserver
command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
- run:
name: Install libvips
command: sudo apt-get install libvips
command: sudo apt-get update && sudo apt-get install libvips
- run:
name: Ensure Bundle Install
command: |
Expand Down Expand Up @@ -254,22 +263,22 @@ workflows:
main:
jobs:
- bundle_ruby_2_7
- bundle_ruby_3_0
- bundle_ruby_3_2
- brakeman:
requires:
- bundle_ruby_3_0
- tests_ruby_3_0_rails_7_0_postgres:
- bundle_ruby_3_2
- tests_ruby_3_2_rails_7_0_postgres:
requires:
- bundle_ruby_3_0
- bundle_ruby_3_2
- tests_ruby_2_7_rails_7_0_postgres:
requires:
- bundle_ruby_2_7
- tests_ruby_2_7_rails_6_1_postgres:
requires:
- bundle_ruby_2_7
- tests_ruby_3_0_rails_7_0_mysql:
- tests_ruby_3_2_rails_7_0_mysql:
requires:
- bundle_ruby_3_0
- bundle_ruby_3_2
- send_test_coverage:
requires:
- tests_ruby_3_0_rails_7_0_mysql
- tests_ruby_3_2_rails_7_0_mysql
2 changes: 2 additions & 0 deletions api/app/controllers/spree/api/v2/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def spree_current_user
@spree_current_user ||= doorkeeper_token.resource_owner
end

alias try_spree_current_user spree_current_user # for compatibility with spree_legacy_frontend

def spree_authorize!(action, subject, *args)
authorize!(action, subject, *args)
end
Expand Down
24 changes: 24 additions & 0 deletions api/app/controllers/spree/api/v2/data_feeds/google_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module Spree
module Api
module V2
module DataFeeds
class GoogleController < ::Spree::Api::V2::BaseController
def rss_feed
send_data data_feeds_google_rss_service.value[:file], filename: 'products.rss', type: 'text/xml'
end

private

def settings
@settings ||= Spree::DataFeedSetting.find_by!(spree_store_id: current_store, uuid: params[:unique_url], provider: 'google', enabled: true)
end

def data_feeds_google_rss_service
Spree::Dependencies.data_feeds_google_rss_service.constantize.new.call(settings)
end
end
end
end
end
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Spree
module Api
module V2
module Platform
class GoogleFeedSettingsController < ResourceController
private

def model_class
Spree::GoogleFeedSetting
end
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Spree
module Api
module V2
module Platform
class TaxonsController < TranslatableResourceController
class TaxonsController < ResourceController
include ::Spree::Api::V2::Platform::NestedSetRepositionConcern

private
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ def spree_permitted_attributes
def collection
# if filtering on products, manually join on product translation to workaround mobility-ransack issue
if params.key?(:filter) && params[:filter].keys.any? { |k| k.include? 'product' }
@collection ||= scope.joins(:product).
joins("LEFT OUTER JOIN #{Product::Translation.table_name} #{Product.translation_table_alias}
ON #{Product.translation_table_alias}.spree_product_id = #{Product.table_name}.id
AND #{Product.translation_table_alias}.locale = '#{Mobility.locale.to_s}'").
ransack(params[:filter]).result
@collection ||= scope.joins(:product).join_translation_table(Product).
ransack(params[:filter]).result
else
super
end
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/spree/api/v2/resource_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def scope(skip_cancancan: false)
base_scope = model_class.for_store(current_store)
base_scope = base_scope.accessible_by(current_ability, :show) unless skip_cancancan
base_scope = base_scope.includes(scope_includes) if scope_includes.any? && action_name == 'index'
base_scope
model_class.include?(TranslatableResource) ? base_scope.i18n : base_scope
end

def scope_includes
Expand Down
8 changes: 1 addition & 7 deletions api/app/models/concerns/spree/webhooks/has_webhooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ def resource_serializer
end

def updating_only_ignored_attributes?
if defined?(translations) &&
translations.any?(&:saved_changes) &&
(translations.first(&:saved_changes).saved_changes.keys - ignored_attributes).any?
false
else
(saved_changes.keys - ignored_attributes).empty?
end
(saved_changes.keys - ignored_attributes).empty?
end

def ignored_attributes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Spree
module Api
module V2
module Platform
class GoogleFeedSettingSerializer < BaseSerializer
include ResourceSerializerConcern
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Platform
class UserSerializer < BaseSerializer
set_type :user

attributes :email, :first_name, :last_name, :created_at, :updated_at, :public_metadata, :private_metadata
attributes :email, :first_name, :last_name, :created_at, :updated_at, :public_metadata, :private_metadata, :selected_locale

attribute :average_order_value do |user, params|
price_stats(user.report_values_for(:average_order_value, params[:store]))
Expand Down
2 changes: 1 addition & 1 deletion api/app/serializers/spree/v2/storefront/user_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Storefront
class UserSerializer < BaseSerializer
set_type :user

attributes :email, :first_name, :last_name, :public_metadata
attributes :email, :first_name, :selected_locale, :last_name, :public_metadata

attribute :store_credits do |user|
user.total_available_store_credit
Expand Down
7 changes: 7 additions & 0 deletions api/brakeman.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ignored_warnings": [

],
"updated": "2022-12-29 09:29:46 +0100",
"brakeman_version": "5.4.0"
}
8 changes: 8 additions & 0 deletions api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@
# Store API
resources :stores

# Google Feed Setting API
resources :google_feed_settings

# Configurations API
resources :payment_methods
resources :shipping_categories
Expand All @@ -207,6 +210,11 @@
resources :subscribers
end
end

namespace :data_feeds do
# google data feed API
get '/google/:unique_url', to: 'google#rss_feed'
end
end
end
end