mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Add connected apps settings screen
I considered adding a request spec, but figured it still doesnt' test the form, so better to use a full system spec.
This commit is contained in:
committed by
Rachel Arnould
parent
254e11aa36
commit
5d732d80a6
21
app/controllers/admin/connected_app_settings_controller.rb
Normal file
21
app/controllers/admin/connected_app_settings_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ConnectedAppSettingsController < Spree::Admin::BaseController
|
||||
def update
|
||||
Spree::Config.set(connected_apps_enabled:)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to main_app.edit_admin_connected_app_settings_path
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def connected_apps_enabled
|
||||
params.require(:preferences).require(:connected_apps_enabled).join(",")
|
||||
end
|
||||
end
|
||||
end
|
||||
22
app/views/admin/connected_app_settings/edit.html.haml
Normal file
22
app/views/admin/connected_app_settings/edit.html.haml
Normal file
@@ -0,0 +1,22 @@
|
||||
= render :partial => 'spree/admin/shared/configuration_menu'
|
||||
|
||||
- content_for :page_title do
|
||||
= t('.title')
|
||||
|
||||
= form_tag main_app.admin_connected_app_settings_path, :method => :put do
|
||||
|
||||
%fieldset
|
||||
%legend= t('.enabled_legend')
|
||||
|
||||
= t('.info_html')
|
||||
|
||||
.field
|
||||
- ConnectedApp::TYPES.each do |type|
|
||||
%label
|
||||
= check_box_tag("preferences[connected_apps_enabled][]", type,
|
||||
Spree::Config.connected_apps_enabled&.split(',')&.include?(type))
|
||||
= t('.connected_apps_enabled.' + type)
|
||||
%br
|
||||
|
||||
.form-buttons
|
||||
= button t(:update), 'icon-refresh'
|
||||
@@ -23,3 +23,4 @@
|
||||
= configurations_sidebar_menu_item t('admin.invoice_settings.edit.title'), main_app.edit_admin_invoice_settings_path
|
||||
= configurations_sidebar_menu_item t('admin.matomo_settings.edit.title'), main_app.edit_admin_matomo_settings_path
|
||||
= configurations_sidebar_menu_item t('admin.stripe_connect_settings.edit.title'), main_app.edit_admin_stripe_connect_settings_path
|
||||
= configurations_sidebar_menu_item t('admin.connected_app_settings.edit.title'), main_app.edit_admin_connected_app_settings_path
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
= tab :order_cycles, url: main_app.admin_order_cycles_path, icon: 'icon-refresh'
|
||||
= tab :orders, :subscriptions, :customer_details, :adjustments, :payments, :return_authorizations, url: admin_orders_path, icon: 'icon-shopping-cart'
|
||||
= tab :reports, url: main_app.admin_reports_path, icon: 'icon-file'
|
||||
= tab :general_settings, :terms_of_service_files, :mail_methods, :tax_categories, :tax_rates, :tax_settings, :zones, :countries, :states, :payment_methods, :taxonomies, :shipping_methods, :shipping_categories, :enterprise_fees, :contents, :invoice_settings, :matomo_settings, :stripe_connect_settings, label: 'configuration', icon: 'icon-wrench', url: edit_admin_general_settings_path
|
||||
= tab :general_settings, :terms_of_service_files, :mail_methods, :tax_categories, :tax_rates, :tax_settings, :zones, :countries, :states, :payment_methods, :taxonomies, :shipping_methods, :shipping_categories, :enterprise_fees, :contents, :invoice_settings, :matomo_settings, :stripe_connect_settings, :connected_app_settings, label: 'configuration', icon: 'icon-wrench', url: edit_admin_general_settings_path
|
||||
= tab :enterprises, :enterprise_relationships, :vouchers, :oidc_settings, url: main_app.admin_enterprises_path
|
||||
= tab :customers, url: main_app.admin_customers_path
|
||||
= tab :enterprise_groups, url: main_app.admin_enterprise_groups_path, label: 'groups'
|
||||
|
||||
@@ -683,6 +683,8 @@ en:
|
||||
terms_of_service_have_been_updated_html: "Open Food Network's Terms of Service have been updated: %{tos_link}"
|
||||
terms_of_service: Read Terms of Service
|
||||
accept_terms_of_service: Accept Terms of Service
|
||||
|
||||
# Pages
|
||||
shopfront_settings:
|
||||
embedded_shopfront_settings: "Embedded Shopfront Settings"
|
||||
enable_embedded_shopfronts: "Enable Embedded Shopfronts"
|
||||
@@ -739,6 +741,15 @@ en:
|
||||
config_instructions_html: "Here you can configure the OFN Matomo integration. The Matomo URL below should point to the Matomo instance where the user tracking information will be sent to; if it is left empty, Matomo user tracking will be disabled. The Site ID field is not mandatory but useful if you are tracking more than one website on a single Matomo instance; it can be found on the Matomo instance console."
|
||||
config_instructions_tag_manager_html: "Setting the Matomo Tag Manager URL enables Matomo Tag Manager. This tool allows you to set up analytics events. The Matomo Tag Manager URL is copied from the Install Code section of Matomo Tag Manager. Ensure you select the right container and environment as these options change the URL."
|
||||
|
||||
connected_app_settings:
|
||||
edit:
|
||||
title: "Connected app settings"
|
||||
info_html: "Enabled apps will appear under Enterprise Settings > Connected Apps."
|
||||
enabled_legend: "Enabled connected apps"
|
||||
connected_apps_enabled:
|
||||
discover_regen: Discover Regenerative portal
|
||||
affiliate_sales_data: DFC anonymised orders API for research purposes
|
||||
|
||||
customers:
|
||||
index:
|
||||
new_customer: "New Customer"
|
||||
|
||||
@@ -108,6 +108,8 @@ Openfoodnetwork::Application.routes.draw do
|
||||
|
||||
resource :matomo_settings, only: [:edit, :update]
|
||||
|
||||
resource :connected_app_settings, only: [:edit, :update]
|
||||
|
||||
resources :stripe_accounts, only: [:destroy] do
|
||||
get :connect, on: :collection
|
||||
get :status, on: :collection
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'system_helper'
|
||||
|
||||
RSpec.describe "Connected App Settings", feature: :connected_apps do
|
||||
include AuthenticationHelper
|
||||
|
||||
before do
|
||||
login_as_admin
|
||||
visit spree.admin_dashboard_path
|
||||
click_link "Configuration"
|
||||
click_link "Connected app settings"
|
||||
end
|
||||
|
||||
it "should update connected app enabled preferences" do
|
||||
expect(page).to have_field "Discover Regenerative portal", checked: false
|
||||
expect(page).to have_field "DFC anonymised orders API for research purposes", checked: false
|
||||
|
||||
check "Discover Regenerative portal"
|
||||
check "DFC anonymised orders API for research purposes"
|
||||
|
||||
expect{
|
||||
click_button "Update"
|
||||
}.to change{ Spree::Config.connected_apps_enabled }.to("discover_regen,affiliate_sales_data")
|
||||
end
|
||||
end
|
||||
@@ -42,7 +42,6 @@ RSpec.describe "Connected Apps", feature: :connected_apps, vcr: true do
|
||||
expect(page).to have_content "CONNECTED APPS"
|
||||
end
|
||||
|
||||
|
||||
it "only shows enabled apps" do
|
||||
allow(Spree::Config).to receive(:connected_apps_enabled).and_return("discover_regen")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user