### One-Command Avo Installation Source: https://docs.avohq.io/3.0/llms-full.txt Use this command to install Avo with a pre-configured app template. This automates the setup process. ```bash bin/rails app:template LOCATION='https://avohq.io/app-template' ``` -------------------------------- ### Install Avo with Jumpstart Pro Template Source: https://docs.avohq.io/3.0/llms-full.txt Use this command to install Avo in a Jumpstart Pro application using a dedicated template. ```bash bin/rails app:template LOCATION=https://v3.avohq.io/templates/jumpstart-pro.template ``` -------------------------------- ### Run Bundle Install Source: https://avohq.io/templates/jumpstart-pro Executes `bundle install` to install the Avo gem and its dependencies. This command ensures that all necessary gems are available for Avo to function correctly. ```ruby # === Run bundle install === Bundler.with_unbundled_env { run "bundle install" } ``` -------------------------------- ### Install Avo Kanban Gem Source: https://docs.avohq.io/3.0/llms-full.txt Run this command in your terminal after adding the gem to your Gemfile to install it. ```bash bundle install ``` -------------------------------- ### Docker Build Argument Examples Source: https://docs.avohq.io/3.0/llms-full.txt Examples of how to pass the BUNDLE_PACKAGER__DEV token to Docker builds, either directly or via an environment variable set in your shell configuration. ```bash # Pass the key to the build argument docker build --build-arg BUNDLE_PACKAGER__DEV=xxx # OR # Set the key as an environment variable on your machine # Somewhere in your `.bashrc` or `.bash_profile` file export BUNDLE_PACKAGER__DEV=xxx # Then pass it to the build argument from there docker build --build-arg BUNDLE_PACKAGER__DEV=$BUNDLE_PACKAGER__DEV ``` -------------------------------- ### Install Solid Cache Migrations Source: https://docs.avohq.io/3.0/llms-full.txt Run the Solid Cache migration generator and then migrate the database to set up the necessary tables for Solid Cache. ```bash $ bin/rails solid_cache:install:migrations $ bin/rails db:migrate ``` -------------------------------- ### Example Resource Definition with View-Specific Fields Source: https://docs.avohq.io/3.0/llms-full.txt Define a resource with fields tailored for index, show, create, and edit views using Avo's DSL. This example demonstrates how to include a concern for extended functionality. ```ruby class ExampleResource < Avo::BaseResource include ResourceExtensions field :id, as: :id field :name, as: :text index do field :some_field, as: :text field :some_index_field, as: :text, sortable: true end show do field :some_show_field, as: :markdown field :some_field, as: :text end create do field :some_create_field, as: :number end edit do field :some_create_field, as: :number, readonly: true field :some_field field :some_editable_field, as: :text end end ``` -------------------------------- ### Install Pundit Source: https://docs.avohq.io/3.0/llms-full.txt Run this command to install the Pundit gem if it's not already present in your application. ```bash bin/rails g pundit:install ``` -------------------------------- ### Install Avo JS Assets with Importmap Source: https://docs.avohq.io/3.0/llms-full.txt Run this command to install custom JS assets for Avo using importmap. It creates an entrypoint, adds it to Avo's head partial, and pins it in importmap.rb. ```bash bin/rails generate avo:js:install ``` -------------------------------- ### Example Translation File for pt-BR Source: https://docs.avohq.io/3.0/llms-full.txt An example of a translation file for Brazilian Portuguese (pt-BR), demonstrating how to localize field and resource names with pluralization. ```yaml # config/locales/avo.pt-BR.yml pt-BR: avo: field_translations: file: zero: 'arquivos' one: 'arquivo' other: 'arquivos' resource_translations: user: zero: 'usuários' one: 'usuário' other: 'usuários' ``` -------------------------------- ### Defining a Resource File Source: https://docs.avohq.io/3.0/resources.html Example of a resource file that inherits from the custom `Avo::BaseResource`. ```ruby # app/avo/resources/post_resource.rb module Avo::Resources::Post < Avo::BaseResource # Your existing configuration for the Post resource end ``` -------------------------------- ### Install Avo with Optional Gems Source: https://docs.avohq.io/3.0/llms-full.txt Use this command to install Avo and its optional gems. This is useful for distributing your Rails app without paid gems. ```bash RAILS_GROUPS=avo BUNDLE_WITH=avo bundle install ``` -------------------------------- ### Generate Avo Actions with Options Source: https://docs.avohq.io/3.0/llms-full.txt Examples demonstrating how to generate regular actions, standalone actions, and actions within a namespace using the Avo generator. ```bash # Generate a regular action bin/rails generate avo:action mark_as_featured # Generate a standalone action bin/rails generate avo:action generate_monthly_report --standalone # Generate an action in a namespace bin/rails generate avo:action admin/approve_user ``` -------------------------------- ### Resource Translation YAML Example Source: https://docs.avohq.io/3.0/llms-full.txt Example YAML file for translating resource names, providing pluralization rules (zero, one, other) for a specific locale. ```yaml es: avo: dashboard: 'Dashboard' # ... other translation keys resource_translations: user: zero: 'usuarios' one: 'usuario' other: 'usuarios' ``` -------------------------------- ### Vitepress Recipe Data Import Source: https://docs.avohq.io/3.0/llms-full.txt This script setup imports data from a local Vitepress recipe file. It's used to dynamically populate guides and articles within the documentation. ```javascript import { data } from './../.vitepress/recipes.data.js' // add guides written on the blog const articles = [ { title: "Override the field method to add default values to field options", link: "https://avohq.io/blog/override-the-field-method-to-add-default-values-to-field-options" }, { title: "Implement soft-delete in Rails with Avo + Discard", link: "https://greenhats.medium.com/implement-soft-delete-in-rails-with-avo-discard-bc33d1e84e79" } ] ``` -------------------------------- ### Run Database Migrations for Kanban Source: https://docs.avohq.io/3.0/llms-full.txt Apply the database changes generated by the avo:kanban install command by running this migration command. ```bash rails db:migrate ``` -------------------------------- ### Install Avo with Bullet Train Template Source: https://docs.avohq.io/3.0/llms-full.txt Use this command to install Avo in a Bullet Train application using a dedicated template. ```bash bin/rails app:template LOCATION=https://v3.avohq.io/templates/bullet-train.template ``` -------------------------------- ### Configure filter to apply on select with custom options Source: https://docs.avohq.io/3.0/llms-full.txt This example shows a filter that applies immediately on selection and uses a predefined list of options. ```ruby field :priority, as: :select, filterable: { apply_on_select: true, render_apply_button: false, options: ["high", "medium", "low"] } ``` -------------------------------- ### Set Up ViewComponent Logging Source: https://docs.avohq.io/3.0/llms-full.txt Configure a custom `LogSubscriber` in `config/initializers/view_component.rb` to log ViewComponent render times and allocations. This setup captures performance metrics for each rendered component. ```ruby module ViewComponent class LogSubscriber < ActiveSupport::LogSubscriber define_method :'!render' do |event| info do message = +" Rendered #{event.payload[:name]}" message << " (Duration: #{event.duration.round(1)}ms" message << " | Allocations: #{event.allocations})" end end end end ViewComponent::LogSubscriber.attach_to :view_component ``` -------------------------------- ### Install TailwindCSS Integration Source: https://docs.avohq.io/3.0/llms-full.txt Run this command to install TailwindCSS integration for Avo. It sets up configuration files, generates necessary stylesheets, and configures build processes. ```bash bin/rails generate avo:tailwindcss:install ``` -------------------------------- ### Install Avo JS Assets with js-bundling and esbuild Source: https://docs.avohq.io/3.0/llms-full.txt Use this command to install custom JS assets for Avo when using js-bundling with esbuild. It ejects the head partial, adds the custom JS asset, and creates the entrypoint file. ```bash bin/rails generate avo:js:install --bundler esbuild ``` -------------------------------- ### Example Card Class for Resource Views Source: https://docs.avohq.io/3.0/llms-full.txt An example of a custom card class that can be used within resource views. It defines properties like ID, label, prefix, formatting, and a query method. ```ruby class Avo::Cards::AmountRaised < Avo::Cards::MetricCard self.id = "amount_raised" self.label = "Amount raised" self.prefix = "$" self.format = -> { number_to_social value, start_at: 1_000 } def query result 9001 end end ``` -------------------------------- ### Time Field Configuration Source: https://docs.avohq.io/3.0/llms-full.txt Example of configuring a Time field with specific formatting and picker options. ```ruby field :starting_at, as: :time, picker_format: 'H:i', format: "HH:mm", relative: true, picker_options: { time_24hr: true } ``` -------------------------------- ### Badge Field with Custom Options (Concise) Source: https://docs.avohq.io/3.0/llms-full.txt A concise example demonstrating how to configure a Badge field with custom options, mapping specific values to visual states. ```ruby field :stage, as: :badge, options: { info: [:discovery, :idea], success: :done, warning: 'on hold', danger: :cancelled, neutral: :drafting } ``` -------------------------------- ### Build Avo Assets from GitHub Installation Source: https://docs.avohq.io/3.0/llms-full.txt When installing Avo from GitHub, you must compile assets manually. This Rake task enhances the `assets:precompile` step to include Avo assets. ```ruby # Rakefile Rake::Task["assets:precompile"].enhance do Rake::Task["avo:build-assets"].execute end ``` -------------------------------- ### Custom field definition with properties Source: https://docs.avohq.io/3.0/llms-full.txt Example of a custom field definition that includes initialization of properties like `link_to_record`, `as_html`, and `protocol`. ```ruby # app/avo/fields/super_text_field.rb module Avo module Fields class SuperTextField < BaseField attr_reader :link_to_record attr_reader :as_html attr_reader :protocol def initialize(id, **args, &block) super(id, **args, &block) add_boolean_prop args, :link_to_record add_boolean_prop args, :as_html add_string_prop args, :protocol end end end end ``` -------------------------------- ### Adding a Description to a Tabs Group Source: https://docs.avohq.io/3.0/llms-full.txt This example shows how to provide an auxiliary explanation or detailed note for a group of tabs using the 'description' option. ```ruby tabs description: "Tabs group description" do # ... end ``` -------------------------------- ### Generate a Users Metric Card Source: https://docs.avohq.io/3.0/llms-full.txt Generates a basic metric card for displaying user counts. This is the initial setup for a metric card. ```ruby class Avo::Cards::UsersMetric < Avo::Cards::MetricCard self.id = 'users_metric' self.label = 'Users count' self.description = 'Some tiny description' self.cols = 1 # self.rows = 1 # self.initial_range = 30 # self.ranges = { # "7 days": 7, # "30 days": 30, # "60 days": 60, # "365 days": 365, # Today: "TODAY", # "Month to date": "MTD", # "Quarter to date": "QTD", # "Year to date": "YTD", # All: "ALL", # } # self.prefix = '$' # self.suffix = '%' # self.refresh_every = 10.minutes def query from = Date.today.midnight - 1.week to = DateTime.current if range.present? if range.to_s == range.to_i.to_s from = DateTime.current - range.to_i.days else case range when 'TODAY' from = DateTime.current.beginning_of_day when 'MTD' from = DateTime.current.beginning_of_month when 'QTD' from = DateTime.current.beginning_of_quarter when 'YTD' from = DateTime.current.beginning_of_year when 'ALL' from = Time.at(0) end end end result User.where(created_at: from..to).count end end ``` -------------------------------- ### Define a Stimulus JS Controller Source: https://docs.avohq.io/3.0/llms-full.txt Create a new Stimulus controller file. This example defines a simple controller that logs a message when connected. ```javascript // app/javascript/controllers/sample_controller.js import { Controller } from "@hotwired/stimulus"; export default class extends Controller { connect() { console.log("Hey from sample controller 👋"); } } ``` -------------------------------- ### Generate New Rails App with Avo Source: https://docs.avohq.io/3.0/llms-full.txt Use this command to create a new Rails application with the standard Avo gem installed. This is a starting point for reproducing issues. ```bash rails new -m https://avo.cool/new.rb APP_NAME ``` -------------------------------- ### Basic Action Usage Source: https://docs.avohq.io/3.0/customizable-controls.html Demonstrates the basic syntax for using the `action` helper to display action buttons with optional arguments and styling. ```ruby action Avo::Actions::DisableAccount action Avo::Actions::DisableAccount, arguments: { hide_some_fields: true } action Avo::Actions::ExportSelection, style: :text action Avo::Actions::PublishPost, color: :fuchsia, icon: "heroicons/outline/eye" ``` -------------------------------- ### Controlling Tab Visibility with Lambdas Source: https://docs.avohq.io/3.0/llms-full.txt This example demonstrates how to dynamically control the visibility of tab groups and individual tabs using lambda expressions based on resource and user properties. ```ruby tabs visible: -> { resource.record.enabled? } do tab name: "General Information" do panel do field :name, as: :text field :email, as: :text end end tab "Admin Information", visible: -> { current_user.is_admin? } do panel do field :role, as: :text field :permissions, as: :text end end end ``` -------------------------------- ### Define User resource fields in Avo Source: https://docs.avohq.io/3.0/llms-full.txt This example shows a basic definition of fields for a User resource, including ID, text, boolean, and file types. ```ruby class Avo::Resources::User < Avo::BaseResource def fields field :id, as: :id field :first_name, as: :text field :last_name, as: :text field :email, as: :text field :active, as: :boolean field :cv, as: :file field :is_admin?, as: :boolean end end ``` -------------------------------- ### Apply Jumpstart Pro Blueprint Source: https://avohq.io/templates/jumpstart-pro Run this command to quickly apply the Jumpstart Pro app blueprint with Avo 3. ```bash $ bin/rails app:template LOCATION=https://avohq.io/blueprints/jumpstart-pro.template ``` -------------------------------- ### Field Translation YAML Example Source: https://docs.avohq.io/3.0/llms-full.txt Example YAML file for translating field names, including pluralization rules for different counts. ```yaml es: avo: dashboard: 'Dashboard' # ... other translation keys field_translations: file: zero: 'archivos' one: 'archivo' other: 'archivos' ``` -------------------------------- ### Sample Resource Tool Partial Source: https://docs.avohq.io/3.0/llms-full.txt This ERB partial demonstrates the structure of a resource tool in Avo, including panels, tools, and body content. It shows how to render Avo components and provides comments on available variables. ```erb
<%= render Avo::PanelComponent.new title: "Post info" do |c| <% c.with_tools do %> <%= a_link('/avo', icon: 'heroicons/solid/academic-cap', style: :primary) do %> Dummy link <% end %> <% end %> <% c.with_body do %>

