diff --git a/app/services/permitted_attributes/enterprise.rb b/app/services/permitted_attributes/enterprise.rb index cd0e704392..2948fe4f3e 100644 --- a/app/services/permitted_attributes/enterprise.rb +++ b/app/services/permitted_attributes/enterprise.rb @@ -35,7 +35,7 @@ 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, + :hide_ofn_navigation, :white_label_logo, :white_label_logo_link ] 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 eb15cb1934..963d26a25e 100644 --- a/app/views/admin/enterprises/form/_white_label.html.haml +++ b/app/views/admin/enterprises/form/_white_label.html.haml @@ -6,18 +6,26 @@ .three.columns = f.check_box :hide_ofn_navigation, { "data-controller": "checkbox-display", "data-checkbox-display-target-id-value": "white_label_logo" } -.row{id: "white_label_logo"} - .three.columns.alpha - = f.label :white_label_logo, t('.upload_logo') - .three.columns - = image_tag @object.white_label_logo_url if @object.white_label_logo.present? - = f.file_field :white_label_logo, accept: "image/*" - - if @object.white_label_logo.variable? - %button.button.small{ type: "button", "data-controller": "modal-link", "data-action": "click->modal-link#open", "data-modal-link-target-value": "remove_logo" } - = t('.remove_logo') +%div{id: "white_label_logo"} + .row + .three.columns.alpha + = f.label :white_label_logo, t('.upload_logo') + .three.columns + = image_tag @object.white_label_logo_url if @object.white_label_logo.present? + = f.file_field :white_label_logo, accept: "image/*" + - if @object.white_label_logo.present? + %button.button.small{ type: "button", "data-controller": "modal-link", "data-action": "click->modal-link#open", "data-modal-link-target-value": "remove_logo" } + = t('.remove_logo') + + - if @object.white_label_logo.present? + .row + .three.columns.alpha + = f.label :white_label_logo_link, t('.white_label_logo_link_label') + .three.columns + = f.text_field :white_label_logo_link -- if @object.white_label_logo.variable? +- if @object.white_label_logo.present? = render ConfirmModalComponent.new(id: "remove_logo", confirm_reflexes: "click->WhiteLabel#remove_logo" ) do .margin-bottom-30 = t('.remove_logo_confirm') diff --git a/config/locales/en.yml b/config/locales/en.yml index 3d0071804c..5b7b4ff979 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1165,6 +1165,7 @@ en: remove_logo: "Remove logo" 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" actions: edit_profile: Settings properties: Properties diff --git a/spec/system/admin/enterprises_spec.rb b/spec/system/admin/enterprises_spec.rb index 07c6cee06e..8fd7a1f9d0 100644 --- a/spec/system/admin/enterprises_spec.rb +++ b/spec/system/admin/enterprises_spec.rb @@ -696,6 +696,10 @@ describe ' expect(distributor1.reload.white_label_logo_blob.filename).to eq("logo-white.png") end + it "does not show the white label logo link field" do + expect(page).not_to have_field "white_label_logo_link" + end + context "when enterprise has a white label logo" do before do distributor1.update white_label_logo: white_logo_file @@ -717,6 +721,14 @@ describe ' distributor1.reload expect(distributor1.white_label_logo).to_not be_attached end + + it "can edit the text field white_label_logo_link" do + fill_in "enterprise_white_label_logo_link", with: "https://www.openfoodnetwork.org" + click_button 'Update' + expect(flash_message) + .to eq('Enterprise "First Distributor" has been successfully updated!') + expect(distributor1.reload.white_label_logo_link).to eq("https://www.openfoodnetwork.org") + end end end end