Class: Avo::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/avo/configuration.rb

Defined Under Namespace

Classes: Appearance

Constant Summary collapse

CONTAINER_WIDTH_DEFAULTS =
{
  index: :lg,
  show: :md,
  new: :md,
  edit: :md,
  create: :md,
  update: :md
}.freeze
VALID_CONTAINER_WIDTHS =
%i[full lg md sm].freeze
DEPRECATED_CONTAINER_WIDTHS =

Avo 4.1 renamed the widths onto Tailwind's scale so the vocabulary matches every other size option (size: :sm, width: :xl, ...). Note :small maps to :md, not :sm — the rename kept the old width and freed the narrower names. The old names still work and warn; drop them in Avo 5.

{large: :lg, small: :md}.freeze
CONTAINER_WIDTH_GROUPS =
{
  forms: %i[new edit create update],
  display: %i[index show],
  single: %i[show new edit create update]
}.freeze
RESOURCE_ROW_CONTROLS_CONFIG_DEFAULTS =
{
  placement: :right,
  float: false,
  show_on_hover: false
}.freeze
HOTKEYS_DEFAULTS =
{
  enabled: true,
  show_key_badges: true
}.freeze
BACK_TO_TOP_DEFAULTS =
{
  enabled: true,
  threshold: 400
}.freeze
{
  toggle_visible: true,
  resizable: true
}.freeze
MAP_VIEW_DEFAULTS =
{
  styles: nil
}.freeze
ASSOCIATIONS_DEFAULTS =
{
  lookup_list_limit: 1000,
  frames: {
    loading: :lazy,
    # 15 minutes, in seconds. Kept as a literal (not `15.minutes`) because
    # this constant is evaluated at require time, before ActiveSupport's
    # `Integer#minutes` core extension is guaranteed to be loaded.
    auto_load_for: 15 * 60
  }
}.freeze
RTL_LOCALES =

Known RTL (Right-to-Left) locale codes

%w[ar he fa ur yi ps sd ku ckb ug dv].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/avo/configuration.rb', line 154

def initialize
  @root_path = "/avo"
  @app_name = ::Rails.application.class.to_s.split("::").first.underscore.humanize(keep_id_suffix: true)
  @timezone = "UTC"
  @per_page = 24
  @per_page_steps = [12, 24, 48, 72]
  @via_per_page = 8
  @locale = nil
  @currency = "USD"
  @default_view_type = :table
  @map_view = {}
  @license_key = nil
  @current_user = proc {}
  @authenticate = proc {}
  @explicit_authorization = true
  @authorization_methods = {
    index: "index?",
    show: "show?",
    edit: "edit?",
    new: "new?",
    update: "update?",
    create: "create?",
    destroy: "destroy?"
  }
  @id_links_to_resource = false
  @cache_resources_on_index_view = Avo::PACKED
  @persistence = {
    driver: nil
  }
  @context = proc {}
  @initial_breadcrumbs = proc {
    add_breadcrumb title: I18n.t("avo.home").humanize, path: avo.root_path, icon: "tabler/outline/home"
  }
  @hide_layout_when_printing = false
  @home_path = nil
  @search_debounce = 300
  @view_component_path = "app/components"
  @display_license_request_timeout_error = true
  @current_user_resource_name = "user"
  @raise_error_on_missing_policy = false
  @buttons_on_form_footers = false
  @main_menu = nil
  @profile_menu = nil
  @header_menu = nil
  @model_resource_mapping = {}
  @resource_default_view = Avo::ViewInquirer.new("show")
  @authorization_client = :pundit
  @field_wrapper_layout = :inline
  @resources = nil
  @resource_parent_controller = "Avo::ResourcesController"
  @cache_store = computed_cache_store
  @logger = default_logger
  @turbo = default_turbo
  @default_url_options = []
  @pagination = {}
  @click_row_to_view_record = true
  @density = :normal
  @alert_dismiss_time = 5000
  @is_admin_method = :is_admin?
  @is_developer_method = :is_developer?
  @search_results_count = 8
  @first_sorting_option = :desc # :desc or :asc
  @exclude_from_status = ["license_key"]
  @column_names_mapping = {}
  @column_types_mapping = {}
  @resource_row_controls_config = {}
  @hotkeys = {}
  @back_to_top = {}
  @associations = {}
  @global_search = {
    enabled: true,
    navigation_section: true
  }
  @model_generator_hook = true
  @send_metadata = true
  @use_stacked_fields = false
  # Off in the test environment: the first-load cookie handshake soft-reloads
  # the page through Turbo, which races browser specs (stale nodes, doubled
  # requests). Apps can still opt in per example.
  @use_browser_timezone = !Rails.env.test?
  @default_editor_url = "cursor://file/%{path}"
  @sidebar = {}
  @body_classes = []
  @tailwindcss_integration_enabled = true
  @mount_lookbook = false
