Class: Avo::Items::PanelComponent
- Inherits:
-
ResourceComponent
- Object
- ResourceComponent
- Avo::Items::PanelComponent
- Includes:
- ApplicationHelper
- Defined in:
- app/components/avo/items/panel_component.rb
Instance Method Summary collapse
- #card_background_warning_message ⇒ Object
-
#fields_outside_card? ⇒ Boolean
Warn in development/test when a developer declares fields directly inside a ‘panel` without wrapping them in a `card do …
Methods included from ApplicationHelper
#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #rtl?, #text_direction, #ui, #wrap_in_modal
Methods included from ResourcesHelper
#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table
Instance Method Details
#card_background_warning_message ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'app/components/avo/items/panel_component.rb', line 47 def # Keep the message deterministic for specs. # docs_url = "https://docs.avohq.io/4.0/resource-cards.html" = "" # docs_message = "See the <a href=\"#{docs_url}\" target=\"_blank\" rel=\"noopener\" class=\"underline underline-offset-2\">resource cards</a> docs." code_classes = "inline-flex items-center align-middle rounded bg-orange-500/10 px-1 py-px font-mono text-[0.85em] font-semibold leading-none text-orange-950 dark:bg-orange-500/15 dark:text-orange-50" disable_snippet = "<code class=\"#{code_classes}\">panel dev_warnings: false do ... end</code>" "Some fields are declared directly inside a <code class=\"#{code_classes}\">panel</code> without a <code class=\"#{code_classes}\">card do ... end</code> wrapper. Wrap them in a <code class=\"#{code_classes}\">card</code> to get the expected card background and spacing. If this is intentional and you want to avoid this warning please use #{disable_snippet}. #{}" end |
#fields_outside_card? ⇒ Boolean
Warn in development/test when a developer declares fields directly inside a ‘panel` without wrapping them in a `card do … end` block.
This matters because cards are the thing that provides the consistent background/spacing.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/avo/items/panel_component.rb', line 29 def fields_outside_card? return false unless Rails.env.development? || Rails.env.test? return false unless @item.respond_to?(:visible_items) return false if @item.respond_to?(:dev_warnings?) && !@item.dev_warnings? @item.visible_items.any? do |item| # Direct field under the panel will render without card background. if item.is_field? true # Row is rendered directly by the panel too; it can contain fields rendered without card background. elsif item.is_row? item.visible_items.any?(&:is_field?) else false end end end |