Module: Avo

Defined in:
lib/avo/view_inquirer.rb,
lib/avo.rb,
lib/avo/engine.rb,
lib/avo/plugin.rb,
lib/avo/version.rb,
lib/avo/base_action.rb,
lib/avo/cover_photo.rb,
lib/avo/test_helpers.rb,
app/avo/base_resource.rb,
lib/avo/asset_manager.rb,
lib/avo/configuration.rb,
lib/avo/error_manager.rb,
lib/avo/licensing/h_q.rb,
lib/avo/profile_photo.rb,
lib/avo/loaders/loader.rb,
lib/avo/plugin_manager.rb,
lib/avo/resources/base.rb,
lib/avo/fields/id_field.rb,
lib/avo/wait_for_loaded.rb,
lib/avo/dsl/field_parser.rb,
lib/avo/execution_context.rb,
lib/avo/fields/area_field.rb,
lib/avo/fields/base_field.rb,
lib/avo/fields/code_field.rb,
lib/avo/fields/date_field.rb,
lib/avo/fields/file_field.rb,
lib/avo/fields/tags_field.rb,
lib/avo/fields/text_field.rb,
lib/avo/fields/time_field.rb,
lib/avo/fields/trix_field.rb,
lib/avo/licensing/license.rb,
lib/avo/licensing/request.rb,
lib/avo/base_resource_tool.rb,
lib/avo/concerns/has_items.rb,
lib/avo/concerns/hydration.rb,
lib/avo/fields/badge_field.rb,
lib/avo/fields/files_field.rb,
lib/avo/fields/radio_field.rb,
lib/avo/tools/tool_manager.rb,
app/helpers/avo/url_helpers.rb,
lib/avo/concerns/is_visible.rb,
lib/avo/concerns/pagination.rb,
lib/avo/fields/hidden_field.rb,
lib/avo/fields/number_field.rb,
lib/avo/fields/select_field.rb,
lib/avo/fields/status_field.rb,
lib/avo/fields/tiptap_field.rb,
lib/avo/filters/base_filter.rb,
lib/avo/filters/text_filter.rb,
lib/avo/concerns/breadcrumbs.rb,
lib/avo/concerns/has_helpers.rb,
lib/avo/fields/boolean_field.rb,
lib/avo/fields/country_field.rb,
lib/avo/fields/field_manager.rb,
lib/avo/fields/has_one_field.rb,
lib/avo/fields/heading_field.rb,
lib/avo/fields/preview_field.rb,
lib/avo/services/uri_service.rb,
lib/avo/concerns/has_controls.rb,
lib/avo/fields/gravatar_field.rb,
lib/avo/fields/has_base_field.rb,
lib/avo/fields/has_many_field.rb,
lib/avo/fields/location_field.rb,
lib/avo/fields/markdown_field.rb,
lib/avo/fields/password_field.rb,
lib/avo/fields/textarea_field.rb,
lib/avo/filters/select_filter.rb,
lib/avo/licensing/nil_license.rb,
lib/avo/licensing/pro_license.rb,
lib/avo/loaders/fields_loader.rb,
lib/avo/loaders/scopes_loader.rb,
lib/avo/prefixed_test_helpers.rb,
lib/avo/concerns/has_item_type.rb,
lib/avo/concerns/visible_items.rb,
lib/avo/fields/date_time_field.rb,
lib/avo/fields/key_value_field.rb,
lib/avo/filters/boolean_filter.rb,
lib/avo/grid_fields/body_field.rb,
lib/avo/grid_fields/grid_field.rb,
lib/avo/loaders/actions_loader.rb,
lib/avo/loaders/filters_loader.rb,
lib/avo/fields/belongs_to_field.rb,
lib/avo/grid_fields/title_field.rb,
app/helpers/avo/resources_helper.rb,
lib/avo/concerns/has_cover_photo.rb,
lib/avo/concerns/has_description.rb,
lib/avo/concerns/request_methods.rb,
lib/avo/fields_execution_context.rb,
lib/avo/filters/date_time_filter.rb,
lib/avo/concerns/is_resource_item.rb,
lib/avo/fields/progress_bar_field.rb,
lib/avo/grid_fields/preview_field.rb,
lib/avo/licensing/license_manager.rb,
app/helpers/avo/application_helper.rb,
lib/avo/concerns/can_replace_items.rb,
lib/avo/concerns/has_profile_photo.rb,
lib/avo/fields/boolean_group_field.rb,
lib/avo/resources/resource_manager.rb,
app/controllers/avo/base_controller.rb,
app/controllers/avo/home_controller.rb,
lib/avo/concerns/controls_placement.rb,
lib/avo/fields/concerns/has_default.rb,
lib/avo/fields/concerns/is_disabled.rb,
lib/avo/fields/concerns/is_readonly.rb,
lib/avo/fields/concerns/is_required.rb,
lib/avo/fields/concerns/reload_icon.rb,
lib/avo/fields/external_image_field.rb,
lib/avo/licensing/community_license.rb,
lib/avo/services/encryption_service.rb,
app/controllers/avo/debug_controller.rb,
lib/avo/concerns/borrow_items_holder.rb,
lib/avo/fields/concerns/use_resource.rb,
app/controllers/avo/charts_controller.rb,
app/controllers/avo/search_controller.rb,
lib/avo/fields/concerns/frame_loading.rb,
lib/avo/fields/concerns/is_searchable.rb,
app/controllers/avo/actions_controller.rb,
app/controllers/avo/private_controller.rb,
lib/avo/fields/concerns/has_field_name.rb,
lib/avo/fields/concerns/linkable_title.rb,
lib/avo/filters/multiple_select_filter.rb,
lib/avo/resources/controls/back_button.rb,
lib/avo/resources/controls/edit_button.rb,
lib/avo/resources/controls/save_button.rb,
lib/avo/resources/controls/show_button.rb,
lib/avo/services/authorization_service.rb,
lib/avo/concerns/find_association_field.rb,
lib/avo/resources/controls/actions_list.rb,
lib/avo/resources/controls/base_control.rb,
app/controllers/avo/resources_controller.rb,
lib/avo/concerns/filters_session_handler.rb,
lib/avo/resources/controls/attach_button.rb,
lib/avo/resources/controls/create_button.rb,
lib/avo/resources/controls/delete_button.rb,
lib/avo/resources/controls/detach_button.rb,
lib/avo/concerns/model_class_constantized.rb,
lib/avo/resources/controls/order_controls.rb,
app/controllers/avo/application_controller.rb,
app/controllers/avo/attachments_controller.rb,
lib/avo/concerns/checks_show_authorization.rb,
lib/avo/fields/concerns/file_authorization.rb,
lib/avo/fields/concerns/handles_field_args.rb,
app/controllers/avo/associations_controller.rb,
app/helpers/avo/turbo_stream_actions_helper.rb,
lib/avo/concerns/checks_assoc_authorization.rb,
lib/avo/concerns/visible_in_different_views.rb,
lib/avo/fields/concerns/has_html_attributes.rb,
lib/avo/fields/concerns/use_view_components.rb,
app/controllers/concerns/avo/initializes_avo.rb,
lib/avo/configuration/resource_configuration.rb,
lib/avo/fields/has_and_belongs_to_many_field.rb,
app/components/avo/fields/concerns/item_labels.rb,
app/controllers/concerns/avo/common_controller.rb,
app/components/avo/index/resource_map_component.rb,
app/controllers/avo/base_application_controller.rb,
lib/avo/concerns/has_action_stimulus_controllers.rb,
lib/avo/fields/field_extensions/has_include_blank.rb,
lib/avo/concerns/has_resource_stimulus_controllers.rb

