spree_backend 4.6.2 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +20 -101
  3. data/.codeclimate.yml +1 -1
  4. data/.rubocop.yml +5 -2
  5. data/Gemfile +10 -14
  6. data/app/assets/javascripts/spree/backend/global/tinymce.es6 +2 -2
  7. data/app/assets/javascripts/spree/backend/stock_transfer.js +1 -1
  8. data/app/controllers/spree/admin/products_controller.rb +22 -0
  9. data/app/helpers/spree/admin/navigation_helper.rb +77 -11
  10. data/app/helpers/spree/admin/orders_helper.rb +0 -18
  11. data/app/models/spree/admin/actions/action.rb +48 -0
  12. data/app/models/spree/admin/actions/action_builder.rb +79 -0
  13. data/app/models/spree/admin/actions/action_style.rb +11 -0
  14. data/app/models/spree/admin/actions/adjustments_default_actions_builder.rb +28 -0
  15. data/app/models/spree/admin/actions/images_default_actions_builder.rb +29 -0
  16. data/app/models/spree/admin/actions/order_default_actions_builder.rb +92 -0
  17. data/app/models/spree/admin/actions/orders_default_actions_builder.rb +29 -0
  18. data/app/models/spree/admin/actions/payments_default_actions_builder.rb +33 -0
  19. data/app/models/spree/admin/actions/product_properties_default_actions_builder.rb +42 -0
  20. data/app/models/spree/admin/actions/products_default_actions_builder.rb +29 -0
  21. data/app/models/spree/admin/actions/root.rb +15 -0
  22. data/app/models/spree/admin/actions/store_credits_default_actions_builder.rb +28 -0
  23. data/app/models/spree/admin/actions/user_default_actions_builder.rb +29 -0
  24. data/app/models/spree/admin/actions/users_default_actions_builder.rb +29 -0
  25. data/app/models/spree/admin/actions/variants_default_actions_builder.rb +30 -0
  26. data/app/models/spree/admin/item_manager.rb +50 -0
  27. data/app/models/spree/admin/main_menu/default_configuration_builder.rb +263 -0
  28. data/app/models/spree/admin/main_menu/item.rb +30 -0
  29. data/app/models/spree/admin/main_menu/item_builder.rb +37 -0
  30. data/app/models/spree/admin/main_menu/root.rb +17 -0
  31. data/app/models/spree/admin/main_menu/section.rb +31 -0
  32. data/app/models/spree/admin/main_menu/section_builder.rb +36 -0
  33. data/app/models/spree/admin/permission_checks.rb +50 -0
  34. data/app/models/spree/admin/tabs/order_default_tabs_builder.rb +147 -0
  35. data/app/models/spree/admin/tabs/product_default_tabs_builder.rb +144 -0
  36. data/app/models/spree/admin/tabs/root.rb +15 -0
  37. data/app/models/spree/admin/tabs/tab.rb +38 -0
  38. data/app/models/spree/admin/tabs/tab_builder.rb +63 -0
  39. data/app/models/spree/admin/tabs/user_default_tabs_builder.rb +77 -0
  40. data/app/views/spree/admin/adjustments/index.html.erb +9 -1
  41. data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +27 -33
  42. data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +18 -22
  43. data/app/views/spree/admin/images/index.html.erb +12 -3
  44. data/app/views/spree/admin/orders/_order_actions.html.erb +10 -15
  45. data/app/views/spree/admin/orders/index.html.erb +11 -6
  46. data/app/views/spree/admin/payments/index.html.erb +9 -4
  47. data/app/views/spree/admin/prices/index.html.erb +12 -2
  48. data/app/views/spree/admin/product_properties/index.html.erb +13 -13
  49. data/app/views/spree/admin/products/_add_stock_form.html.erb +12 -1
  50. data/app/views/spree/admin/products/edit.html.erb +12 -1
  51. data/app/views/spree/admin/products/index.html.erb +11 -2
  52. data/app/views/spree/admin/shared/_main_menu.html.erb +19 -77
  53. data/app/views/spree/admin/shared/_order_tabs.html.erb +10 -83
  54. data/app/views/spree/admin/shared/_product_tabs.html.erb +12 -64
  55. data/app/views/spree/admin/store_credits/index.html.erb +9 -1
  56. data/app/views/spree/admin/users/_tabs.html.erb +11 -30
  57. data/app/views/spree/admin/users/_user_page_actions.html.erb +9 -1
  58. data/app/views/spree/admin/users/index.html.erb +11 -2
  59. data/app/views/spree/admin/variants/index.html.erb +12 -2
  60. data/app/views/spree/admin/webhooks_subscribers/index.html.erb +0 -11
  61. data/config/locales/en.yml +6 -4
  62. data/lib/spree/backend/configuration.rb +0 -17
  63. data/lib/spree/backend/engine.rb +28 -1
  64. data/lib/spree/backend/version.rb +1 -1
  65. data/spree_backend.gemspec +2 -2
  66. data/yarn.lock +58 -22
  67. metadata +36 -17
  68. data/app/views/spree/admin/shared/sub_menu/_apps.html.erb +0 -3
  69. data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +0 -19
  70. data/app/views/spree/admin/shared/sub_menu/_content.html.erb +0 -4
  71. data/app/views/spree/admin/shared/sub_menu/_integrations.html.erb +0 -5
  72. data/app/views/spree/admin/shared/sub_menu/_orders.html.erb +0 -5
  73. data/app/views/spree/admin/shared/sub_menu/_organizations.html.erb +0 -3
  74. data/app/views/spree/admin/shared/sub_menu/_product.html.erb +0 -8
  75. data/app/views/spree/admin/shared/sub_menu/_promotion.html.erb +0 -4
  76. data/app/views/spree/admin/shared/sub_menu/_returns.html.erb +0 -4
  77. data/app/views/spree/admin/shared/sub_menu/_stock.html.erb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6a727db968502ab5d08a7733adecdf3d46a1657218745d63a0896b72d6c0480
