Skip to content

Commit

Permalink
Merge branch 'main' into refactor/avo-tailwind-file-clash
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed Jan 4, 2024
2 parents db2c453 + 94f6e77 commit 7454bdf
Show file tree
Hide file tree
Showing 91 changed files with 1,592 additions and 1,002 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Expand Up @@ -74,8 +74,6 @@ group :development do

gem "hotwire-livereload", "~> 1.3.0"

gem "brakeman"

gem "rubocop"
gem "ripper-tags"
gem "rubocop-shopify", require: false
Expand Down
54 changes: 28 additions & 26 deletions Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
avo (3.1.7)
avo (3.2.3)
actionview (>= 6.1)
active_link_to
activerecord (>= 6.1)
Expand All @@ -13,7 +13,7 @@ PATH
inline_svg
meta-tags
pagy
turbo-rails (~> 2.0.0.pre.beta.1)
turbo-rails
turbo_power (>= 0.6.0)
view_component (>= 3.7.0)
zeitwerk (>= 2.6.12)
Expand Down Expand Up @@ -121,16 +121,16 @@ GEM
ast (2.4.2)
awesome_print (1.9.2)
aws-eventstream (1.3.0)
aws-partitions (1.869.0)
aws-sdk-core (3.190.0)
aws-partitions (1.873.0)
aws-sdk-core (3.190.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.75.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.141.0)
aws-sdk-s3 (1.142.0)
aws-sdk-core (~> 3, >= 3.189.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
Expand All @@ -151,7 +151,6 @@ GEM
bindex (0.8.1)
bootsnap (1.17.0)
msgpack (~> 1.2)
brakeman (6.1.0)
builder (3.2.4)
bump (0.10.0)
bundler-integrity (1.0.9)
Expand Down Expand Up @@ -198,11 +197,12 @@ GEM
ruby2_keywords
dry-initializer (3.1.1)
e2mmap (0.1.0)
erb-formatter (0.3.0)
erb-formatter (0.7.0)
syntax_tree (~> 6.0)
erubi (1.12.0)
factory_bot (6.4.2)
factory_bot (6.4.5)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.2)
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
railties (>= 5.0.0)
faker (3.2.2)
Expand Down Expand Up @@ -251,7 +251,7 @@ GEM
activesupport (>= 3.0)
nokogiri (>= 1.6)
io-console (0.7.1)
irb (1.10.1)
irb (1.11.0)
rdoc
reline (>= 0.3.8)
iso (0.4.0)
Expand Down Expand Up @@ -283,8 +283,8 @@ GEM
mapkick-rb (0.1.5)
marcel (1.0.2)
matrix (0.4.2)
meta-tags (2.19.0)
actionpack (>= 3.2.0, < 7.2)
meta-tags (2.20.0)
actionpack (>= 6.0.0, < 7.2)
method_source (1.0.0)
mini_magick (4.11.0)
mini_mime (1.1.5)
Expand All @@ -303,10 +303,10 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.7.0)
nokogiri (1.15.5)
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.15.5-x86_64-linux)
nokogiri (1.16.0-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (6.2.0)
Expand All @@ -318,6 +318,7 @@ GEM
prefixed_ids (1.6.1)
hashids (>= 1.0.0, < 2.0.0)
rails (>= 6.0.0)
prettier_print (1.2.1)
psych (5.1.2)
stringio
public_suffix (5.0.4)
Expand Down Expand Up @@ -411,22 +412,22 @@ GEM
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.1)
rubocop (1.57.2)
rubocop (1.59.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-performance (1.20.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-shopify (2.14.0)
rubocop (~> 1.51)
ruby-debug-ide (0.7.3)
Expand Down Expand Up @@ -479,26 +480,28 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
standard (1.32.1)
standard (1.33.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.57.2)
rubocop (~> 1.59.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.2)
standard-performance (~> 1.3)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.2.1)
standard-performance (1.3.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.19.1)
rubocop-performance (~> 1.20.1)
stringio (3.1.0)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
test-prof (1.3.1)
thor (1.3.0)
tilt (2.3.0)
timeout (0.4.1)
turbo-rails (2.0.0.pre.beta.1)
turbo-rails (1.5.0)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
Expand Down Expand Up @@ -554,7 +557,6 @@ DEPENDENCIES
awesome_print
aws-sdk-s3
bootsnap (>= 1.4.2)
brakeman
bump
bundler-integrity (~> 1.0)
byebug
Expand Down
17 changes: 13 additions & 4 deletions app/components/avo/field_wrapper_component.html.erb
Expand Up @@ -2,15 +2,24 @@
class: classes,
style: style,
data: data do %>
<div class="h-full <% if stacked? %> md:pt-4 md:w-full <% else %> md:pt-0 <% if short? %> md:h-10 <% else %> md:h-14 <% end %> <% end %> pt-4 flex self-start items-center flex-shrink-0 <%= @field.get_html(:classes, view: view, element: :label) %> w-48 <% if compact? %> md:w-48 xl:w-64 <% else %> md:w-64 <% end %> px-6 uppercase font-semibold text-gray-500 text-sm" data-slot="label">
<%= content_tag :div, class: class_names("pt-4 flex self-start items-center flex-shrink-0 w-48 px-6 uppercase font-semibold text-gray-500 text-sm", @field.get_html(:classes, view: view, element: :label), {
"md:pt-4 md:w-full": stacked?,
"h-full md:pt-0": !stacked?,
"md:h-10 ": !stacked? && short?,
"md:h-14 ": !stacked? && !short?,
"md:w-48 xl:w-64": compact?,
"md:w-64": !compact?,
}), data: {slot: "label"} do %>
<% if form.present? %>
<%= form.label field.id, label %>
<% else %>
<%= field.name %>
<% end %>
<% if on_edit? && field.is_required? %> <span class="text-red-600 ml-1">*</span> <% end %>
</div>
<div class="flex-1 flex flex-row md:min-h-inherit py-2 <% if stacked? %> pb-4 <% else %><% end %> px-6 <%= @field.get_html(:classes, view: view, element: :content) %>" data-slot="value">
<% end %>
<%= content_tag :div, class: class_names("flex-1 flex flex-row md:min-h-inherit py-2 px-6", @field.get_html(:classes, view: view, element: :content), {
"pb-4": stacked?,
}), data: {slot: "value"} do %>
<div class="self-center w-full <% unless full_width? || compact? || stacked? %> md:w-8/12 <% end %>">
<% if on_show? %>
<% if field.value.blank? and dash_if_blank %>
Expand All @@ -28,7 +37,7 @@
<% end %>
<% end %>
</div>
</div>
<% end %>
<% if params[:avo_debug].present? %>
<!-- Raw value: -->
<!-- <%= sanitize field.value.inspect %> -->
Expand Down
@@ -1,3 +1,3 @@
<%= turbo_frame_tag @field.turbo_frame, src: @field.frame_url, loading: loading, target: :_top, class: "block" do %>
<%= turbo_frame_tag @field.turbo_frame, src: @field.frame_url, loading: turbo_frame_loading, target: :_top, class: "block" do %>
<%= render(Avo::LoadingComponent.new(title: @field.plural_name)) %>
<% end %>
7 changes: 1 addition & 6 deletions app/components/avo/fields/has_many_field/show_component.rb
Expand Up @@ -2,10 +2,5 @@

class Avo::Fields::HasManyField::ShowComponent < Avo::Fields::ShowComponent
include Turbo::FramesHelper

def turbo_frame_loading = kwargs[:turbo_frame_loading]

def loading
turbo_frame_loading || params[:turbo_frame_loading] || "eager"
end
include Avo::Fields::Concerns::FrameLoading
end
@@ -1,5 +1,5 @@
<% if @field.value %>
<turbo-frame id="<%= @field.turbo_frame %>" src="<%= @field.frame_url %>" target="_top" class="block">
<turbo-frame id="<%= @field.turbo_frame %>" src="<%= @field.frame_url %>" loading=<%= turbo_frame_loading %> target="_top" class="block">
<%= render(Avo::LoadingComponent.new(title: @field.name)) %>
</turbo-frame>
<% else %>
Expand Down
1 change: 1 addition & 0 deletions app/components/avo/fields/has_one_field/show_component.rb
Expand Up @@ -2,6 +2,7 @@

class Avo::Fields::HasOneField::ShowComponent < Avo::Fields::ShowComponent
include Avo::ApplicationHelper
include Avo::Fields::Concerns::FrameLoading

def can_attach?
policy_result = true
Expand Down
5 changes: 3 additions & 2 deletions app/components/avo/resource_component.rb
Expand Up @@ -240,13 +240,14 @@ def render_edit_button(control)
def render_detach_button(control)
return unless is_a_related_resource? && can_detach?

a_button url: detach_path,
a_link detach_path,
icon: "detach",
method: :delete,
form_class: "flex flex-col sm:flex-row sm:inline-flex",
style: :text,
data: {
confirm: "Are you sure you want to detach this #{title}."
turbo_method: :delete,
turbo_confirm: "Are you sure you want to detach this #{title}."
} do
control.label || t("avo.detach_item", item: title).humanize
end
Expand Down
4 changes: 2 additions & 2 deletions app/components/avo/row_component.html.erb
@@ -1,3 +1,3 @@
<div class="flex flex-col sm:flex-row min-h-14 grow shrink-0" data-component="<%= self.class %>">
<%= content_tag :div, class: "relative grid auto-cols-fr grid-flow-col min-h-14", data: {component: self.class.to_s} do %>
<%= body %>
</div>
<% end %>
5 changes: 3 additions & 2 deletions app/components/avo/sidebar_profile_component.html.erb
Expand Up @@ -41,11 +41,12 @@
<% end %>
<%= render "avo/partials/profile_menu_extra" %>
<% if can_destroy_user? %>
<%= button_to helpers.main_app.send(destroy_user_session_path),
<%= link_to helpers.main_app.send(destroy_user_session_path),
form: { "data-turbo" => "false" },
method: :delete,
data: {
confirm: t('avo.are_you_sure')
turbo_method: :delete,
turbo_confirm: t('avo.are_you_sure')
},
class: "flex-1 flex items-center justify-center bg-white text-left cursor-pointer text-red-600 font-semibold hover:bg-red-100 block px-4 py-1 w-full py-3 text-center rounded w-full",
form_class: 'flex-1' do %>
Expand Down
6 changes: 2 additions & 4 deletions app/components/avo/tab_group_component.rb
Expand Up @@ -7,6 +7,8 @@ class Avo::TabGroupComponent < Avo::BaseComponent
attr_reader :form
attr_reader :resource

delegate :group_param, to: :@group

def initialize(resource:, group:, index:, form:, params:, view:)
@resource = resource
@group = group
Expand All @@ -26,10 +28,6 @@ def tabs_have_content?
visible_tabs.present?
end

def group_param
group.id
end

def active_tab_name
CGI.unescape(params[group_param] || group.visible_items&.first&.name)
end
Expand Down
5 changes: 1 addition & 4 deletions app/components/avo/tab_switcher_component.rb
Expand Up @@ -12,6 +12,7 @@ class Avo::TabSwitcherComponent < Avo::BaseComponent
attr_reader :resource

delegate :white_panel_classes, to: :helpers
delegate :group_param, to: :@group

def initialize(resource:, group:, current_tab:, active_tab_name:, view:)
@active_tab_name = active_tab_name
Expand Down Expand Up @@ -48,10 +49,6 @@ def current_one?(tab)

private

def group_param
"tab-group_#{group.id}"
end

def tab_param_missing?
params[group_param].blank?
end
Expand Down
7 changes: 4 additions & 3 deletions app/components/avo/views/resource_index_component.rb
Expand Up @@ -159,16 +159,17 @@ def render_dynamic_filters_button
end

def scopes_list
Avo::Pro::Scopes::ListComponent.new(
Avo::Advanced::Scopes::ListComponent.new(
scopes: scopes,
resource: resource,
turbo_frame: turbo_frame,
parent_record: parent_record
parent_record: parent_record,
query: query
)
end

def can_render_scopes?
defined?(Avo::Pro)
defined?(Avo::Advanced)
end

private
Expand Down
10 changes: 2 additions & 8 deletions app/controllers/avo/application_controller.rb
Expand Up @@ -45,14 +45,6 @@ def exception_logger(exception)
end
end

def _current_user
instance_eval(&Avo.configuration.current_user)
end

def context
instance_eval(&Avo.configuration.context)
end

# This is coming from Turbo::Frames::FrameRequest module.
# Exposing it as public method
def turbo_frame_request?
Expand Down Expand Up @@ -125,6 +117,8 @@ def detect_fields
end

def set_related_resource
raise Avo::MissingResourceError.new(related_resource_name) if related_resource.nil?

@related_resource = related_resource.new(params: params, view: action_name.to_sym, user: _current_user, record: @related_record).detect_fields
end

Expand Down
2 changes: 0 additions & 2 deletions app/javascript/avo.base.js
Expand Up @@ -5,7 +5,6 @@ import 'regenerator-runtime/runtime'
import * as ActiveStorage from '@rails/activestorage'
import * as Mousetrap from 'mousetrap'
import { Turbo } from '@hotwired/turbo-rails'
import Rails from '@rails/ujs'
import tippy from 'tippy.js'

import { LocalStorageService } from './js/local-storage-service'
Expand All @@ -18,7 +17,6 @@ import './js/active-storage'
import './js/controllers'
import './js/custom-stream-actions'

Rails.start()

window.Turbolinks = Turbo

Expand Down
1 change: 0 additions & 1 deletion app/javascript/js/application.js
Expand Up @@ -2,7 +2,6 @@ import 'mapkick/bundle'

import { Alert, Popover } from 'tailwindcss-stimulus-components'
import { Application } from '@hotwired/stimulus'
import { Turbo } from '@hotwired/turbo-rails'
import TurboPower from 'turbo_power'

TurboPower.initialize(Turbo.StreamActions)
Expand Down

0 comments on commit 7454bdf

Please sign in to comment.