# frozen_string_literal: true
require_relative "dynamic_settings_node"

module ActiveAdmin
  class NamespaceSettings < DynamicSettingsNode
    # The default number of resources to display on index pages
    register :default_per_page, 30

    # The max number of resources to display on index pages and batch exports
    register :max_per_page, 10_000

    # The title which gets displayed in the main layout
    register :site_title, "", :string_symbol_or_proc

    # The method to call in controllers to get the current user
    register :current_user_method, false

    # The method to call in the controllers to ensure that there
    # is a currently authenticated admin user
    register :authentication_method, false

    # The path to log user's out with. If set to a symbol, we assume
    # that it's a method to call which returns the path
    register :logout_link_path, :destroy_admin_user_session_path

    # Whether the batch actions are enabled or not
    register :batch_actions, false

    # Whether filters are enabled
    register :filters, true

    # The namespace root
    register :root_to, "dashboard#index"

    # Options that are passed to root_to
    register :root_to_options, {}

    # Options passed to the routes, i.e. { path: '/custom' }
    register :route_options, {}

    # Display breadcrumbs
    register :breadcrumb, true

    # Display create another checkbox on a new page
    # @return [Boolean] (true)
    register :create_another, false

    # Default CSV options
    register :csv_options, { col_sep: ",", byte_order_mark: "\xEF\xBB\xBF" }

    # Default Download Links options
    register :download_links, true

    # The authorization adapter to use
    register :authorization_adapter, ActiveAdmin::AuthorizationAdapter

    # A proc to be used when a user is not authorized to view the current resource
    register :on_unauthorized_access, :rescue_active_admin_access_denied

    # Whether to display 'Current Filters' on search screen
    register :current_filters, true

    # class to handle ordering
    register :order_clause, ActiveAdmin::OrderClause

    # default show_count for scopes
    register :scopes_show_count, true

    # Request parameters that are permitted by default
    register :permitted_params, [
      :utf8, :_method, :authenticity_token, :commit, :id
    ]

    # Set flash message keys that shouldn't show in ActiveAdmin.
    # By default, we remove the `timedout` key from Devise.
    register :flash_keys_to_except, ["timedout"]

    # Include association filters by default
    register :include_default_association_filters, true

    register :maximum_association_filter_arity, :unlimited

    register :filter_columns_for_large_association, [
        :display_name,
        :full_name,
        :name,
        :username,
        :login,
        :title,
        :email,
    ]
    register :filter_method_for_large_association, "_start"
  end
end