4
- data.tar.gz: 660d8c18a9e4f401cd72321f7b68503dc0f3784e50eda8e123f0e5ee9cf18d76
3
+ metadata.gz: 53af17f0ae03b42dc296d5867212669844deec1a6613c77c77d863c7160cd9ed
4
+ data.tar.gz: 22326cbf504f1f32d2fb8ee81cb05990d6ef2cd6a98ed68845ff5eaa7bab2b31
5
5
  SHA512:
6
- metadata.gz: a7d89b1b4411316a3727d36b349f07789ce4eb07e36be7dfa7d046a8becb2acd7dad8439fc7206ca47fd4e834db7a947ef2b8a4c2ade7dbecd17e38e72e8a9b8
7
- data.tar.gz: 3cf8f6c96eaef38994f05a137ddcf5cefadb9403b3582dee37fa360c3c868649622b9cc9e56586e31bec9ca97855aff03e9fbe18da23774848de9df91ad77077
6
+ metadata.gz: 0a2adf4c4895a8de60c84755afcca683fb13edb6e304d8691dafdd8d414274c6f4f0c768e2eae214acabc7c1a2108445b918494b14f8c18188c0b2b1c099e345
7
+ data.tar.gz: db8d9bd704a18c8d92c6df428b01e3a508fcff455eb56d05c5c346d7feb85bd026f9e7e9518a008ce959ecf0992f0a90423ef1881835fb72d99dc3646826e9a3
data/.circleci/config.yml CHANGED
@@ -7,17 +7,11 @@ defaults: &defaults
7
7
  BUNDLE_JOBS: 4
8
8
  BUNDLE_RETRY: 3
9
9
  BUNDLE_PATH: ~/spree/vendor/bundle
10
- RAILS_VERSION: '~> 7.0'
10
+ RAILS_VERSION: '~> 7.1.0'
11
11
  working_directory: ~/spree
12
- docker:
13
- - image: &ruby_2_7_image circleci/ruby:2.7-node-browsers
14
- - image: &redis_image circleci/redis:6.2-alpine
15
-
16
- defaults_3_0: &defaults_3_0
17
- <<: *defaults
18
12
  docker:
