Skip to content

Commit

Permalink
fix Avo
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev committed May 19, 2023
1 parent 567c568 commit 8ede7d7
Show file tree
Hide file tree
Showing 44 changed files with 1,354 additions and 525 deletions.
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ gem "awesome_print"
# source "https://heheheh@packager.dev/avo" do
# gem "avo", path: "./avo"
source "https://#{ENV['AVO_GEM_TOKEN']}@packager.fly.dev/avo-hq-beta/" do
gem "avo", "3.0.0.pre.6"
gem "avo", "3.0.0.pre.11"
gem "avo_pro"
gem "avo_advanced"
gem "avo_filters"
Expand All @@ -112,6 +112,10 @@ end
# gem "avo_menu", path: "/Users/adrian/work/avocado/gems/avo_menu"
# gem "avo_dashboards", path: "/Users/adrian/work/avocado/gems/avo_dashboards"

group :development do
gem "avo_upgrade", path: "/Users/adrian/work/avocado/gems/avo_upgrade"
end

gem 'newrelic_rpm'

gem 'ransack'
Expand Down
163 changes: 88 additions & 75 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
PATH
remote: /Users/adrian/work/avocado/gems/avo_upgrade
specs:
avo_upgrade (0.1.0)
rails (>= 6.0.0)
zeitwerk

GEM
remote: https://a1c254a4-6687-4523-bcf2-cd3dfca2b1cf@packager.fly.dev/avo-hq-beta/
specs:
avo (3.0.0.pre6)
avo (3.0.0.pre11)
actionview (>= 6.1)
active_link_to
activerecord (>= 6.1)
Expand All @@ -15,100 +22,100 @@ GEM
turbo-rails
view_component (>= 3.0.0)
zeitwerk (>= 2.6.2)
avo_advanced (0.1.49)
avo_advanced (0.1.51)
avo
rails (>= 6.1.0)
zeitwerk
avo_dashboards (0.1.3)
avo_dashboards (0.1.4)
avo
rails (>= 6.1.0)
turbo-rails
view_component
zeitwerk
avo_filters (0.5.7)
avo_filters (0.5.8)
avo
rails (>= 6.1.0)
ransack
view_component
zeitwerk
avo_menu (0.1.9)
avo_menu (0.1.10)
avo
docile
dry-initializer
rails (>= 6.1.0)
zeitwerk
avo_pro (0.1.50)
avo_pro (0.1.51)
avo
rails (>= 6.1.0)
zeitwerk

GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
actioncable (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.4)
actionpack (= 7.0.4)
activejob (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
actionmailbox (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.4)
actionpack (= 7.0.4)
actionview (= 7.0.4)
activejob (= 7.0.4)
activesupport (= 7.0.4)
actionmailer (7.0.4.3)
actionpack (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activesupport (= 7.0.4.3)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.4)
actionview (= 7.0.4)
activesupport (= 7.0.4)
actionpack (7.0.4.3)
actionview (= 7.0.4.3)
activesupport (= 7.0.4.3)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.4)
actionpack (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
actiontext (7.0.4.3)
actionpack (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.4)
activesupport (= 7.0.4)
actionview (7.0.4.3)
activesupport (= 7.0.4.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_link_to (1.0.5)
actionpack
addressable
activejob (7.0.4)
activesupport (= 7.0.4)
activejob (7.0.4.3)
activesupport (= 7.0.4.3)
globalid (>= 0.3.6)
activemodel (7.0.4)
activesupport (= 7.0.4)
activerecord (7.0.4)
activemodel (= 7.0.4)
activesupport (= 7.0.4)
activestorage (7.0.4)
actionpack (= 7.0.4)
activejob (= 7.0.4)
activerecord (= 7.0.4)
activesupport (= 7.0.4)
activemodel (7.0.4.3)
activesupport (= 7.0.4.3)
activerecord (7.0.4.3)
activemodel (= 7.0.4.3)
activesupport (= 7.0.4.3)
activestorage (7.0.4.3)
actionpack (= 7.0.4.3)
activejob (= 7.0.4.3)
activerecord (= 7.0.4.3)
activesupport (= 7.0.4.3)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.4)
activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -163,6 +170,7 @@ GEM
countries (5.1.2)
sixarm_ruby_unaccent (~> 1.1)
crass (1.0.6)
date (3.3.3)
debug (1.5.0)
irb (>= 1.3.6)
reline (>= 0.2.7)
Expand Down Expand Up @@ -212,11 +220,14 @@ GEM
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jmespath (1.6.1)
loofah (2.20.0)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
mapkick-rb (0.1.4)
marcel (1.0.2)
matrix (0.4.2)
Expand All @@ -228,21 +239,22 @@ GEM
minitest (5.18.0)
msgpack (1.5.1)
multi_xml (0.6.0)
net-imap (0.3.1)
net-imap (0.3.4)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.1.3)
net-protocol (0.2.1)
timeout
net-smtp (0.3.2)
net-smtp (0.3.3)
net-protocol
newrelic_rpm (8.6.0)
nio4r (2.5.8)
nokogiri (1.14.3-arm64-darwin)
nio4r (2.5.9)
nokogiri (1.15.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.3-x86_64-darwin)
nokogiri (1.15.0-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.14.3-x86_64-linux)
nokogiri (1.15.0-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (6.0.4)
Expand All @@ -256,36 +268,36 @@ GEM
rack (2.2.7)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.4)
actioncable (= 7.0.4)
actionmailbox (= 7.0.4)
actionmailer (= 7.0.4)
actionpack (= 7.0.4)
actiontext (= 7.0.4)
actionview (= 7.0.4)
activejob (= 7.0.4)
activemodel (= 7.0.4)
activerecord (= 7.0.4)
activestorage (= 7.0.4)
activesupport (= 7.0.4)
rails (7.0.4.3)
actioncable (= 7.0.4.3)
actionmailbox (= 7.0.4.3)
actionmailer (= 7.0.4.3)
actionpack (= 7.0.4.3)
actiontext (= 7.0.4.3)
actionview (= 7.0.4.3)
activejob (= 7.0.4.3)
activemodel (= 7.0.4.3)
activerecord (= 7.0.4.3)
activestorage (= 7.0.4.3)
activesupport (= 7.0.4.3)
bundler (>= 1.15.0)
railties (= 7.0.4)
railties (= 7.0.4.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
railties (7.0.4)
actionpack (= 7.0.4)
activesupport (= 7.0.4)
railties (7.0.4.3)
actionpack (= 7.0.4.3)
activesupport (= 7.0.4.3)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rake (13.0.6)
ransack (3.1.0)
activerecord (>= 6.0.4)
activesupport (>= 6.0.4)
ransack (4.0.0)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
redis (4.6.0)
regexp_parser (2.3.1)
Expand Down Expand Up @@ -318,8 +330,8 @@ GEM
railties (>= 6.0.0)
tailwindcss-rails (2.0.8-x86_64-linux)
railties (>= 6.0.0)
thor (1.2.1)
timeout (0.3.0)
thor (1.2.2)
timeout (0.3.2)
turbo-rails (1.4.0)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
Expand Down Expand Up @@ -361,12 +373,13 @@ DEPENDENCIES
acts_as_list
annotate
appsignal
avo (= 3.0.0.pre.6)!
avo (= 3.0.0.pre.11)!
avo_advanced!
avo_dashboards!
avo_filters!
avo_menu!
avo_pro!
avo_upgrade!
awesome_print
aws-sdk-s3
bootsnap
Expand Down
31 changes: 31 additions & 0 deletions app/avo/actions/export_csv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class Avo::Actions::ExportCsv < Avo::BaseAction
self.name = "Export csv"
self.no_confirmation = false
self.may_download_file = true

def handle(**args)
records, resource = args.values_at(:records, :resource)

return error "No record selected" if records.blank?

attributes = get_attributes records.first

file = CSV.generate(headers: true) do |csv|
csv << attributes

records.each do |record|
csv << attributes.map do |attr|
record.send(attr)
end
end
end

download file, "#{resource.plural_name}.csv"
end

def get_attributes(record)
# return ["id", "created_at"] # uncomment this and fill in for custom model properties

record.class.columns_hash.keys
end
end
8 changes: 4 additions & 4 deletions app/avo/actions/release_fish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ class Avo::Actions::ReleaseFish < Avo::BaseAction

def fields
field :message, as: :trix, help: "Tell the fish something before releasing."
field :user, as: :belongs_to, searchable: true, visible: ->(resource:) {
field :user, as: :belongs_to, searchable: true, visible: -> {
resource.params[:id].present?
}
end

def handle(**args)
args[:models].each do |model|
model.release
args[:records].each do |record|
record.release
end

succeed "#{args[:models].count} fish released with message '#{args[:fields][:message]}'."
succeed "#{args[:records].count} fish released with message '#{args[:fields][:message]}'."
end
end
14 changes: 7 additions & 7 deletions app/avo/actions/toggle_active.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ def fields
field :message, as: :textarea, default: 'Your account has been marked as inactive.'
end

def handle(models:, fields:, current_user:, resource:)
models.each do |model|
if model.active
model.update active: false
def handle(records:, fields:, current_user:, resource:)
records.each do
if record.active
record.update active: false
else
model.update active: true
record.update active: true
end

model.notify fields['message'] if fields['notify_user']
record.notify fields['message'] if fields['notify_user']
end

succeed 'Perfect!'
end
end
end
Loading

0 comments on commit 8ede7d7

Please sign in to comment.