Overview

Adds the ability to set the visibility of an item in the execution context.

Defined Under Namespace

Modules: ApplicationHelper, CommonController, Concerns, Dsl, Fields, Filters, GridFields, Index, InitializesAvo, Licensing, Loaders, PrefixedTestHelpers, Resources, ResourcesHelper, Services, TestHelpers, Tools, TurboStreamActionsHelper, UrlHelpers, WaitForLoaded Classes: ActionsComponent, ActionsController, AlertComponent, ApplicationController, AssetManager, AssociationsController, AttachmentsController, BacktraceAlertComponent, BaseAction, BaseApplicationController, BaseComponent, BaseController, BaseResource, BaseResourceTool, BlankFieldComponent, ButtonComponent, ChartsController, Configuration, CoverPhoto, CoverPhotoComponent, Current, DebugController, DeprecatedAPIError, Divider, DividerComponent, EmptyStateComponent, Engine, ErrorManager, ExecutionContext, FieldWrapperComponent, FieldsExecutionContext, FiltersComponent, FlashAlertsComponent, HomeController, ItemGrapher, LicenseInvalidError, LicenseVerificationTemperedError, LoadingComponent, MissingGemError, MissingResourceError, ModalComponent, NoPolicyError, NotAuthorizedError, PaginatorComponent, PanelComponent, PanelNameComponent, PhotoObject, Plugin, PluginManager, PrivateController, ProfileItemComponent, ProfilePhoto, ProfilePhotoComponent, ReferrerParamsComponent, Reloader, ResourceComponent, ResourceSidebarComponent, ResourcesController, RowComponent, RowSelectorComponent, SearchController, SidebarComponent, SidebarProfileComponent, SvgFinder, TabGroupComponent, TabSwitcherComponent, TurboFrameWrapperComponent, ViewInquirer