end

Instance Attribute Details

#alert_dismiss_timeObject

Returns the value of attribute alert_dismiss_time.



57
58
59
# File 'lib/avo/configuration.rb', line 57

def alert_dismiss_time
  @alert_dismiss_time
end

#app_nameObject



400
401
402
# File 'lib/avo/configuration.rb', line 400

def app_name
  Avo::ExecutionContext.new(target: @app_name).handle
end

#associationsObject



338
339
340
# File 'lib/avo/configuration.rb', line 338

def associations
  ASSOCIATIONS_DEFAULTS.deep_merge(@associations)
end

#authenticateObject

Returns the value of attribute authenticate.



28
29
30
# File 'lib/avo/configuration.rb', line 28

def authenticate
  @authenticate
end

#authorization_clientObject

Returns the value of attribute authorization_client.



48
49
50
# File 'lib/avo/configuration.rb', line 48

def authorization_client
  @authorization_client
end

#authorization_methodsObject

Returns the value of attribute authorization_methods.



27
28
29
# File 'lib/avo/configuration.rb', line 27

def authorization_methods
  @authorization_methods
end

#back_to_topObject



330
331
332
# File 'lib/avo/configuration.rb', line 330

def back_to_top
  BACK_TO_TOP_DEFAULTS.merge @back_to_top
end

#body_classesObject



500
501
502
# File 'lib/avo/configuration.rb', line 500

def body_classes
  Avo::ExecutionContext.new(target: @body_classes).handle
end

#buttons_on_form_footersObject

Returns the value of attribute buttons_on_form_footers.



42
43
44
# File 'lib/avo/configuration.rb', line 42

def buttons_on_form_footers
  @buttons_on_form_footers
end

#cache_resources_on_index_viewObject

Returns the value of attribute cache_resources_on_index_view.



31
32
33
# File 'lib/avo/configuration.rb', line 31

def cache_resources_on_index_view
  @cache_resources_on_index_view
end

#cache_storeObject



408
409
410
411
412
413
# File 'lib/avo/configuration.rb', line 408

def cache_store
  Avo::ExecutionContext.new(
    target: @cache_store,
    production_rejected_cache_stores: %w[ActiveSupport::Cache::MemoryStore ActiveSupport::Cache::NullStore]
  ).handle
end

#click_row_to_view_recordObject

Returns the value of attribute click_row_to_view_record.



55
56
57
# File 'lib/avo/configuration.rb', line 55

def click_row_to_view_record
  @click_row_to_view_record
end

#column_names_mappingObject

Returns the value of attribute column_names_mapping.



62
63
64
# File 'lib/avo/configuration.rb', line 62

def column_names_mapping
  @column_names_mapping
end

#column_types_mappingObject

Returns the value of attribute column_types_mapping.



63
64
65
# File 'lib/avo/configuration.rb', line 63

def column_types_mapping
  @column_types_mapping
end

#contextObject

Returns the value of attribute context.



32
33
34
# File 'lib/avo/configuration.rb', line 32