19
13
  - image: &ruby_3_0_image circleci/ruby:3.0-node-browsers
20
- - image: *redis_image
14
+ - image: &redis_image circleci/redis:6.2-alpine
21
15
 
22
16
  defaults_3_2: &defaults_3_2
23
17
  <<: *defaults
@@ -25,51 +19,8 @@ defaults_3_2: &defaults_3_2
25
19
  - image: &ruby_3_2_image cimg/ruby:3.2.0-browsers
26
20
  - image: *redis_image
27
21
 
28
- run_tests_2_7: &run_tests_2_7
29
- <<: *defaults
30
- parallelism: 8
31
- steps:
32
- - checkout
33
- - restore_cache:
34
- keys:
35
- - spree-dashboard-bundle-v10-ruby-2-7-{{ .Branch }}
36
- - spree-dashboard-bundle-v10-ruby-2-7
37
- - run:
38
- name: Add keyserver
39
- command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
40
- - run:
41
- name: Install libvips
42
- command: sudo apt-get update && sudo apt-get install libvips
43
- - run:
44
- name: Set bundle path
45
- command: bundle config --local path vendor/bundle
46
- - run:
47
- name: Ensure bundle Install
48
- command: |
49
- bundle check || bundle install
50
- - run:
51
- name: Create test app
52
- command: |
53
- bundle exec rake test_app
54
- - run:
55
- name: Unlink NPM package
56
- command: |
57
- cd spec/dummy && yarn unlink @spree/dashboard
58
- - run:
59
- name: Run Rspec
60
- command: |
61
- TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
62
- bundle exec rspec --format documentation \
63
- --format RspecJunitFormatter \
64
- -o ~/rspec/rspec.xml \
65
- -- ${TESTFILES}
66
- - store_test_results:
67
- path: ~/rspec
68
- - store_artifacts:
69
- path: /tmp/test-artifacts
70
-
71
22
  run_tests_3_0: &run_tests_3_0
72
- <<: *defaults_3_0
23
+ <<: *defaults
73
24
  parallelism: 8
74
25
  steps:
75
26
  - checkout
@@ -152,34 +103,8 @@ run_tests_3_2: &run_tests_3_2
152
103
  path: /tmp/test-artifacts
153
104
 
154
105
  jobs:
155
- bundle_ruby_2_7:
156
- <<: *defaults
157
- steps:
158
- - checkout
159
- - restore_cache:
160
- keys:
161
- - spree-dashboard-bundle-v10-ruby-2-7-{{ .Branch }}
162
- - spree-dashboard-bundle-v10-ruby-2-7
163
- - run:
164
- name: Add keyserver
165
- command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
166
- - run:
167
- name: Install libvips
168
- command: sudo apt-get update && sudo apt-get install libvips
169
- - run:
170
- name: Set bundle path
171
- command: bundle config --local path vendor/bundle
172
- - run:
173
- name: Bundle Install
174
- command: |
175
- bundle check || bundle install
176
- - save_cache:
177
- paths:
178
- - vendor/bundle
179
- key: spree-dashboard-bundle-v10-ruby-2-7-{{ checksum "Gemfile.lock" }}
180
-
181
106
  bundle_ruby_3_0:
182
- <<: *defaults_3_0
107
+ <<: *defaults
183
108
  steps:
184
109
  - checkout
185
110
  - restore_cache:
@@ -227,40 +152,35 @@ jobs:
227
152
  - vendor/bundle
228
153
  key: spree-dashboard-bundle-v10-ruby-3-2-{{ checksum "Gemfile.lock" }}
229
154
 
230
- tests_ruby_2_7_rails_7_0_postgres:
231
- <<: *run_tests_2_7
232
- environment: &postgres_environment
155
+ tests_ruby_3_0_rails_7_0_postgres:
156
+ <<: *run_tests_3_0
157
+ environment:
233
158
  <<: *environment
234
159
  DB: postgres
235
160
  DB_HOST: localhost
236
161
  DB_USERNAME: postgres
162
+ RAILS_VERSION: '~> 7.0.0'
237
163
  docker:
