From 5f02d88a86053416778b6c78fe99cfb7d35f81ac Mon Sep 17 00:00:00 2001 From: Andrey Usyaev Date: Sat, 23 Aug 2025 12:19:49 +0300 Subject: [PATCH 1/2] Fix missed I18n translations for enterprises sells options --- app/helpers/admin/enterprises_helper.rb | 6 ++++++ app/views/admin/enterprises/_admin_index.html.haml | 2 +- config/locales/en.yml | 5 +++++ spec/helpers/admin/enterprises_helper_spec.rb | 6 ++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/helpers/admin/enterprises_helper.rb b/app/helpers/admin/enterprises_helper.rb index 7ff5e52e9e..591c6b5a46 100644 --- a/app/helpers/admin/enterprises_helper.rb +++ b/app/helpers/admin/enterprises_helper.rb @@ -71,6 +71,12 @@ module Admin "#{enterprise_attachment_removal_panel}_panel" end + def enterprise_sells_options + Enterprise::SELLS.map do |s| + [I18n.t("admin.enterprises.admin_index.sells_options.#{s}"), s] + end + end + private def build_enterprise_side_menu_items(is_shop:, show_options: ) # rubocop:disable Metrics/MethodLength diff --git a/app/views/admin/enterprises/_admin_index.html.haml b/app/views/admin/enterprises/_admin_index.html.haml index 2592d9970c..ce2d88f51b 100644 --- a/app/views/admin/enterprises/_admin_index.html.haml +++ b/app/views/admin/enterprises/_admin_index.html.haml @@ -28,7 +28,7 @@ = enterprise_form.check_box :is_primary_producer = t('.producer') - if spree_current_user.admin? - %td= enterprise_form.select :sells, Enterprise::SELLS, {}, class: 'select2 fullwidth' + %td= enterprise_form.select :sells, enterprise_sells_options, {}, class: 'select2 fullwidth' %td= enterprise_form.check_box :visible, {}, 'public', 'hidden' - if spree_current_user.admin? %td= enterprise_form.select :owner_id, enterprise.users.map{ |e| [ e.email, e.id ] }, {}, class: "select2 fullwidth" diff --git a/config/locales/en.yml b/config/locales/en.yml index 1644dec151..1dcd04cb82 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1518,6 +1518,11 @@ en: visible: Visible? owner: Owner producer: Producer + sells_options: + unspecified: unspecified + none: none + own: own + any: any change_type_form: producer_profile: Producer Profile connect_ofn: Connect through OFN diff --git a/spec/helpers/admin/enterprises_helper_spec.rb b/spec/helpers/admin/enterprises_helper_spec.rb index 7d2fd04e3f..4189e216d4 100644 --- a/spec/helpers/admin/enterprises_helper_spec.rb +++ b/spec/helpers/admin/enterprises_helper_spec.rb @@ -50,4 +50,10 @@ RSpec.describe Admin::EnterprisesHelper do expect(visible_items.pluck(:name)).to include "connected_apps" end end + + describe '#enterprise_sells_options' do + it 'returns sells options with translations' do + expect(helper.enterprise_sells_options.map(&:first)).to eq %w[unspecified none own any] + end + end end From 3d7799df193eca8b82b31b8c78f1960c04768370 Mon Sep 17 00:00:00 2001 From: Andrey Usyaev Date: Mon, 25 Aug 2025 16:31:21 +0300 Subject: [PATCH 2/2] Fix code review remarks --- app/helpers/admin/enterprises_helper.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/helpers/admin/enterprises_helper.rb b/app/helpers/admin/enterprises_helper.rb index 591c6b5a46..a82d96dd4a 100644 --- a/app/helpers/admin/enterprises_helper.rb +++ b/app/helpers/admin/enterprises_helper.rb @@ -72,9 +72,8 @@ module Admin end def enterprise_sells_options - Enterprise::SELLS.map do |s| - [I18n.t("admin.enterprises.admin_index.sells_options.#{s}"), s] - end + scope = "admin.enterprises.admin_index.sells_options" + Enterprise::SELLS.map { |s| [I18n.t(s, scope:), s] } end private