Skip to content

Commit

Permalink
Merge branch 'main' into fix/undefined_tags_in_field_when_editing
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob authored Nov 1, 2024
2 parents 70e85f1 + 06081ae commit 2af81ca
Show file tree
Hide file tree
Showing 144 changed files with 951 additions and 678 deletions.
2 changes: 2 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ categories:
labels:
- 'Feature'
- 'Feat'
- title: '✨ Enhancements'
labels:
- 'Enhancement'
- title: '🐛 Bug Fixes'
labels:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.MD
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Please fork Avo and create a descriptive branch for your feature or fix. We usua
Thank you for considering to contribute to Avo. These are our recommendations to improve readability and interoperability when contributing with a PR:

- the title should have the type (`feature`, `chore`, `fix`, `refactor`) followed by the sentence case of what it does (ex: `feature: scoped search for has many associations` or `fix: broken sidebar on desktop`).
- the PR should be marked by the appropiate tag (`feature`, `chore`, `fix`, `refactor`)
- the PR should be marked by the appropriate tag (`feature`, `chore`, `fix`, `refactor`)
- if there's an issue open that could be fixed by this PR you can mark it by writing `Fixes ISSUE_URL` in the description so GitHub automates some actions (ex: `Fixes https://github.com/avo-hq/avo/issues/1008`). If there are more issues that could be fixed, add more lines.
- please follow the steps on the `Checklist` and mark them as done with an `x` inside the brackets `[x]`
- if there's something that we can test, please send us the instructions to do that in that PR description.
Expand Down Expand Up @@ -167,7 +167,7 @@ In order to restore the previous fields you may run `RESOURCE_CLASS.restore_item

### Working with datepickers

The prerequisite for these helpers is to ensure you have the two inputs mapped in your test file like so and you update the `FIELD_ID` attribute to the field you decalred on your resource `created_at`, `starting_at`, etc.
The prerequisite for these helpers is to ensure you have the two inputs mapped in your test file like so and you update the `FIELD_ID` attribute to the field you declared on your resource `created_at`, `starting_at`, etc.

```ruby
subject(:text_input) { find '[data-field-id="FIELD_ID"] [data-controller="date-field"] input[type="text"]' }
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ gem "bundler-integrity", "~> 1.0"
# Avo country field requires this gem
gem "countries"

# Avo dashbaords requires this gem
# Avo dashboards requires this gem
gem "chartkick"

# Required by Avo
Expand Down
13 changes: 7 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ GIT
PATH
remote: .
specs:
avo (3.13.3)
avo (3.13.7)
actionview (>= 6.1)
active_link_to
activerecord (>= 6.1)
activesupport (>= 6.1)
addressable
docile
inline_svg
literal (~> 0.2)
meta-tags
pagy (>= 7.0.0)
prop_initializer (>= 0.2.0)
turbo-rails (>= 2.0.0)
turbo_power (>= 0.6.0)
view_component (>= 3.7.0)
Expand Down Expand Up @@ -391,7 +391,6 @@ GEM
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
literal (0.2.1)
logger (1.6.1)
loofah (2.22.0)
crass (~> 1.0.2)
Expand Down Expand Up @@ -450,6 +449,8 @@ GEM
hashids (>= 1.0.0, < 2.0.0)
rails (>= 6.0.0)
prettier_print (1.2.1)
prop_initializer (0.2.0)
zeitwerk (>= 2.6.18)
psych (5.1.2)
stringio
public_suffix (6.0.1)
Expand Down Expand Up @@ -507,7 +508,7 @@ GEM
railties (>= 5.2)
reverse_markdown (2.1.1)
nokogiri
rexml (3.3.7)
rexml (3.3.9)
ripper-tags (1.0.2)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
Expand Down Expand Up @@ -642,7 +643,7 @@ GEM
unicode-display_width (2.6.0)
uri (0.13.1)
useragent (0.16.10)
view_component (3.15.1)
view_component (3.17.0)
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
Expand Down Expand Up @@ -757,4 +758,4 @@ DEPENDENCIES
zeitwerk

BUNDLED WITH
2.4.7
2.5.9
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Please read the [RELEASE.MD](./RELEASE.MD)
</tr>
</table>

