From 2adb60a08616ca4f3831fa2e3c485fe5e5938df3 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Wed, 10 Jan 2024 17:56:39 +0100 Subject: [PATCH 1/3] Rename the batch_actions text key from `display_name` to `label` --- .../solidus_admin/adjustment_reasons/index/component.rb | 2 +- .../solidus_admin/option_types/index/component.rb | 2 +- .../solidus_admin/payment_methods/index/component.rb | 2 +- .../components/solidus_admin/products/index/component.rb | 6 +++--- .../solidus_admin/promotion_categories/index/component.rb | 2 +- .../components/solidus_admin/promotions/index/component.rb | 2 +- .../components/solidus_admin/properties/index/component.rb | 2 +- .../solidus_admin/refund_reasons/index/component.rb | 2 +- .../solidus_admin/return_reasons/index/component.rb | 2 +- .../solidus_admin/shipping_categories/index/component.rb | 2 +- .../solidus_admin/shipping_methods/index/component.rb | 2 +- .../solidus_admin/stock_locations/index/component.rb | 2 +- .../solidus_admin/store_credit_reasons/index/component.rb | 2 +- .../app/components/solidus_admin/stores/index/component.rb | 2 +- .../solidus_admin/tax_categories/index/component.rb | 2 +- .../components/solidus_admin/tax_rates/index/component.rb | 2 +- .../components/solidus_admin/taxonomies/index/component.rb | 2 +- admin/app/components/solidus_admin/ui/table/component.rb | 4 ++-- admin/app/components/solidus_admin/users/index/component.rb | 2 +- admin/app/components/solidus_admin/zones/index/component.rb | 2 +- .../solidus_admin/ui/pages/index/component_preview.rb | 2 +- .../previews/solidus_admin/ui/table/component_preview.rb | 6 +++--- 22 files changed, 27 insertions(+), 27 deletions(-) diff --git a/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb b/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb index b432453f6a3..e6d297e9904 100644 --- a/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb +++ b/admin/app/components/solidus_admin/adjustment_reasons/index/component.rb @@ -20,7 +20,7 @@ def row_url(adjustment_reason) def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.adjustment_reasons_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/option_types/index/component.rb b/admin/app/components/solidus_admin/option_types/index/component.rb index 1cad137da0d..24f6b24e4cf 100644 --- a/admin/app/components/solidus_admin/option_types/index/component.rb +++ b/admin/app/components/solidus_admin/option_types/index/component.rb @@ -36,7 +36,7 @@ def next_page_path def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.option_types_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/payment_methods/index/component.rb b/admin/app/components/solidus_admin/payment_methods/index/component.rb index 9639b5fd80d..7bf64ffa63f 100644 --- a/admin/app/components/solidus_admin/payment_methods/index/component.rb +++ b/admin/app/components/solidus_admin/payment_methods/index/component.rb @@ -36,7 +36,7 @@ def page_actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.payment_methods_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/products/index/component.rb b/admin/app/components/solidus_admin/products/index/component.rb index 5dbbdfc6a4e..07363b42824 100644 --- a/admin/app/components/solidus_admin/products/index/component.rb +++ b/admin/app/components/solidus_admin/products/index/component.rb @@ -29,19 +29,19 @@ def page_actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.products_path, method: :delete, icon: 'delete-bin-7-line', }, { - display_name: t('.batch_actions.discontinue'), + label: t('.batch_actions.discontinue'), action: solidus_admin.discontinue_products_path, method: :put, icon: 'pause-circle-line', }, { - display_name: t('.batch_actions.activate'), + label: t('.batch_actions.activate'), action: solidus_admin.activate_products_path, method: :put, icon: 'play-circle-line', diff --git a/admin/app/components/solidus_admin/promotion_categories/index/component.rb b/admin/app/components/solidus_admin/promotion_categories/index/component.rb index a5ee76493dc..b52b1a0f3d2 100644 --- a/admin/app/components/solidus_admin/promotion_categories/index/component.rb +++ b/admin/app/components/solidus_admin/promotion_categories/index/component.rb @@ -21,7 +21,7 @@ def page_actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.promotion_categories_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/promotions/index/component.rb b/admin/app/components/solidus_admin/promotions/index/component.rb index 09e4810d71f..81c1d5d89c5 100644 --- a/admin/app/components/solidus_admin/promotions/index/component.rb +++ b/admin/app/components/solidus_admin/promotions/index/component.rb @@ -29,7 +29,7 @@ def page_actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.promotions_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/properties/index/component.rb b/admin/app/components/solidus_admin/properties/index/component.rb index 2f0af1141b2..e8289365922 100644 --- a/admin/app/components/solidus_admin/properties/index/component.rb +++ b/admin/app/components/solidus_admin/properties/index/component.rb @@ -29,7 +29,7 @@ def page_actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.properties_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/refund_reasons/index/component.rb b/admin/app/components/solidus_admin/refund_reasons/index/component.rb index c5b42d244c2..bff2aa644c1 100644 --- a/admin/app/components/solidus_admin/refund_reasons/index/component.rb +++ b/admin/app/components/solidus_admin/refund_reasons/index/component.rb @@ -30,7 +30,7 @@ def actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.refund_reasons_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/return_reasons/index/component.rb b/admin/app/components/solidus_admin/return_reasons/index/component.rb index 42baf319fc2..75ba35f2b95 100644 --- a/admin/app/components/solidus_admin/return_reasons/index/component.rb +++ b/admin/app/components/solidus_admin/return_reasons/index/component.rb @@ -20,7 +20,7 @@ def row_url(return_reason) def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.return_reasons_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/shipping_categories/index/component.rb b/admin/app/components/solidus_admin/shipping_categories/index/component.rb index 7624877004e..d5bf779136b 100644 --- a/admin/app/components/solidus_admin/shipping_categories/index/component.rb +++ b/admin/app/components/solidus_admin/shipping_categories/index/component.rb @@ -30,7 +30,7 @@ def search_url def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.shipping_categories_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/shipping_methods/index/component.rb b/admin/app/components/solidus_admin/shipping_methods/index/component.rb index 12102bda26c..77624e1f8ca 100644 --- a/admin/app/components/solidus_admin/shipping_methods/index/component.rb +++ b/admin/app/components/solidus_admin/shipping_methods/index/component.rb @@ -30,7 +30,7 @@ def actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.shipping_methods_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/stock_locations/index/component.rb b/admin/app/components/solidus_admin/stock_locations/index/component.rb index 8b9401681fd..643c4b4231f 100644 --- a/admin/app/components/solidus_admin/stock_locations/index/component.rb +++ b/admin/app/components/solidus_admin/stock_locations/index/component.rb @@ -30,7 +30,7 @@ def search_key def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.stock_locations_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb b/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb index 200ba18d619..3199d8aac0b 100644 --- a/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb +++ b/admin/app/components/solidus_admin/store_credit_reasons/index/component.rb @@ -30,7 +30,7 @@ def search_key def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.store_credit_reasons_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/stores/index/component.rb b/admin/app/components/solidus_admin/stores/index/component.rb index bad5a948575..5df8aa80005 100644 --- a/admin/app/components/solidus_admin/stores/index/component.rb +++ b/admin/app/components/solidus_admin/stores/index/component.rb @@ -29,7 +29,7 @@ def page_actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.stores_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/tax_categories/index/component.rb b/admin/app/components/solidus_admin/tax_categories/index/component.rb index bab394c2d71..47ff3fb60bf 100644 --- a/admin/app/components/solidus_admin/tax_categories/index/component.rb +++ b/admin/app/components/solidus_admin/tax_categories/index/component.rb @@ -30,7 +30,7 @@ def search_key def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.tax_categories_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/tax_rates/index/component.rb b/admin/app/components/solidus_admin/tax_rates/index/component.rb index 3f73e4f42cd..2c08eea16d8 100644 --- a/admin/app/components/solidus_admin/tax_rates/index/component.rb +++ b/admin/app/components/solidus_admin/tax_rates/index/component.rb @@ -30,7 +30,7 @@ def search_key def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.tax_rates_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/taxonomies/index/component.rb b/admin/app/components/solidus_admin/taxonomies/index/component.rb index fcee55250a4..e1a47ae8f60 100644 --- a/admin/app/components/solidus_admin/taxonomies/index/component.rb +++ b/admin/app/components/solidus_admin/taxonomies/index/component.rb @@ -28,7 +28,7 @@ def page_actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.taxonomies_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/ui/table/component.rb b/admin/app/components/solidus_admin/ui/table/component.rb index 86a8517f48c..59277a9c7e6 100644 --- a/admin/app/components/solidus_admin/ui/table/component.rb +++ b/admin/app/components/solidus_admin/ui/table/component.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class SolidusAdmin::UI::Table::Component < SolidusAdmin::BaseComponent - BatchAction = Struct.new(:display_name, :icon, :action, :method, keyword_init: true) # rubocop:disable Lint/StructNewOverride + BatchAction = Struct.new(:label, :icon, :action, :method, keyword_init: true) # rubocop:disable Lint/StructNewOverride Column = Struct.new(:header, :data, :col, :wrap, keyword_init: true) Filter = Struct.new(:presentation, :combinator, :attribute, :predicate, :options, keyword_init: true) Scope = Struct.new(:name, :label, :default, keyword_init: true) @@ -108,7 +108,7 @@ def render_batch_action_button(batch_action) form: batch_actions_form_id, type: :submit, icon: batch_action.icon, - text: batch_action.display_name, + text: batch_action.label, scheme: :secondary, ) end diff --git a/admin/app/components/solidus_admin/users/index/component.rb b/admin/app/components/solidus_admin/users/index/component.rb index 9a4d6d4c8ca..04247c74b66 100644 --- a/admin/app/components/solidus_admin/users/index/component.rb +++ b/admin/app/components/solidus_admin/users/index/component.rb @@ -29,7 +29,7 @@ def page_actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.users_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/app/components/solidus_admin/zones/index/component.rb b/admin/app/components/solidus_admin/zones/index/component.rb index eff2c73358d..04ff17ea1cd 100644 --- a/admin/app/components/solidus_admin/zones/index/component.rb +++ b/admin/app/components/solidus_admin/zones/index/component.rb @@ -30,7 +30,7 @@ def page_actions def batch_actions [ { - display_name: t('.batch_actions.delete'), + label: t('.batch_actions.delete'), action: solidus_admin.zones_path, method: :delete, icon: 'delete-bin-7-line', diff --git a/admin/spec/components/previews/solidus_admin/ui/pages/index/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/pages/index/component_preview.rb index 37e3b3e6d6c..4b18c2bdf37 100644 --- a/admin/spec/components/previews/solidus_admin/ui/pages/index/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/pages/index/component_preview.rb @@ -40,7 +40,7 @@ def page_actions def batch_actions [{ - display_name: "Print", + label: "Print", action: "print", }] end diff --git a/admin/spec/components/previews/solidus_admin/ui/table/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/table/component_preview.rb index b8acca8a721..c572cf03bae 100644 --- a/admin/spec/components/previews/solidus_admin/ui/table/component_preview.rb +++ b/admin/spec/components/previews/solidus_admin/ui/table/component_preview.rb @@ -56,19 +56,19 @@ def table_data(batch_actions, sortable) def batch_actions_data [ { - display_name: "Delete", + label: "Delete", action: "#", method: :delete, icon: 'delete-bin-7-line', }, { - display_name: "Discontinue", + label: "Discontinue", action: "#", method: :put, icon: 'pause-circle-line', }, { - display_name: "Activate", + label: "Activate", action: "#", method: :put, icon: 'play-circle-line', From 366d39df6ddddcc8d73e3c787df7ff8d09ee1c36 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Wed, 10 Jan 2024 18:04:23 +0100 Subject: [PATCH 2/3] Rename the filters text key from `presentation` to `label` --- .../components/solidus_admin/orders/index/component.rb | 8 ++++---- .../components/solidus_admin/products/index/component.rb | 2 +- .../solidus_admin/promotions/index/component.rb | 2 +- .../solidus_admin/stock_items/index/component.rb | 4 ++-- .../components/solidus_admin/tax_rates/index/component.rb | 4 ++-- admin/app/components/solidus_admin/ui/table/component.rb | 4 ++-- .../app/components/solidus_admin/users/index/component.rb | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/admin/app/components/solidus_admin/orders/index/component.rb b/admin/app/components/solidus_admin/orders/index/component.rb index c75436888ae..5c412db937e 100644 --- a/admin/app/components/solidus_admin/orders/index/component.rb +++ b/admin/app/components/solidus_admin/orders/index/component.rb @@ -43,7 +43,7 @@ def scopes def filters [ { - presentation: t('.filters.status'), + label: t('.filters.status'), combinator: 'or', attribute: "state", predicate: "eq", @@ -55,7 +55,7 @@ def filters end }, { - presentation: t('.filters.shipment_state'), + label: t('.filters.shipment_state'), combinator: 'or', attribute: "shipment_state", predicate: "eq", @@ -67,7 +67,7 @@ def filters end }, { - presentation: t('.filters.payment_state'), + label: t('.filters.payment_state'), combinator: 'or', attribute: "payment_state", predicate: "eq", @@ -79,7 +79,7 @@ def filters end }, { - presentation: t('.filters.promotions'), + label: t('.filters.promotions'), combinator: 'or', attribute: "promotions_id", predicate: "in", diff --git a/admin/app/components/solidus_admin/products/index/component.rb b/admin/app/components/solidus_admin/products/index/component.rb index 07363b42824..27b7446c7a0 100644 --- a/admin/app/components/solidus_admin/products/index/component.rb +++ b/admin/app/components/solidus_admin/products/index/component.rb @@ -63,7 +63,7 @@ def scopes def filters Spree::OptionType.all.map do |option_type| { - presentation: option_type.presentation, + label: option_type.presentation, combinator: 'or', attribute: "variants_option_values", predicate: "in", diff --git a/admin/app/components/solidus_admin/promotions/index/component.rb b/admin/app/components/solidus_admin/promotions/index/component.rb index 81c1d5d89c5..b44b5114db3 100644 --- a/admin/app/components/solidus_admin/promotions/index/component.rb +++ b/admin/app/components/solidus_admin/promotions/index/component.rb @@ -50,7 +50,7 @@ def scopes def filters [ { - presentation: Spree::PromotionCategory.model_name.human.pluralize, + label: Spree::PromotionCategory.model_name.human.pluralize, attribute: "promotion_category_id", predicate: "in", options: Spree::PromotionCategory.pluck(:name, :id) diff --git a/admin/app/components/solidus_admin/stock_items/index/component.rb b/admin/app/components/solidus_admin/stock_items/index/component.rb index 11f7fd521d9..2ad4e782dd7 100644 --- a/admin/app/components/solidus_admin/stock_items/index/component.rb +++ b/admin/app/components/solidus_admin/stock_items/index/component.rb @@ -30,7 +30,7 @@ def scopes def filters [ { - presentation: t('.filters.stock_locations'), + label: t('.filters.stock_locations'), combinator: 'or', attribute: "stock_location_id", predicate: "eq", @@ -42,7 +42,7 @@ def filters end }, { - presentation: t('.filters.variants'), + label: t('.filters.variants'), combinator: 'or', attribute: "variant_id", predicate: "eq", diff --git a/admin/app/components/solidus_admin/tax_rates/index/component.rb b/admin/app/components/solidus_admin/tax_rates/index/component.rb index 2c08eea16d8..148d280a682 100644 --- a/admin/app/components/solidus_admin/tax_rates/index/component.rb +++ b/admin/app/components/solidus_admin/tax_rates/index/component.rb @@ -41,13 +41,13 @@ def batch_actions def filters [ { - presentation: Spree::Zone.model_name.human, + label: Spree::Zone.model_name.human, attribute: :zone_id, predicate: :eq, options: Spree::Zone.pluck(:name, :id), }, { - presentation: Spree::TaxCategory.model_name.human, + label: Spree::TaxCategory.model_name.human, attribute: :tax_categories_id, predicate: :in, options: Spree::TaxCategory.pluck(:name, :id), diff --git a/admin/app/components/solidus_admin/ui/table/component.rb b/admin/app/components/solidus_admin/ui/table/component.rb index 59277a9c7e6..7aaed74c3df 100644 --- a/admin/app/components/solidus_admin/ui/table/component.rb +++ b/admin/app/components/solidus_admin/ui/table/component.rb @@ -3,7 +3,7 @@ class SolidusAdmin::UI::Table::Component < SolidusAdmin::BaseComponent BatchAction = Struct.new(:label, :icon, :action, :method, keyword_init: true) # rubocop:disable Lint/StructNewOverride Column = Struct.new(:header, :data, :col, :wrap, keyword_init: true) - Filter = Struct.new(:presentation, :combinator, :attribute, :predicate, :options, keyword_init: true) + Filter = Struct.new(:label, :combinator, :attribute, :predicate, :options, keyword_init: true) Scope = Struct.new(:name, :label, :default, keyword_init: true) Sortable = Struct.new(:url, :param, :animation, :handle, keyword_init: true) private_constant :BatchAction, :Column, :Filter, :Scope, :Sortable @@ -115,7 +115,7 @@ def render_batch_action_button(batch_action) def render_ransack_filter_dropdown(filter, index) render component("ui/table/ransack_filter").new( - presentation: filter.presentation, + presentation: filter.label, search_param: @search.name, combinator: filter.combinator, attribute: filter.attribute, diff --git a/admin/app/components/solidus_admin/users/index/component.rb b/admin/app/components/solidus_admin/users/index/component.rb index 04247c74b66..5b555b0912e 100644 --- a/admin/app/components/solidus_admin/users/index/component.rb +++ b/admin/app/components/solidus_admin/users/index/component.rb @@ -50,7 +50,7 @@ def scopes def filters [ { - presentation: Spree::Role.model_name.human.pluralize, + label: Spree::Role.model_name.human.pluralize, attribute: "spree_roles_id", predicate: "in", options: Spree::Role.pluck(:name, :id) From e717cdb07b017bf29a38d057b345c194317bf639 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Wed, 10 Jan 2024 18:08:50 +0100 Subject: [PATCH 3/3] Keep all the label structs in the table component together --- admin/app/components/solidus_admin/ui/table/component.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/app/components/solidus_admin/ui/table/component.rb b/admin/app/components/solidus_admin/ui/table/component.rb index 7aaed74c3df..a77cdc37a8a 100644 --- a/admin/app/components/solidus_admin/ui/table/component.rb +++ b/admin/app/components/solidus_admin/ui/table/component.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true class SolidusAdmin::UI::Table::Component < SolidusAdmin::BaseComponent - BatchAction = Struct.new(:label, :icon, :action, :method, keyword_init: true) # rubocop:disable Lint/StructNewOverride Column = Struct.new(:header, :data, :col, :wrap, keyword_init: true) - Filter = Struct.new(:label, :combinator, :attribute, :predicate, :options, keyword_init: true) - Scope = Struct.new(:name, :label, :default, keyword_init: true) Sortable = Struct.new(:url, :param, :animation, :handle, keyword_init: true) + Scope = Struct.new(:label, :name, :default, keyword_init: true) + Filter = Struct.new(:label, :combinator, :attribute, :predicate, :options, keyword_init: true) + BatchAction = Struct.new(:label, :icon, :action, :method, keyword_init: true) # rubocop:disable Lint/StructNewOverride private_constant :BatchAction, :Column, :Filter, :Scope, :Sortable class Data < Struct.new(:rows, :class, :url, :prev, :next, :columns, :fade, :batch_actions, keyword_init: true) # rubocop:disable Lint/StructNewOverride,Style/StructInheritance