Constant Summary collapse

ROOT_PATH =
Pathname.new(File.join(__dir__, ".."))
IN_DEVELOPMENT =
ENV["AVO_IN_DEVELOPMENT"] == "1"
PACKED =
!IN_DEVELOPMENT
COOKIES_KEY =
"avo"
:modal_frame
ACTIONS_BACKGROUND_FRAME =
:actions_background
CACHED_SVGS =
{}
VERSION =
"3.14.5"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cache_storeObject (readonly)

Returns the value of attribute cache_store.



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

def cache_store
  @cache_store
end

.field_managerObject (readonly)

Returns the value of attribute field_manager.



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

def field_manager
  @field_manager
end

.loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

Class Method Details

.app_statusObject



111
112
113
# File 'lib/avo.rb', line 111

def app_status
  license.valid?
end

.asset_managerObject



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

def self.asset_manager
  @manager ||= AssetManager.new
end

.avo_dynamic_filters_installed?Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/avo.rb', line 115

def avo_dynamic_filters_installed?
  defined?(Avo::DynamicFilters).present?
end

.bootObject

Runs when the app boots up



63
64
65
66
67
68
69
# File 'lib/avo.rb', line 63

def boot
  @logger = Avo.configuration.logger
  @field_manager = Avo::Fields::FieldManager.build
  @cache_store = Avo.configuration.cache_store
  ActiveSupport.run_load_hooks(:avo_boot, self)
  eager_load_actions
end

.check_rails_version_issuesObject



151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/avo.rb', line 151

def check_rails_version_issues
  if Rails.version.start_with?("7.1") && Avo.configuration.license.in?(["pro", "advanced"])
    Avo.error_manager.add({
      url: "https://docs.avohq.io/3.0/upgrade.html#upgrade-from-3-7-4-to-3-9-1",
      target: "_blank",
      message: "Due to a Rails 7.1 bug the following features won't work:\n\r
                - Dashboards\n\r
                - Ordering\n\r
                - Dynamic filters\n\r
                We recommend you upgrade to Rails 7.2\n\r
                Click banner for more information."
    })
  end
end

.configurationObject



275
276
277
# File 'lib/avo/configuration.rb', line 275

def self.configuration
  @configuration ||= Configuration.new
end

.configuration=(config) ⇒ Object



279
280
281
# File 'lib/avo/configuration.rb', line 279

def self.configuration=(config)
  @configuration = config