🪧 This partial is waiting to be updated

You can edit this file here app/views/avo/resource_tools/post_info.html.erb.

The resource tool configuration file should be here app/avo/resource_tools/post_info.rb.

<% # In this partial, you have access to the following variables: # tool # @resource # @resource.model # form (on create & edit pages. please check for presence first) # params # Avo::Current.context # current_user %>
<% end %> <% end %>
``` -------------------------------- ### Create New Repo and Set Avo Root Path Source: https://docs.avohq.io/3.0/llms-full.txt Commands to create a new Rails repository, install Avo using a template, and modify the Avo initializer to set the root path. ```bash rails new avo-root-path cd avo-root-path bin/rails app:template LOCATION='https://avohq.io/app-template' sed -i '' "s|config.root_path = '/avo'|config.root_path = '/'|" config/initializers/avo.rb ``` -------------------------------- ### Configure Cover Photo with Size and Source Source: https://docs.avohq.io/3.0/llms-full.txt Set up the cover photo, specifying its size, visibility on different views, and the source of the image. The source can be a record attribute or dynamically determined. ```ruby self.cover_photo = { size: :md, # :sm, :md, :lg visible_on: [:show, :forms], # can be :show, :index, :edit, or a combination [:show, :index] source: -> { if view.index? # We're on the index page and don't have a record to reference DEFAULT_IMAGE else # We have a record so we can reference it's cover_photo record.cover_photo end } } ``` ```ruby self.cover_photo = { source: :cover_photo # this will run `record.cover_photo` } ``` -------------------------------- ### Configure Home Path and Initial Breadcrumbs Source: https://docs.avohq.io/3.0/customization.html Set a static string for the home path and define initial breadcrumbs for a cohesive navigation experience. ```ruby Avo.configure do |config| config.home_path = "/avo/dashboard" config.set_initial_breadcrumbs do add_breadcrumb "Dashboard", "/avo/dashboard" end end ``` -------------------------------- ### Association `touch: true` Example Source: https://docs.avohq.io/3.0/llms-full.txt Example demonstrating how to use `touch: true` on a `belongs_to` association to ensure associated records are updated when the parent record changes, helping to invalidate cache. ```ruby class Comment < ApplicationRecord belongs_to :post, touch: true end ``` -------------------------------- ### PostHog Initialization Source: https://avohq.io/roadmap This script initializes PostHog, a product analytics platform. It configures API host, capture page views, and sets up user profiles. It also includes an example of identifying a specific user. ```javascript !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.api_host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="init capture register register_once register_for_session unregister unregister_for_session getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey getNextSurveyStep identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty createPersonProfile opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing clear_opt_in_out_capturing debug".split(" "),n=0;n 5.5.0" ``` -------------------------------- ### Configure Main Menu with Sections and Groups Source: https://docs.avohq.io/3.0/llms-full.txt Organize sidebar resources into menus using `main_menu`. Define sections with icons, groups with collapsable options, and add resources, dashboards, or links. ```ruby # config/initializers/avo.rb Avo.configure do |config| config.main_menu = -> { section "Resources", icon: "heroicons/outline/academic-cap" do group "Academia" do resource :course resource :course_link end group "Blog", collapsable: true, collapsed: true do dashboard :dashy resource :post resource :comment end end section I18n.t('avo.other'), icon: "heroicons/outline/finger-print", collapsable: true, collapsed: true do link_to 'Avo HQ', path: 'https://avohq.io', target: :_blank link_to 'Jumpstart Rails', path: 'https://jumpstartrails.com/', target: :_blank end } end ``` -------------------------------- ### Enable Media Library Source: https://docs.avohq.io/3.0/llms-full.txt Set `config.enabled = true` to enable the Media Library feature. This is the primary switch for the entire feature. ```ruby if defined?(Avo::MediaLibrary) Avo::MediaLibrary.configure do |config| config.enabled = true end end ``` -------------------------------- ### Basic Tags Field Source: https://docs.avohq.io/3.0/llms-full.txt Defines a field with the type 'tags'. This is the most basic setup for the tags field. ```ruby field :skills, as: :tags ``` -------------------------------- ### Configure a comprehensive ProgressBar field Source: https://docs.avohq.io/3.0/llms-full.txt This example shows how to configure a progress bar with custom max value, step, display value, and value suffix. It's useful for detailed progress tracking and slider input. ```ruby field :progress, as: :progress_bar, max: 150, step: 10, display_value: true, value_suffix: "%" ``` -------------------------------- ### Add Hashid Rails Gem to Gemfile Source: https://docs.avohq.io/3.0/llms-full.txt Install the hashid-rails gem by adding it to your application's Gemfile. ```ruby gem "hashid-rails", "~> 1.0" ``` -------------------------------- ### Avo Subscriptions Controller with Jumpstart Helpers Source: https://avohq.io/templates/jumpstart-pro Controller for Avo's Subscriptions resource, including Jumpstart's AdministrateHelpers for enhanced functionality. ```ruby class Avo::SubscriptionsController < Avo::ResourcesController include Jumpstart::AdministrateHelpers end ``` -------------------------------- ### Add Prefixed IDs Gem to Gemfile Source: https://docs.avohq.io/3.0/llms-full.txt Install the prefixed_ids gem by adding it to your application's Gemfile. ```ruby gem "prefixed_ids" ``` -------------------------------- ### Radio field options using a Proc Source: https://docs.avohq.io/3.0/llms-full.txt This example demonstrates how to define radio button options dynamically using a Proc. This allows options to be generated based on record data or other context. ```ruby options: -> do record.roles.each_with_object({}) do |role, hash| hash[role.id] = role.name.humanize end end ``` -------------------------------- ### Register Stimulus Controller for Nested Forms Source: https://docs.avohq.io/3.0/llms-full.txt Install the `stimulus-rails-nested-form` package and register its controller in your Avo JavaScript file. ```javascript // Probably app/javascript/avo.custom.js import { Application } from '@hotwired/stimulus' import NestedForm from 'stimulus-rails-nested-form' const application = Application.start() application.register('nested-form', NestedForm) ``` -------------------------------- ### Enable ViewComponent Instrumentation Source: https://docs.avohq.io/3.0/llms-full.txt Add this configuration to `application.rb` or `development.rb` to enable ViewComponent instrumentation. ```ruby config.view_component.instrumentation_enabled = true ``` -------------------------------- ### Example of Repetitive Attachment Permissions Source: https://docs.avohq.io/3.0/llms-full.txt Shows the common, repetitive way to define individual attachment permissions in Pundit. ```ruby def upload_logo? update? end def delete_logo? update? end def download_logo? update? end ``` -------------------------------- ### Scope for HasMany Field Source: https://docs.avohq.io/3.0/llms-full.txt Scopes the records displayed in the table for a HasMany association. This example filters for approved users. ```ruby field :user, as: :belongs_to, scope: -> { query.approved } ``` -------------------------------- ### Add Media Library to Main Menu Source: https://docs.avohq.io/3.0/llms-full.txt Integrate the Media Library into the main application menu using the `media_library` helper. This makes it accessible from the sidebar. ```ruby Avo.configure do |config| config.main_menu = lambda { link_to 'Media Library', avo.media_library_index_path } end ``` -------------------------------- ### Avo Configuration Example Source: https://avohq.io/templates/bullet-train This snippet shows a comprehensive configuration for Avo, including routing, authentication, authorization, and branding options. It is used to customize the Avo admin panel's behavior and appearance. ```ruby # For more information regarding these settings check out our docs https://docs.avohq.io Avo.configure do |config| ## == Routing == config.root_path = "/admin/avo" # used only when you have custom `map` configuration in your config.ru # config.prefix_path = "/internal" # Where should the user be redirected when visting the `/avo` url # config.home_path = nil ## == Licensing == # config.license_key = ENV['AVO_LICENSE_KEY'] ## == Set the context == config.set_context do # Return a context object that gets evaluated in Avo::ApplicationController end ## == Authentication == config.current_user_method = :current_user # config.authenticate_with do # end ## == Authorization == # config.authorization_methods = { # index: 'index?', # show: 'show?', # edit: 'edit?', # new: 'new?', # update: 'update?', # create: 'create?', # destroy: 'destroy?', # search: 'search?', # } # config.raise_error_on_missing_policy = false # config.authorization_client = :pundit ## == Localization == # config.locale = 'en-US' ## == Resource options == # config.resource_controls_placement = :right # config.model_resource_mapping = {} # config.default_view_type = :table # config.per_page = 24 # config.per_page_steps = [12, 24, 48, 72] # config.via_per_page = 8 config.id_links_to_resource = true # config.cache_resources_on_index_view = true ## permanent enable or disable cache_resource_filters, default value is false # config.cache_resource_filters = false ## provide a lambda to enable or disable cache_resource_filters per user/resource. # config.cache_resource_filters = ->(current_user:, resource:) { current_user.cache_resource_filters?} ## == Customization == config.app_name = -> { I18n.t "application.name" } # config.timezone = 'UTC' # config.currency = 'USD' # config.hide_layout_when_printing = false # config.full_width_container = false # config.full_width_index_view = false # config.search_debounce = 300 # config.view_component_path = "app/components" # config.display_license_request_timeout_error = true # config.disabled_features = [] # config.buttons_on_form_footers = true # config.field_wrapper_layout = true ## == Branding == # config.branding = { # colors: { # background: "248 246 242", # 100 => "#CEE7F8", # 400 => "#399EE5", # 500 => "#0886DE", # 600 => "#066BB2", # }, # chart_colors: ["#0B8AE2", "#34C683", "#2AB1EE", "#34C6A8"], # logo: "/avo-assets/logo.png", # logomark: "/avo-assets/logomark.png", # placeholder: "/avo-assets/placeholder.svg", # favicon: "/avo-assets/favicon.ico" # } ## == Breadcrumbs == # config.display_breadcrumbs = true # config.set_initial_breadcrumbs do # add_breadcrumb "Home", '/avo' # end ## == Menus == # config.main_menu = -> { # section "Dashboards", icon: "dashboards" do # all_dashboards # end # section "Resources", icon: "resources" do # all_resources # end # section "Tools", icon: "tools" do # all_tools # end # } # config.profile_menu = -> { # link "Profile", path: "/avo/profile", icon: "user-circle" # } end ``` -------------------------------- ### Kamal Dockerfile with Secret Mount Source: https://docs.avohq.io/3.0/llms-full.txt Configure your Dockerfile for Kamal to securely access the BUNDLE_PACKAGER__DEV secret during the bundle install process. ```dockerfile # Install application gems COPY Gemfile Gemfile.lock ./ RUN --mount=type=secret,id=BUNDLE_PACKAGER__DEV BUNDLE_PACKAGER__DEV=$(cat /run/secrets/BUNDLE_PACKAGER__DEV) bundle install && \ rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ bundle exec bootsnap precompile --gemfile ``` -------------------------------- ### Render Custom Profile Item Source: https://docs.avohq.io/3.0/llms-full.txt Example of rendering a custom profile item component within the Avo profile menu. ```erb <%# Example link below %> <%#= render Avo::ProfileItemComponent.new label: 'Profile', path: '/profile', icon: 'user-circle' %> ``` -------------------------------- ### Displaying all resources in Avo menu Source: https://docs.avohq.io/3.0/llms-full.txt Use `all_dashboards`, `all_resources`, and `all_tools` helpers within a section to automatically populate menu groups. Ensure `def index?` is enabled in resource policies for `all_resources` to respect authorization. ```ruby section "App", icon: "heroicons/outline/beaker" do group "Dashboards", icon: "dashboards" do all_dashboards end group "Resources", icon: "resources" do all_resources end group "All tools", icon: "tools" do all_tools end end ``` -------------------------------- ### HTML Markup with View Value Source: https://docs.avohq.io/3.0/llms-full.txt Example of HTML markup that includes the `data-[CONTROLLER]-view-value` attribute, which is automatically added by Avo. ```html
``` -------------------------------- ### Create a basic link with target Source: https://docs.avohq.io/3.0/llms-full.txt Use `link_to` to create a menu item that links to a URL. Specify `target: :_blank` to open the link in a new tab and display an external link icon. ```ruby link_to "Google", path: "https://google.com", target: :_blank ``` -------------------------------- ### Avo Customers Controller with Jumpstart Helpers Source: https://avohq.io/templates/jumpstart-pro Controller for Avo's Customers resource, including Jumpstart's AdministrateHelpers for enhanced functionality. ```ruby class Avo::CustomersController < Avo::ResourcesController include Jumpstart::AdministrateHelpers end ``` -------------------------------- ### Custom Authentication using Session Source: https://docs.avohq.io/3.0/llms-full.txt Implement authentication logic directly within the `authenticate_with` block, for example, by checking session data. ```ruby # config/initializers/avo.rb Avo.configure do |config| config.authenticate_with do redirect_to '/' unless session[:user_id] == 1 # hard code user ids here end end ``` -------------------------------- ### Use Customized Component with Custom Namespace Source: https://docs.avohq.io/3.0/resources.html Example of configuring a resource to use a custom component with a custom namespace after ejecting and modifying it. ```ruby self.components = { resource_index_component: Avo::MyDir::Views::ResourceIndexComponent } ``` -------------------------------- ### Avo Charges Controller with Jumpstart Helpers Source: https://avohq.io/templates/jumpstart-pro Controller for Avo's Charges resource, including Jumpstart's AdministrateHelpers for enhanced functionality. ```ruby # This controller has been generated to enable Rails' resource routes. # You shouldn't need to modify it in order to use Avo. class Avo::ChargesController < Avo::ResourcesController include Jumpstart::AdministrateHelpers end ``` -------------------------------- ### Chartkick Card with Callable Chart Options Source: https://docs.avohq.io/3.0/llms-full.txt Demonstrates how to set chart options using a callable block for dynamic configuration. This allows for options to be evaluated at runtime. ```ruby class Avo::Cards::ExampleAreaChart < Avo::Cards::ChartkickCard self.chart_options: -> do { library: { plugins: { legend: {display: true} } } } end end ``` -------------------------------- ### Generate a new Pundit policy Source: https://docs.avohq.io/3.0/llms-full.txt Use this command to generate a new policy file for a specific resource. Ensure Pundit is installed first. ```bash bin/rails g pundit:policy Post ``` -------------------------------- ### Configure Bundler with Token Source: https://docs.avohq.io/3.0/llms-full.txt Add your authentication token to the global bundler configuration for local development. This ensures bundler is aware of the token without needing to specify it in the Gemfile. ```bash bundle config set --global https://packager.dev/avo-hq/ xxx ``` -------------------------------- ### HTML Markup for Field Wrapper Targets Source: https://docs.avohq.io/3.0/llms-full.txt Example of the generated HTML markup for field wrappers, including Stimulus target data attributes. ```html
``` -------------------------------- ### Render all tools Source: https://docs.avohq.io/3.0/llms-full.txt The `all_tools` helper renders all available tools within a menu section or group. ```ruby section "App", icon: "heroicons/outline/beaker" do group "All tools", icon: "tools" do all_tools end end ``` -------------------------------- ### Customize Kanban Item Component View Source: https://docs.avohq.io/3.0/llms-full.txt Example of customizing the `app/components/avo/kanban/items/item_component.html.erb` file. It shows how to display the record's name associated with the item. ```erb <%= item.record.name %> ``` -------------------------------- ### Configure Main and Profile Menus Source: https://docs.avohq.io/3.0/llms-full.txt Customize both the main sidebar menu and the user profile menu. The `main_menu` can include dashboards, resources, tools, and links, while `profile_menu` typically contains user-specific links. ```ruby # config/initializers/avo.rb Avo.configure do |config| config.main_menu = -> { section I18n.t("avo.dashboards"), icon: "dashboards" do dashboard :dashy, visible: -> { true } dashboard :sales, visible: -> { true } group "All dashboards", visible: false do all_dashboards end end section "Resources", icon: "heroicons/outline/academic-cap" do group "Academia" do resource :course resource :course_link end group "Blog" do resource :posts resource :comments end group "Other" do resource :fish end end section "Tools", icon: "heroicons/outline/finger-print" do all_tools end group do link_to "Avo", path: "https://avohq.io" link_to "Google", path: "https://google.com", target: :_blank end } config.profile_menu = -> { link_to "Profile", path: "/profile", icon: "user-circle" } end ``` -------------------------------- ### Configure Avo Profile Menu Source: https://avohq.io/templates/jumpstart-pro Set up the profile menu, typically used for user-specific actions like accessing their profile. This snippet shows how to add a 'Profile' link. ```ruby config.profile_menu = -> { link "Profile", path: "/avo/profile", icon: "user-circle" } ``` -------------------------------- ### Configure Turbo Behavior in Avo Source: https://docs.avohq.io/3.0/customization.html Control Turbo's behavior within Avo using the `config.turbo` option. This example enables `instant_click`. ```ruby config.turbo = -> do { instant_click: true } end ``` -------------------------------- ### Download File with Ruby Source: https://docs.avohq.io/3.0/llms-full.txt Initiates a file download to a specified path and filename. Requires `self.may_download_file = true` for versions before 3.2.2. ```ruby class Avo::Actions::DownloadFile < Avo::BaseAction self.name = "Download file" # Only required for versions before 3.2.2 self.may_download_file = true def handle(query:, **args) filename = "projects.csv" report_data = [] query.each do |project| report_data << project.generate_report_data end succeed 'Done!' if report_data.present? and filename.present? download report_data, filename end end end ``` ```ruby # app/avo/resources/project.rb class Avo::Resources::Project < Avo::BaseResource def fields # fields here end def actions action Avo::Actions::DownloadFile end end ``` -------------------------------- ### Basic Code Field for JSON Source: https://docs.avohq.io/3.0/llms-full.txt Use a code field with the 'javascript' language to display JSON data. This is a basic setup before applying formatting. ```ruby field :meta, as: :code, language: 'javascript' ``` -------------------------------- ### Generate Array Resource Source: https://docs.avohq.io/3.0/llms-full.txt Generates an array resource for use with the Array field. This command ensures proper setup within the Avo framework. ```bash rails generate avo:resource Attendee --array ``` -------------------------------- ### Implement Custom Search Provider Source: https://docs.avohq.io/3.0/llms-full.txt Example of configuring a custom search provider for an Avo resource. The `query` block returns an array of hashes, each representing a search result with specific metadata. ```ruby class Avo::Resources::Project < Avo::BaseResource self.search = { query: -> do [ { _id: 1, _label: "Record One", _url: "https://example.com/1" }, { _id: 2, _label: "Record Two", _url: "https://example.com/2" }, { _id: 3, _label: "Record Three", _url: "https://example.com/3" } ] end } end ``` -------------------------------- ### Add Help Text to Field Source: https://docs.avohq.io/3.0/llms-full.txt Use the `help` method to provide explanatory text or HTML for a field. This text appears to guide the user. ```ruby # using the text value field :custom_css, as: :code, theme: 'dracula', language: 'css', help: "This enables you to edit the user's custom styles." ``` ```ruby # using HTML value field :password, as: :password, help: 'You may verify the password strength here.' ``` -------------------------------- ### Mount Avo with Default and Custom Paths Source: https://docs.avohq.io/3.0/llms-full.txt Mounts Avo using the default configuration path or a custom path specified with the `at` argument. ```ruby # config/routes.rb Rails.application.routes.draw do # Mounts Avo at Avo.configuration.root_path mount_avo # Mounts Avo at `/custom_path` instead of the default mount_avo at: "custom_path" end ```