def context
  @context
end

#currencyObject

Returns the value of attribute currency.



24
25
26
# File 'lib/avo/configuration.rb', line 24

def currency
  @currency
end

#current_userObject

Returns the value of attribute current_user.



29
30
31
# File 'lib/avo/configuration.rb', line 29

def current_user
  @current_user
end

#current_user_resource_nameObject

Returns the value of attribute current_user_resource_name.



39
40
41
# File 'lib/avo/configuration.rb', line 39

def current_user_resource_name
  @current_user_resource_name
end

#default_editor_urlObject

Returns the value of attribute default_editor_url.



68
69
70
# File 'lib/avo/configuration.rb', line 68

def default_editor_url
  @default_editor_url
end

#default_url_optionsObject

Returns the value of attribute default_url_options.



54
55
56
# File 'lib/avo/configuration.rb', line 54

def default_url_options
  @default_url_options
end

#default_view_typeObject

Returns the value of attribute default_view_type.



25
26
27
# File 'lib/avo/configuration.rb', line 25

def default_view_type
  @default_view_type
end

#densityObject

Returns the value of attribute density.



56
57
58
# File 'lib/avo/configuration.rb', line 56

def density
  @density
end

#display_license_request_timeout_errorObject

Returns the value of attribute display_license_request_timeout_error.



38
39
40
# File 'lib/avo/configuration.rb', line 38

def display_license_request_timeout_error
  @display_license_request_timeout_error
end

#exclude_from_statusObject



458
459
460
# File 'lib/avo/configuration.rb', line 458

def exclude_from_status
  Avo::ExecutionContext.new(target: @exclude_from_status).handle
end

#explicit_authorizationObject



496
497
498
# File 'lib/avo/configuration.rb', line 496

def explicit_authorization
  Avo::ExecutionContext.new(target: @explicit_authorization).handle
end

#field_wrapper_layoutObject

Returns the value of attribute field_wrapper_layout.



49
50
51
# File 'lib/avo/configuration.rb', line 49

def field_wrapper_layout
  @field_wrapper_layout
end

#first_sorting_optionObject

Returns the value of attribute first_sorting_option.



61
62
63
# File 'lib/avo/configuration.rb', line 61

def first_sorting_option
  @first_sorting_option
end

#global_searchObject

Returns the value of attribute global_search.



41
42
43
# File 'lib/avo/configuration.rb', line 41

def global_search
  @global_search
end

#header_menuObject

Returns the value of attribute header_menu.



45
46
47
# File 'lib/avo/configuration.rb', line 45

def header_menu
  @header_menu
end

#hide_layout_when_printingObject

Returns the value of attribute hide_layout_when_printing.



33
34
35
# File 'lib/avo/configuration.rb', line 33

def hide_layout_when_printing
  @hide_layout_when_printing
end

#home_pathObject

Returns the value of attribute home_path.



35
36
37
# File 'lib/avo/configuration.rb', line 35

def home_path
  @home_path
end

#hotkeysObject



326
327
328
# File 'lib/avo/configuration.rb', line 326

def hotkeys
  HOTKEYS_DEFAULTS.merge @hotkeys
end

Returns the value of attribute id_links_to_resource.



30
31
32
# File 'lib/avo/configuration.rb', line 30

def id_links_to_resource
  @id_links_to_resource
end

#initial_breadcrumbsObject

Returns the value of attribute initial_breadcrumbs.



34
35
36
# File 'lib/avo/configuration.rb', line 34

def initial_breadcrumbs
  @initial_breadcrumbs
end

#is_admin_methodObject

Returns the value of attribute is_admin_method.



58
59
60
# File 'lib/avo/configuration.rb', line 58

def is_admin_method
  @is_admin_method
end

#is_developer_methodObject

Returns the value of attribute is_developer_method.



59
60
61
# File 'lib/avo/configuration.rb', line 59

def is_developer_method
  @is_developer_method
end

#license_keyObject