238
- - image: *ruby_2_7_image
239
- - image: *redis_image
164
+ - image: *ruby_3_0_image
240
165
  - image: &postgres_image circleci/postgres:12-alpine
241
166
  environment:
242
167
  POSTGRES_USER: postgres
243
-
244
- tests_ruby_3_0_rails_7_0_postgres:
245
- <<: *run_tests_3_0
246
- environment:
247
- <<: *postgres_environment
248
- docker:
249
- - image: *ruby_3_0_image
250
- - image: *postgres_image
251
168
  - image: *redis_image
252
169
 
253
- tests_ruby_3_2_rails_7_0_postgres:
170
+ tests_ruby_3_2_rails_7_1_postgres:
254
171
  <<: *run_tests_3_2
255
172
  environment:
256
- <<: *postgres_environment
173
+ <<: *environment
174
+ DB: postgres
175
+ DB_HOST: localhost
176
+ DB_USERNAME: postgres
257
177
  docker:
258
178
  - image: *ruby_3_2_image
259
179
  - image: *postgres_image
260
180
  - image: *redis_image
261
181
 
262
- tests_ruby_2_7_rails_7_0_mysql:
263
- <<: *run_tests_2_7
182
+ tests_ruby_3_2_rails_7_1_mysql:
183
+ <<: *run_tests_3_2
264
184
  environment:
265
185
  <<: *environment
266
186
  DB: mysql
@@ -269,7 +189,7 @@ jobs:
269
189
  COVERAGE: true
270
190
  COVERAGE_DIR: /tmp/workspace/simplecov
271
191
  docker:
272
- - image: *ruby_2_7_image
192
+ - image: *ruby_3_2_image
273
193
  - image: *redis_image
274
194
  - image: &mysql_image circleci/mysql:8-ram
275
195
 
@@ -277,15 +197,14 @@ workflows:
277
197
  version: 2
278
198
  main:
279
199
  jobs:
280
- - bundle_ruby_2_7
281
200
  - bundle_ruby_3_0
282
201
  - bundle_ruby_3_2
283
- - tests_ruby_3_2_rails_7_0_postgres:
202
+ - tests_ruby_3_2_rails_7_1_postgres:
284
203
  requires:
285
204
  - bundle_ruby_3_2
286
205
  - tests_ruby_3_0_rails_7_0_postgres:
287
206
  requires:
288
207
  - bundle_ruby_3_0
289
- - tests_ruby_2_7_rails_7_0_mysql:
208
+ - tests_ruby_3_2_rails_7_1_mysql:
290
209
  requires:
291
- - bundle_ruby_2_7
210
+ - bundle_ruby_3_2
data/.codeclimate.yml CHANGED
@@ -15,7 +15,7 @@ plugins:
15
15
  enabled: false
16
16
  config:
17
17
  file: .rubocop.yml
18
- channel: "rubocop-0-80" # need to keep this value the same as rubocop version
18
+ channel: "rubocop-1-50-2" # need to keep this value the same as rubocop version
19
19
  # https://docs.codeclimate.com/v1.0/docs/rubocop#section-using-rubocop-s-newer-versions
20
20
  eslint:
21
21
  enabled: true
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  require: rubocop-rspec
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.5
4
+ TargetRubyVersion: 3.0
5
5
  Exclude:
6
6
  - '**/sandbox/**/*'
7
7
  - '**/db/migrate/*'
@@ -181,7 +181,10 @@ RSpec/NamedSubject:
181
181
  RSpec/MultipleExpectations:
182
182
  Enabled: false
183
183
 
184
- RSpec/FilePath:
184
+ RSpec/SpecFilePathFormat:
185
+ Enabled: false
186
+
187
+ RSpec/SpecFilePathSuffix:
185
188
  Enabled: false
186
189
 
187
190
  RSpec/LetSetup:
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
6
6
  actionmailer actionpack actionview activejob activemodel activerecord
7
7
  activestorage activesupport railties
8
8
  ].each do |rails_gem|
9
- gem rails_gem, ENV.fetch('RAILS_VERSION', '~> 7.0.0'), require: false
9
+ gem rails_gem, ENV.fetch('RAILS_VERSION', '~> 7.1.0'), require: false
10
10
  end