end

.configure {|configuration| ... } ⇒ Object

Yields:



283
284
285
# File 'lib/avo/configuration.rb', line 283

def self.configure
  yield configuration
end

.display_menu_editor_warningObject



166
167
168
169
170
171
172
173
174
# File 'lib/avo.rb', line 166

def display_menu_editor_warning
  if Avo.configuration.license == "community" && has_main_menu?
    Avo.error_manager.add({
      url: "https://docs.avohq.io/3.0/menu-editor.html",
      target: "_blank",
      message: "The menu editor is available exclusively with the Pro license or above. Consider upgrading to access this feature."
    })
  end
end

.eager_load_actionsObject



147
148
149
# File 'lib/avo.rb', line 147

def eager_load_actions
  Rails.autoloaders.main.eager_load_namespace(Avo::Actions) if defined?(Avo::Actions)
end

.extra_gemsObject



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

def extra_gems
  [:pro, :advanced, :menu, :dynamic_filters, :dashboards, :enterprise, :audits]
end

.has_main_menu?Boolean

Returns:

  • (Boolean)


119
120
121
122
123
124
# File 'lib/avo.rb', line 119

def has_main_menu?
  return false if Avo.license.lacks_with_trial(:menu_editor)
  return false if Avo.configuration.main_menu.nil?

  true
end

.has_profile_menu?Boolean

Returns:

  • (Boolean)


126
127
128
129
130
131
# File 'lib/avo.rb', line 126

def has_profile_menu?
  return false if Avo.license.lacks_with_trial(:menu_editor)
  return false if Avo.configuration.profile_menu.nil?

  true
end

.initObject

Runs on each request



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/avo.rb', line 72

def init
  Avo::Current.error_manager = Avo::ErrorManager.build
  # Check rails version issues only on NON Production environments
  unless Rails.env.production?
    check_rails_version_issues
    display_menu_editor_warning
  end
  Avo::Current.resource_manager = Avo::Resources::ResourceManager.build
  Avo::Current.tool_manager = Avo::Tools::ToolManager.build

  ActiveSupport.run_load_hooks(:avo_init, self)
end


93
94
95
96
97
98
99
100
# File 'lib/avo.rb', line 93

def main_menu
  return unless Avo.plugin_manager.installed?(:avo_menu)

  # Return empty menu if the app doesn't have the profile menu configured
  return Avo::Menu::Builder.new.build unless has_main_menu?

  Avo::Menu::Builder.parse_menu(&Avo.configuration.main_menu)
end

.mount_enginesObject

Mount all Avo engines



134
135
136
137
138
139
140
141
# File 'lib/avo.rb', line 134

def mount_engines
  -> {
    mount Avo::DynamicFilters::Engine, at: "/avo-dynamic_filters" if defined?(Avo::DynamicFilters::Engine)
    mount Avo::Dashboards::Engine, at: "/dashboards" if defined?(Avo::Dashboards::Engine)
    mount Avo::Pro::Engine, at: "/avo-pro" if defined?(Avo::Pro::Engine)
    mount Avo::Kanban::Engine, at: "/boards" if defined?(Avo::Kanban::Engine)
  }
end

.plugin_managerObject



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

def self.plugin_manager
  @plugin_manager ||= PluginManager.new
end

.profile_menuObject



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

def profile_menu
  return unless Avo.plugin_manager.installed?(:avo_menu)

  # Return empty menu if the app doesn't have the profile menu configured
  return Avo::Menu::Builder.new.build unless has_profile_menu?

  Avo::Menu::Builder.parse_menu(&Avo.configuration.profile_menu)
end

.root_path(paths: [], query: {}, **args) ⇒ Object

Generate a dynamic root path using the URIService



86
87
88
89
90
91
# File 'lib/avo.rb', line 86

def root_path(paths: [], query: {}, **args)
  Avo::Services::URIService.parse(Avo::Current.view_context.avo.root_url.to_s)
    .append_paths(paths)
    .append_query(query)
    .to_s
end