Returns the value of attribute license_key.



26
27
28
# File 'lib/avo/configuration.rb', line 26

def license_key
  @license_key
end

#localeObject

Returns the value of attribute locale.



23
24
25
# File 'lib/avo/configuration.rb', line 23

def locale
  @locale
end

#loggerObject



435
436
437
# File 'lib/avo/configuration.rb', line 435

def logger
  Avo::ExecutionContext.new(target: @logger).handle
end

Returns the value of attribute main_menu.



43
44
45
# File 'lib/avo/configuration.rb', line 43

def main_menu
  @main_menu
end

#map_viewObject



334
335
336
# File 'lib/avo/configuration.rb', line 334

def map_view
  MAP_VIEW_DEFAULTS.merge @map_view
end

#model_generator_hookObject

Returns the value of attribute model_generator_hook.



64
65
66
# File 'lib/avo/configuration.rb', line 64

def model_generator_hook
  @model_generator_hook
end

#model_resource_mappingObject

Returns the value of attribute model_resource_mapping.



46
47
48
# File 'lib/avo/configuration.rb', line 46

def model_resource_mapping
  @model_resource_mapping
end

#mount_lookbookObject

Returns the value of attribute mount_lookbook.



72
73
74
# File 'lib/avo/configuration.rb', line 72

def mount_lookbook
  @mount_lookbook
end

#paginationObject



470
471
472
# File 'lib/avo/configuration.rb', line 470

def pagination
  Avo::ExecutionContext.new(target: @pagination).handle
end

#per_pageObject

Returns the value of attribute per_page.



20
21
22
# File 'lib/avo/configuration.rb', line 20

def per_page
  @per_page
end

#per_page_stepsObject

Returns the value of attribute per_page_steps.



21
22
23
# File 'lib/avo/configuration.rb', line 21

def per_page_steps
  @per_page_steps
end

#persistenceObject



528
529
530
# File 'lib/avo/configuration.rb', line 528

def persistence
  Avo::ExecutionContext.new(target: @persistence).handle
end

#prefix_pathObject

Returns the value of attribute prefix_path.



52
53
54
# File 'lib/avo/configuration.rb', line 52

def prefix_path
  @prefix_path
end

#profile_menuObject

Returns the value of attribute profile_menu.



44
45
46
# File 'lib/avo/configuration.rb', line 44

def profile_menu
  @profile_menu
end

#raise_error_on_missing_policyObject

Returns the value of attribute raise_error_on_missing_policy.



40
41
42
# File 'lib/avo/configuration.rb', line 40

def raise_error_on_missing_policy
  @raise_error_on_missing_policy
end

#resource_default_viewObject

Returns the value of attribute resource_default_view.



47
48
49
# File 'lib/avo/configuration.rb', line 47

def resource_default_view
  @resource_default_view
end

#resource_parent_controllerObject

Returns the value of attribute resource_parent_controller.



53
54
55
# File 'lib/avo/configuration.rb', line 53

def resource_parent_controller
  @resource_parent_controller
end

#resource_row_controls_configObject



322
323
324
# File 'lib/avo/configuration.rb', line 322

def resource_row_controls_config
  RESOURCE_ROW_CONTROLS_CONFIG_DEFAULTS.merge @resource_row_controls_config
end

#resourcesObject

Returns the value of attribute resources.



51
52
53
# File 'lib/avo/configuration.rb', line 51

def resources
  @resources
end

#root_pathObject



386
387
388
389
390
# File 'lib/avo/configuration.rb', line 386

def root_path
  return "" if @root_path === "/"

  @root_path
end

#search_debounceObject

Returns the value of attribute search_debounce.



36
37
38
# File 'lib/avo/configuration.rb', line 36

def search_debounce
  @search_debounce
end

#search_results_countObject

Returns the value of attribute search_results_count.



60
61
62
# File 'lib/avo/configuration.rb', line 60

def search_results_count
  @search_results_count
end

#send_metadataObject