[Become a sponsor ](https://github.com/sponsors/adrianthedev)
[Become a sponsor](mailto:[email protected])


![Alt](https://repobeats.axiom.co/api/embed/1481a6a259064f02a7936470d12a50802a9c98a4.svg "Repobeats analytics image")
Expand All @@ -120,3 +120,10 @@ Please read the [RELEASE.MD](./RELEASE.MD)
[Get a box of waffles and some of the best app monitoring from Appsignal](https://appsignal.com/r/93dbe69bfb) 🧇

[Get $100 in credits from Digital Ocean](https://www.digitalocean.com/?refcode=efc1fe881d74&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge) 💸

## Other Open Source Work

- [`active_storage-blurhash`](https://github.com/avo-hq/active_storage-blurhash) - A plug-n-play [blurhash](https://blurha.sh/) integration for images stored in ActiveStorage
- [`class_variants`](https://github.com/avo-hq/class_variants) - Easily configure styles and apply them as classes. Very useful when you're implementing Tailwind CSS components and call them with different states.
- [`prop_initializer`](https://github.com/avo-hq/prop_initializer) - A flexible tool for defining properties on Ruby classes.
- [`stimulus-confetti`](https://github.com/avo-hq/stimulus-confetti) - The easiest way to add confetti to your StimulusJS app
60 changes: 26 additions & 34 deletions app/components/avo/actions_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,44 @@
class Avo::ActionsComponent < Avo::BaseComponent
include Avo::ApplicationHelper

ACTION_FILTER = _Set(_Class(Avo::BaseAction))

prop :as_row_control, _Boolean, default: false
prop :icon, _Nilable(String)
prop :size, Avo::ButtonComponent::SIZE, default: :md
prop :title, _Nilable(String)
prop :color, _Nilable(Symbol) do |value|
prop :as_row_control, default: false
prop :icon
prop :size, default: :md
prop :title
prop :color do |value|
value || :primary
end
prop :include, _Nilable(ACTION_FILTER), default: [].freeze do |include|
prop :include, default: [].freeze do |include|
Array(include).to_set
end
prop :custom_list, _Boolean, default: false
prop :label, _Nilable(String) do |label|
prop :custom_list, default: false
prop :label do |label|
if @custom_list
label
else
label || I18n.t("avo.actions")
end
end
prop :style, Avo::ButtonComponent::STYLE, default: :outline
prop :actions, _Array(_Any), default: [].freeze
prop :exclude, _Nilable(ACTION_FILTER), default: [].freeze do |exclude|
prop :style, default: :outline
prop :actions, default: [].freeze
prop :exclude, default: [].freeze do |exclude|
Array(exclude).to_set
end
prop :resource, _Nilable(Avo::BaseResource)
prop :view, _Nilable(Avo::ViewInquirer)
prop :host_component, _Nilable(_Any)
prop :resource
prop :view
prop :host_component

delegate_missing_to :@host_component

def after_initialize
filter_actions unless @custom_list

# Hydrate each action action with the record when rendering a list on row controls
if @as_row_control
@actions.each do |action|
action.hydrate(resource: @resource, record: @resource.record) if action.respond_to?(:hydrate)
end
end
end

def render?
Expand All @@ -54,23 +59,8 @@ def filter_actions
end
end

# How should the action be displayed by default
def is_disabled?(action)
return false if action.standalone || @as_row_control

on_index_page?
end

private

def on_record_page?
@view.in?(["show", "edit", "new"])
end

def on_index_page?
!on_record_page?
end

def icon(icon)
svg icon, class: "h-5 shrink-0 mr-1 inline pointer-events-none"
end
Expand Down Expand Up @@ -114,15 +104,17 @@ def action_data_attributes(action)
"turbo-frame": Avo::MODAL_FRAME_ID,
action: "click->actions-picker#visitAction",
"actions-picker-target": action.standalone ? "standaloneAction" : "resourceAction",
disabled: is_disabled?(action),
disabled: action.disabled?,
turbo_prefetch: false,
enabled_classes: "text-black",
disabled_classes: "text-gray-500"
}
end

def action_css_class(action)
helpers.class_names("flex items-center px-4 py-3 w-full font-semibold text-sm hover:bg-primary-100", {
"text-gray-500": is_disabled?(action),
"text-black": !is_disabled?(action),
"text-gray-500": action.disabled?,
"text-black": action.enabled?,
})
end
end
4 changes: 2 additions & 2 deletions app/components/avo/alert_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class Avo::AlertComponent < Avo::BaseComponent
include Avo::ApplicationHelper

prop :type, Symbol, :positional
prop :message, String, :positional
prop :type, kind: :positional
prop :message, kind: :positional

def icon
return "heroicons/solid/exclamation-circle" if is_error?
Expand Down
2 changes: 1 addition & 1 deletion app/components/avo/asset_manager/javascript_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Avo::AssetManager::JavascriptComponent < Avo::BaseComponent
prop :asset_manager, Avo::AssetManager
prop :asset_manager

delegate :javascripts, to: :@asset_manager
end
2 changes: 1 addition & 1 deletion app/components/avo/asset_manager/stylesheet_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Avo::AssetManager::StylesheetComponent < Avo::BaseComponent
prop :asset_manager, Avo::AssetManager
prop :asset_manager

delegate :stylesheets, to: :@asset_manager
end
2 changes: 1 addition & 1 deletion app/components/avo/backtrace_alert_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Avo::BacktraceAlertComponent < Avo::BaseComponent
include Avo::ApplicationHelper

prop :backtrace, _Nilable(Array)
prop :backtrace

def render?
@backtrace.present?
Expand Down
2 changes: 1 addition & 1 deletion app/components/avo/base_component.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Avo::BaseComponent < ViewComponent::Base
extend Literal::Properties
extend PropInitializer::Properties
include Turbo::FramesHelper
include Avo::Concerns::FindAssociationField

Expand Down
27 changes: 12 additions & 15 deletions app/components/avo/button_component.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# frozen_string_literal: true

class Avo::ButtonComponent < Avo::BaseComponent
SIZE = _Union(:xs, :sm, :md, :lg, :xl)
STYLE = _Union(:primary, :outline, :text, :icon)

prop :path, _Nilable(String), :positional
prop :size, Symbol, default: :md
prop :style, Symbol, default: :outline
prop :color, Symbol, default: :gray
prop :icon, _Nilable(Symbol) do |value|
prop :path, kind: :positional
prop :size, default: :md
prop :style, default: :outline
prop :color, default: :gray
prop :icon do |value|
value&.to_sym
end
prop :icon_class, String, default: ""
prop :is_link, _Boolean, default: false
prop :rounded, _Boolean, default: true
prop :compact, _Boolean, default: false
prop :aria, Hash, default: {}.freeze
prop :args, Hash, :**, default: {}.freeze
prop :class, _Nilable(String)
prop :icon_class, default: ""
prop :is_link, default: false
prop :rounded, default: true
prop :compact, default: false
prop :aria, default: {}.freeze
prop :args, kind: :**, default: {}.freeze
prop :class

def args
if @args[:loading]
Expand Down
4 changes: 2 additions & 2 deletions app/components/avo/cover_photo_component.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

class Avo::CoverPhotoComponent < Avo::BaseComponent
prop :cover_photo, _Nilable(Avo::CoverPhoto)
prop :size, _Nilable(Symbol) do |value|
prop :cover_photo
prop :size do |value|
@cover_photo&.size
end

Expand Down
4 changes: 2 additions & 2 deletions app/components/avo/divider_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Avo::DividerComponent < Avo::BaseComponent
prop :label, _Nilable(String), :positional
prop :args, Hash, :**
prop :label, kind: :positional
prop :args, kind: :**
end
8 changes: 4 additions & 4 deletions app/components/avo/empty_state_component.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

class Avo::EmptyStateComponent < Avo::BaseComponent
prop :message, _Nilable(String)
prop :view_type, Symbol, default: :table do |value|
prop :message
prop :view_type, default: :table do |value|
value&.to_sym
end
prop :add_background, _Boolean, default: false
prop :by_association, _Boolean, default: false
prop :add_background, default: false
prop :by_association, default: false

def text
@message || locale_message
Expand Down
32 changes: 16 additions & 16 deletions app/components/avo/field_wrapper_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
class Avo::FieldWrapperComponent < Avo::BaseComponent
include Avo::Concerns::HasResourceStimulusControllers

prop :dash_if_blank, _Boolean, default: true
prop :data, Hash, default: {}.freeze
prop :compact, _Boolean, default: false
prop :help, _Nilable(String)
prop :field, _Nilable(Avo::Fields::BaseField)
prop :form, _Nilable(ActionView::Helpers::FormBuilder)
prop :full_width, _Boolean, default: false
prop :label, _Nilable(String)
prop :resource, _Nilable(Avo::BaseResource)
prop :short, _Boolean, default: false
prop :stacked, _Nilable(_Boolean)
prop :style, String, default: ""
prop :view, Avo::ViewInquirer, default: Avo::ViewInquirer.new(:show).freeze
prop :label_for, _Nilable(Symbol) do |value|
prop :dash_if_blank, default: true
prop :data, default: {}.freeze
prop :compact, default: false
prop :help
prop :field
prop :form
prop :full_width, default: false
prop :label
prop :resource
prop :short, default: false
prop :stacked
prop :style, default: ""
prop :view, default: Avo::ViewInquirer.new(:show).freeze
prop :label_for do |value|
value&.to_sym
end
prop :args, Hash, :**, default: {}.freeze
prop :classes, _Nilable(String) do |value|
prop :args, kind: :**, default: {}.freeze
prop :classes do |value|
@args&.dig(:class) || ""
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Avo::Fields::BooleanGroupField::EditComponent < Avo::Fields::EditComponent
def initialize(...)
super(...)

# Initilize here to avoid multiple calls to @field.get_html for each option.
# Initialize here to avoid multiple calls to @field.get_html for each option.
@classes = "w-4 h-4 rounded checked:bg-primary-400 focus:checked:!bg-primary-400" \
"#{@field.get_html(:classes, view: view, element: :input)}"
@data = @field.get_html(:data, view: view, element: :input)
Expand Down
Loading

0 comments on commit 2af81ca

Please sign in to comment.