11
11
 
12
12
  platforms :jruby do
@@ -23,21 +23,21 @@ end
23
23
 
24
24
  group :test do
25
25
  gem 'tinymce-rails'
26
- gem 'capybara', '~> 3.39'
27
- gem 'capybara-screenshot', '~> 1.0'
26
+ gem 'capybara'
27
+ gem 'capybara-screenshot'
28
28
  gem 'capybara-select-2'
29
29
  gem 'database_cleaner', '~> 2.0'
30
30
  gem 'email_spec'
31
31
  gem 'factory_bot_rails', '~> 6.0'
32
32
  gem 'multi_json'
33
- gem 'rspec-activemodel-mocks', '~> 1.0'
34
- gem 'rspec-rails', '~> 5.0'
33
+ gem 'rspec-activemodel-mocks'
34
+ gem 'rspec-rails'
35
35
  gem 'rspec-retry'
36
36
  gem 'rspec_junit_formatter'
37
37
  gem 'rswag-specs'
38
38
  gem 'jsonapi-rspec'
39
39
  gem 'simplecov', '0.22.0'
40
- gem 'webmock', '~> 3.7'
40
+ gem 'webmock'
41
41
  gem 'timecop'
42
42
  gem 'rails-controller-testing'
43
43
  gem 'turbo-rails'
@@ -47,12 +47,11 @@ group :test, :development do
47
47
  gem 'awesome_print'
48
48
  gem 'gem-release'
49
49
  gem 'redis'
50
- gem 'rubocop', '~> 1.48.1', require: false # bumped
50
+ gem 'rubocop', require: false
51
51
  gem 'rubocop-rspec', require: false
52
52
  gem 'pry-byebug'
53
- gem 'webdrivers', '~> 5.3'
54
- # Puma 6.0 causes issues in specs due to conflict with capybara version
55
- gem 'puma', '< 6.0'
53
+ gem 'selenium-webdriver'
54
+ gem 'puma'
56
55
  gem 'ffaker'
57
56
  end
58
57
 
@@ -62,10 +61,7 @@ group :development do
62
61
  end
63
62
 
64
63
 
65
- spree_opts = { github: 'spree/spree', branch: '4-6-stable' }
64
+ spree_opts = { github: 'spree/spree', branch: 'main' }
66
65
  gem 'spree_core', spree_opts
67
66
  gem 'spree_api', spree_opts
68
- # Last version that supports Ruby 2.7
69
- # We should remove this once we drop support for Ruby 2.7
70
- gem 'selenium-webdriver', '~> 4.8.1'
71
67
  gemspec