Returns the value of attribute send_metadata.



65
66
67
# File 'lib/avo/configuration.rb', line 65

def 
  @send_metadata
end

default_width is clamped into the same [SIDEBAR_WIDTH_MIN, SIDEBAR_WIDTH_MAX] range the drag and the persisted cookie use — outside it the sidebar would start at a width the handle cannot drag back to, and aria-valuenow would sit outside its own declared min/max. Anything unparseable falls back to the built-in default rather than clamping to the minimum, so a typo does not silently ship a 200px sidebar. The bounds constants stay private (lib/avo.rb): this hash is the only host-facing knob.



511
512
513
514
515
516
# File 'lib/avo/configuration.rb', line 511

def sidebar
  config = SIDEBAR_DEFAULTS.merge(@sidebar)
  width = Integer(config[:default_width], exception: false)&.clamp(SIDEBAR_WIDTH_MIN, SIDEBAR_WIDTH_MAX)

  config.merge(default_width: width || SIDEBAR_WIDTH_DEFAULT)
end

#sign_out_path_nameObject

Returns the value of attribute sign_out_path_name.



50
51
52
# File 'lib/avo/configuration.rb', line 50

def sign_out_path_name
  @sign_out_path_name
end

#tailwindcss_content_sourcesObject



146
147
148
149
150
151
152
# File 'lib/avo/configuration.rb', line 146

def tailwindcss_content_sources
  if @tailwindcss_content_sources.nil?
    [Rails.root.join("app")]
  else
    Array(@tailwindcss_content_sources)
  end
end

#tailwindcss_integration_enabledObject

Returns the value of attribute tailwindcss_integration_enabled.



71
72
73
# File 'lib/avo/configuration.rb', line 71

def tailwindcss_integration_enabled
  @tailwindcss_integration_enabled
end

#timezoneObject

Returns the value of attribute timezone.



19
20
21
# File 'lib/avo/configuration.rb', line 19

def timezone
  @timezone
end

#turboObject



454
455
456
# File 'lib/avo/configuration.rb', line 454

def turbo
  Avo::ExecutionContext.new(target: @turbo).handle
end

#use_browser_timezoneObject

Returns the value of attribute use_browser_timezone.



67
68
69
# File 'lib/avo/configuration.rb', line 67

def use_browser_timezone
  @use_browser_timezone
end

#use_stacked_fieldsObject

Returns the value of attribute use_stacked_fields.



66
67
68
# File 'lib/avo/configuration.rb', line 66

def use_stacked_fields
  @use_stacked_fields
end

#via_per_pageObject

Returns the value of attribute via_per_page.



22
23
24
# File 'lib/avo/configuration.rb', line 22

def via_per_page
  @via_per_page
end

#view_component_pathObject

Returns the value of attribute view_component_path.



37
38
39
# File 'lib/avo/configuration.rb', line 37

def view_component_path
  @view_component_path
end

Class Method Details

.normalize_container_width(value) ⇒ Object

Single funnel for every container width that enters Avo — config.container_width= and the controllers' mark_container_width. Unknown values pass through untouched so each caller keeps raising its own ArgumentError.



102
103
104
105
106
107
108
# File 'lib/avo/configuration.rb', line 102

def self.normalize_container_width(value)
  replacement = DEPRECATED_CONTAINER_WIDTHS[value.respond_to?(:to_sym) ? value.to_sym : value]
  return value if replacement.nil?

  Avo.logger.warn "[Avo] Container width `:#{value}` is deprecated and will be removed in Avo 5. Use `:#{replacement}` instead."
  replacement
end

.rtl_locale?(locale = I18n.locale) ⇒ Boolean

Check if the given locale is RTL

Returns:

  • (Boolean)


482
483
484
# File 'lib/avo/configuration.rb', line 482

def self.rtl_locale?(locale = I18n.locale)
  RTL_LOCALES.include?(locale.to_s.split("-").first.downcase)
end

Instance Method Details

