diff --git a/app/services/permitted_attributes/enterprise.rb b/app/services/permitted_attributes/enterprise.rb index 2948fe4f3e..b6edf81636 100644 --- a/app/services/permitted_attributes/enterprise.rb +++ b/app/services/permitted_attributes/enterprise.rb @@ -35,7 +35,8 @@ module PermittedAttributes :show_customer_names_to_suppliers, :preferred_shopfront_product_sorting_method, :preferred_invoice_order_by_supplier, :preferred_product_low_stock_display, - :hide_ofn_navigation, :white_label_logo, :white_label_logo_link + :hide_ofn_navigation, :white_label_logo, :white_label_logo_link, + :hide_groups_tab ] end end diff --git a/app/views/admin/enterprises/form/_white_label.html.haml b/app/views/admin/enterprises/form/_white_label.html.haml index 963d26a25e..091f62213c 100644 --- a/app/views/admin/enterprises/form/_white_label.html.haml +++ b/app/views/admin/enterprises/form/_white_label.html.haml @@ -29,3 +29,11 @@ = render ConfirmModalComponent.new(id: "remove_logo", confirm_reflexes: "click->WhiteLabel#remove_logo" ) do .margin-bottom-30 = t('.remove_logo_confirm') + +// Hide groups tab boolean attribute + +.row + .three.columns.alpha + = f.label :hide_groups_tab, t('.hide_groups_tab') + .three.columns + = f.check_box :hide_groups_tab diff --git a/config/locales/en.yml b/config/locales/en.yml index 8e20e22529..fdf22e4a47 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1185,6 +1185,7 @@ en: remove_logo_confirm: "Are you sure you want to remove this logo?" remove_logo_success: "Logo removed" white_label_logo_link_label: "Link for the logo used in shopfront" + hide_groups_tab: "Hide groups tab in shopfront" actions: edit_profile: Settings properties: Properties diff --git a/spec/system/admin/enterprises_spec.rb b/spec/system/admin/enterprises_spec.rb index 3c75145ced..e786b5ff9a 100644 --- a/spec/system/admin/enterprises_spec.rb +++ b/spec/system/admin/enterprises_spec.rb @@ -706,6 +706,25 @@ describe ' expect(distributor1.reload.white_label_logo_link).to eq("https://www.openfoodnetwork.org") end end + + it "can check/uncheck the hide_groups_tab attribute" do + check "Hide groups tab in shopfront" + click_button 'Update' + expect(flash_message) + .to eq('Enterprise "First Distributor" has been successfully updated!') + expect(distributor1.reload.hide_groups_tab).to be true + + visit edit_admin_enterprise_path(distributor1) + within(".side_menu") do + click_link "White Label" + end + + uncheck "Hide groups tab in shopfront" + click_button 'Update' + expect(flash_message) + .to eq('Enterprise "First Distributor" has been successfully updated!') + expect(distributor1.reload.hide_groups_tab).to be false + end end end end