@@ -4,7 +4,7 @@ document.addEventListener("spree:load", function() {
4
4
  tinymce.init({
5
5
  selector: '.spree-rte',
6
6
  plugins: [
7
- 'image table paste code link table lists'
7
+ 'image table paste code link table'
8
8
  ],
9
9
  menubar: false,
10
10
  toolbar: 'undo redo | styleselect | bold italic link forecolor backcolor | alignleft aligncenter alignright alignjustify | table | bullist numlist outdent indent | code '
@@ -14,7 +14,7 @@ document.addEventListener("spree:load", function() {
14
14
  selector: '.spree-rte-simple',
15
15
  menubar: false,
16
16
  plugins: [
17
- 'image table paste link table lists'
17
+ 'image table paste link table'
18
18
  ],
19
19
  toolbar: 'undo redo | styleselect | bold italic link forecolor backcolor | alignleft aligncenter alignright alignjustify | table | bullist numlist outdent indent'
20
20
  });
@@ -128,7 +128,7 @@ document.addEventListener("spree:load", function() {
128
128
 
129
129
  TransferVariants.prototype._search_transfer_stock_items = function () {
130
130
  var stockLocationId = $('#transfer_source_location_id').val()
131
- return this.build_select(Spree.routes.stock_items_api_v2 + '?filter[stock_location_id_eq]=' + stockLocationId + '&include=variant', 'variant_product_name_or_variant_sku_cont')
131
+ return this.build_select(Spree.routes.stock_items_api_v2 + '?filter[stock_location_id_eq]=' + stockLocationId + '&include=variant', 'variants_product_name_or_variants_sku_cont')
132
132
  }
133
133
 
134
134
  TransferVariants.prototype.format_variant_result = function (result) {
@@ -10,6 +10,7 @@ module Spree
10
10
  before_action :set_product_defaults, only: :new
11
11
 
12
12
  create.before :create_before
13
+ create.before :fix_option_values_params_rails_7_1
13
14
  update.before :update_before
14
15
  update.before :skip_updating_status
15
16
  update.after :update_status
@@ -167,6 +168,27 @@ module Spree
167
168
  @prototype = Spree::Prototype.find(params[:product][:prototype_id])
168
169
  end
169
170
 
171
+ def fix_option_values_params_rails_7_1
172
+ raise 'Verify if the patch is still needed' if Rails::VERSION::STRING >= '7.2.0'
173
+
174
+ if Rails::VERSION::STRING >= '7.1.0'
175
+ # This is a rather ugly fix for an issue with Rails 7.1.0 and 7.1.1
176
+ # As an example, a form field with name = option_values_hash[1][] and value = 5
177
+ # gets parsed incorrectly and is visible via params as the following structure
178
+ # { 'option_values_hash[1' => { '][]' => 5 } }
179
+ # This patch fixes that behavior to ensure compatibility with the existing templates
180
+ option_values_hash_keys = params[:product].keys.select { |e| e.starts_with?('option_values_hash[') }
181
+ option_values_hash = {}
182
+ option_values_hash_keys.each do |key|
183
+ value = params[:product].delete(key)
184
+ fixed_key = key.gsub(/option_values_hash\[/, '')
185
+ option_values_hash[fixed_key] ||= []
186
+ option_values_hash[fixed_key] << value['][]']
187
+ end
188
+ params[:product][:option_values_hash] = option_values_hash if option_values_hash.present?
189
+ end
190
+ end
191
+
170
192
  def update_before
171
193
  # NOTE: we only reset the product properties if we're receiving a post
172
194
  # from the form on that tab
@@ -1,5 +1,6 @@
1
1
  module Spree
2
2
  module Admin
3
+ # rubocop:disable Metrics/ModuleLength
3
4
  module NavigationHelper
4
5
  # Makes an admin navigation tab (<li> tag) that links to a routing resource under /admin.
5
6
  # The arguments should be a list of symbolized controller names that will cause this tab to
@@ -86,14 +87,6 @@ module Spree
86
87
  end
87
88
  end
88
89
 
89
- # Main menu tree menu
90
- def main_menu_tree(text, icon: nil, sub_menu: nil, url: '#')
91
- content_tag :li, class: 'sidebar-menu-item d-block w-100 text-muted' do
92
- main_menu_item(text, url: url, icon: icon) +
93
- render(partial: "spree/admin/shared/sub_menu/#{sub_menu}")
94
- end
95
- end
96
-
97
90
  # the per_page_dropdown is used on index pages like orders, products, promotions etc.
98
91
  # this method generates the select_tag
99
92
  def per_page_dropdown
@@ -279,7 +272,7 @@ module Spree
279
272
  end
280
273
 
281
274
  def main_part_classes
282
- ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
275
+ Spree::Deprecation.warn(<<-DEPRECATION, caller)
283
276
  Admin::NavigationHelper#main_part_classes is deprecated and will be removed in Spree 5.0.
284
277
  DEPRECATION
285
278
  if cookies['sidebar-minimized'] == 'true'
@@ -290,7 +283,7 @@ module Spree
290
283
  end
291
284
 
292
285
  def main_sidebar_classes
293
- ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
286
+ Spree::Deprecation.warn(<<-DEPRECATION, caller)
294
287
  Admin::NavigationHelper#main_sidebar_classes is deprecated and will be removed in Spree 5.0.
295
288
  DEPRECATION
296
289
  if cookies['sidebar-minimized'] == 'true'
@@ -301,7 +294,7 @@ module Spree
301
294
  end
302
295
 
303
296
  def wrapper_classes
304
- ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
297
+ Spree::Deprecation.warn(<<-DEPRECATION, caller)
305
298
  Admin::NavigationHelper#wrapper_classes is deprecated and will be removed in Spree 5.0.
306
299
  DEPRECATION
307
300
  'sidebar-minimized' if cookies['sidebar-minimized'] == 'true'
@@ -312,6 +305,79 @@ module Spree
312
305
  svg_icon name: 'chevron-left.svg', width: 15, height: 15
313
306
  end
314
307
  end
308
+
309
+ def main_menu
310
+ Rails.application.config.spree_backend.main_menu
311
+ end
312
+
313
+ def order_tabs
314
+ Rails.application.config.spree_backend.tabs[:order]
315
+ end
316
+
317
+ def user_tabs
318
+ Rails.application.config.spree_backend.tabs[:user]
319
+ end
320
+
321
+ def product_tabs
322
+ Rails.application.config.spree_backend.tabs[:product]
323
+ end
324
+
325
+ def orders_actions
326
+ Rails.application.config.spree_backend.actions[:orders]
327
+ end
328
+
329
+ def order_actions
330
+ Rails.application.config.spree_backend.actions[:order]
331
+ end
332
+
333
+ def users_actions
334
+ Rails.application.config.spree_backend.actions[:users]
335
+ end
336
+
337
+ def user_actions
338
+ Rails.application.config.spree_backend.actions[:user]
339
+ end
340
+
341
+ def products_actions
342
+ Rails.application.config.spree_backend.actions[:products]
343
+ end
344
+
345
+ def product_actions
346
+ Rails.application.config.spree_backend.actions[:product]
347
+ end
348
+
349
+ def images_actions
350
+ Rails.application.config.spree_backend.actions[:images]
351
+ end
352
+
353
+ def prices_actions
354
+ Rails.application.config.spree_backend.actions[:prices]
355
+ end
356
+
357
+ def store_credits_actions
358
+ Rails.application.config.spree_backend.actions[:store_credits]
359
+ end
360
+
361
+ def adjustments_actions
362
+ Rails.application.config.spree_backend.actions[:adjustments]
363
+ end
364
+
365
+ def payments_actions
366
+ Rails.application.config.spree_backend.actions[:payments]
367
+ end
368
+
369
+ def stock_actions
370
+ Rails.application.config.spree_backend.actions[:stock]
371
+ end
372
+
373
+ def variants_actions
374
+ Rails.application.config.spree_backend.actions[:variants]
375
+ end
376
+
377
+ def product_properties_actions
378
+ Rails.application.config.spree_backend.actions[:product_properties]
379
+ end
380
+ # rubocop:enable Metrics/ModuleLength
315
381
  end
316
382
  end
317
383
  end
@@ -2,24 +2,6 @@ module Spree
2
2
  module Admin
3
3
  module OrdersHelper
4
4
  # Renders all the extension partials that may have been specified in the extensions
5
- def event_links(order, events)
6
- links = []
7
- events.each do |event|
8
- next unless order.send("can_#{event}?")
9
-
10
- label = Spree.t(event, scope: 'admin.order.events', default: Spree.t(event))
11
- links << button_link_to(
12
- label.capitalize,
13
- [event.to_sym, :admin, order],
14
- method: :put,
15
- icon: event.to_s + '.svg',
16
- data: { confirm: Spree.t(:order_sure_want_to, event: label) },
17
- class: 'btn-light'
18
- )
19
- end
20
- safe_join(links, ''.html_safe)
21
- end
22
-
23
5
  def line_item_shipment_price(line_item, quantity)
24
6
  Spree::Money.new(line_item.price * quantity, currency: line_item.currency)
25
7
  end
@@ -0,0 +1,48 @@
1
+ module Spree
2
+ module Admin
3
+ module Actions
4
+ class Action
5
+ STYLE_CLASSES = {
6
+ ::Spree::Admin::Actions::ActionStyle::PRIMARY => 'btn-success',
7
+ ::Spree::Admin::Actions::ActionStyle::SECONDARY => 'btn-secondary',
8
+ ::Spree::Admin::Actions::ActionStyle::LIGHT => 'btn-light'
9
+ }
10
+
11
+ attr_reader :key, :label_translation_key, :icon_key, :method, :id, :target, :data_attributes
12
+
13
+ def initialize(key, label_translation_key, url, icon_key, style, availability_checks, additional_classes, method, id, target, data_attributes) # rubocop:disable Metrics/ParameterLists
14
+ @key = key
15
+ @label_translation_key = label_translation_key
16
+ @url = url
17
+ @icon_key = icon_key
18
+ @style = style
19
+ @availability_checks = availability_checks
20
+ @additional_classes = additional_classes
21
+ @method = method
22
+ @id = id
23
+ @target = target
24
+ @data_attributes = data_attributes
25
+ end
26
+
27
+ def available?(current_ability, resource = nil)
28
+ return true if @availability_checks.empty?
29
+
30
+ result = @availability_checks.map { |check| check.call(current_ability, resource) }
31
+
32
+ result.all?(true)
33
+ end
34
+
35
+ def url(resource = nil)
36
+ @url.is_a?(Proc) ? @url.call(resource) : @url
37
+ end
38
+
39
+ def classes
40
+ [
41
+ STYLE_CLASSES[@style],
42
+ @additional_classes
43
+ ].compact.join(' ')
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,79 @@
1
+ module Spree
2
+ module Admin
3
+ module Actions
4
+ class ActionBuilder
5
+ include ::Spree::Admin::PermissionChecks
6
+
7
+ def initialize(key, url)
8
+ @key = key
9
+ @label_translation_key = key
10
+ @url = url
11
+ @icon_key = nil
12
+ @style = ::Spree::Admin::Actions::ActionStyle::LIGHT
13
+ @availability_checks = []
14
+ @classes = ''
15
+ @method = nil
16
+ @id = nil
17
+ @target = nil
18
+ @data_attributes = {}
19
+ end
20
+
21
+ def with_label_translation_key(key)
22
+ @label_translation_key = key
23
+ self
24
+ end
25
+
26
+ def with_icon_key(icon_key)
27
+ @icon_key = icon_key
28
+ self
29
+ end
30
+
31
+ def with_classes(classes)
32
+ @classes = classes
33
+ self
34
+ end
35
+
36
+ def with_style(style)
37
+ @style = style
38
+ self
39
+ end
40
+
41
+ def with_method(method)
42
+ @method = method
43
+ self
44
+ end
45
+
46
+ def with_id(id)
47
+ @id = id
48
+ self
49
+ end
50
+
51
+ def with_target(target)
52
+ @target = target
53
+ self
54
+ end
55
+
56
+ def with_data_attributes(data_attributes)
57
+ @data_attributes = data_attributes
58
+ self
59
+ end
60
+
61
+ def build
62
+ Action.new(
63
+ @key,
64
+ @label_translation_key,
65
+ @url,
66
+ @icon_key,
67
+ @style,
68
+ @availability_checks,
69
+ @classes,
70
+ @method,
71
+ @id,
72
+ @target,
73
+ @data_attributes
74
+ )
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ module Admin
3
+ module Actions
4
+ module ActionStyle
5
+ PRIMARY = 'primary'
6
+ SECONDARY = 'secondary'
7
+ LIGHT = 'light'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ module Spree
2
+ module Admin
3
+ module Actions
4
+ class AdjustmentsDefaultActionsBuilder
5
+ include Spree::Core::Engine.routes.url_helpers
6
+
7
+ def build
8
+ root = Root.new
9
+ add_new_adjustment_action(root)
10
+ root
11
+ end
12
+
13
+ private
14
+
15
+ def add_new_adjustment_action(root)
16
+ action =
17
+ ActionBuilder.new('new_adjustment', ->(resource) { new_admin_order_adjustment_path(resource) }).
18
+ with_icon_key('add.svg').
19
+ with_style(::Spree::Admin::Actions::ActionStyle::PRIMARY).
20
+ with_create_ability_check(::Spree::Adjustment).
21
+ build
22
+
23
+ root.add(action)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end