#appearanceObject



392
393
394
# File 'lib/avo/configuration.rb', line 392

def appearance
  @appearance ||= Avo::Configuration::Appearance.new
end

#appearance=(options = {}) ⇒ Object



396
397
398
# File 'lib/avo/configuration.rb', line 396

def appearance=(options = {})
  @appearance = Avo::Configuration::Appearance.new(options)
end

#associations_lookup_list_limitObject

Backward-compatible flat accessor — the canonical home is now config.associations[:lookup_list_limit].



344
345
346
# File 'lib/avo/configuration.rb', line 344

def associations_lookup_list_limit
  associations[:lookup_list_limit]
end

#associations_lookup_list_limit=(value) ⇒ Object



348
349
350
# File 'lib/avo/configuration.rb', line 348

def associations_lookup_list_limit=(value)
  @associations[:lookup_list_limit] = value
end

#authenticate_with(&block) ⇒ Object



366
367
368
# File 'lib/avo/configuration.rb', line 366

def authenticate_with(&block)
  @authenticate = block if block.present?
end

#authorization_enabled?Boolean

Authorization is enabled when: (avo-authorization gem is installed) AND (authorization_client is NOT nil)

Returns:

  • (Boolean)


354
355
356
# File 'lib/avo/configuration.rb', line 354

def authorization_enabled?
  @authorization_enabled ||= Avo.plugin_manager.installed?("avo-authorization") && !authorization_client.nil?
end

#computed_cache_storeObject

When not in production we'll just use the FileStore which is good enough. When running in production we'll use Rails.cache if it's not ActiveSupport::Cache::MemoryStore or ActiveSupport::Cache::NullStore. If it's one of rejected cache stores, we'll use the FileStore. We decided against the MemoryStore in production because it will not be shared between multiple processes (when using Puma).



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/avo/configuration.rb', line 419

def computed_cache_store
  file_store_instance = ActiveSupport::Cache.lookup_store(:file_store, Rails.root.join("tmp", "cache"))

  -> {
    if Rails.env.production?
      if Rails.cache.class.to_s.in?(production_rejected_cache_stores)
        file_store_instance
      else
        Rails.cache
      end
    else
      file_store_instance
    end
  }
end

#container_widthObject



142
143
144
# File 'lib/avo/configuration.rb', line 142

def container_width
  @container_width || CONTAINER_WIDTH_DEFAULTS
end

#container_width=(value) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/avo/configuration.rb', line 110

def container_width=(value)
  case value
  when NilClass
    @container_width = nil
  when Symbol
    value = self.class.normalize_container_width(value)
    raise ArgumentError, "Invalid container width: #{value}. Must be one of #{VALID_CONTAINER_WIDTHS}" unless VALID_CONTAINER_WIDTHS.include?(value)
    @container_width = CONTAINER_WIDTH_DEFAULTS.transform_values { value }
  when Hash
    valid_keys = CONTAINER_WIDTH_DEFAULTS.keys + CONTAINER_WIDTH_GROUPS.keys
    invalid_keys = value.keys.reject { |k| valid_keys.include?(k) }
    raise ArgumentError, "Invalid container width keys: #{invalid_keys}. Valid keys: #{valid_keys}" if invalid_keys.any?

    value = value.transform_values { |v| self.class.normalize_container_width(v) }

    invalid_values = value.values.reject { |v| VALID_CONTAINER_WIDTHS.include?(v) }
    raise ArgumentError, "Invalid container widths: #{invalid_values}" if invalid_values.any?

    # Expand group aliases first
    expanded_aliases = value
      .select { |k, _| CONTAINER_WIDTH_GROUPS.key?(k) }
      .each_with_object({}) do |(alias_key, width), result|
        CONTAINER_WIDTH_GROUPS[alias_key].each { |view| result[view] = width }
      end

    # Specific keys win over group aliases
    specific_keys = value.reject { |k, _| CONTAINER_WIDTH_GROUPS.key?(k) }

    @container_width = CONTAINER_WIDTH_DEFAULTS.merge(expanded_aliases).merge(specific_keys)
  end
end

#current_user_method(&block) ⇒ Object



358
359
360
# File 'lib/avo/configuration.rb', line 358

def current_user_method(&block)
  @current_user = block if block.present?
end

#current_user_method=(method) ⇒ Object



362
363
364
# File 'lib/avo/configuration.rb', line 362

def current_user_method=(method)
  @current_user = method if method.present?
end

#default_localeObject



474
475
476
# File 'lib/avo/configuration.rb', line 474

def default_locale
  @locale || I18n.default_locale
end

#default_loggerObject



439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/avo/configuration.rb', line 439

def default_logger
  -> {
    file_logger = ActiveSupport::Logger.new(Rails.root.join("log", "avo.log"))

    file_logger.datetime_format = "%Y-%m-%d %H:%M:%S"
    file_logger.formatter = proc do |severity, time, progname, msg|
      "[Avo->] #{time}: #{msg}\n".tap do |i|
        puts i
      end
    end

    file_logger
  }
end

#default_turboObject



462
463
464
465
466
467
468
# File 'lib/avo/configuration.rb', line 462

def default_turbo
  -> do
    {
      instant_click: true
    }
  end
end

#header_menu_itemsObject

Returns the Link items produced by evaluating the header_menu lambda. Empty when unset or when avo-menu (which owns the DSL) isn't installed.



544
545
546
547
548
549
550
551
# File 'lib/avo/configuration.rb', line 544

def header_menu_items
  return [] if @header_menu.nil?
  return [] unless Avo.plugin_manager.installed?("avo-menu")

  Avo::Menu::Builder.parse_menu(&@header_menu).items.select do |item|
    item.is_a?(Avo::Menu::Link)
  end
end

#mount_avo_engines=Object



536
537
538
539
540
# File 'lib/avo/configuration.rb', line 536

def mount_avo_engines=(...)
  raise "'mount_avo_engines' option is now obsolete. \n" \
    "Please refer to the upgrade guide for details on the new mounting point: \n" \
    "https://docs.avohq.io/3.0/upgrade.html#Avo's%20mounting%20point%20update"
end

#namespaceObject



378
379
380
381
382
383
384
# File 'lib/avo/configuration.rb', line 378

def namespace
  if Avo.configuration.root_path.present?
    Avo.configuration.root_path.delete "/"
  else
    root_path.delete "/"
  end
end

#rtl?Boolean

Check if the current locale is RTL

Returns:

  • (Boolean)


487
488
489
# File 'lib/avo/configuration.rb', line 487

def rtl?
  self.class.rtl_locale?(I18n.locale)
end

#session_persistence_enabled?Boolean

Returns:

  • (Boolean)


532
533
534
# File 'lib/avo/configuration.rb', line 532

def session_persistence_enabled?
  persistence[:driver] == :session
end

#set_context(&block) ⇒ Object



370
371
372
# File 'lib/avo/configuration.rb', line 370

def set_context(&block)
  @context = block if block.present?
end

#set_initial_breadcrumbs(&block) ⇒ Object



374
375
376
# File 'lib/avo/configuration.rb', line 374

def set_initial_breadcrumbs(&block)
  @initial_breadcrumbs = block if block.present?
end

Backward-compatible flat accessor — the canonical home is now config.sidebar[:toggle_visible].



520
521
522
# File 'lib/avo/configuration.rb', line 520

def sidebar_toggle_visible
  sidebar[:toggle_visible]
end


524
525
526
# File 'lib/avo/configuration.rb', line 524

def sidebar_toggle_visible=(value)
  @sidebar[:toggle_visible] = value
end

#text_directionObject

Returns "rtl" or "ltr" based on current locale



492
493
494
# File 'lib/avo/configuration.rb', line 492

def text_direction
  rtl? ? "rtl" : "ltr"
end