Skip to content

Commit

Permalink
chore: Set up Avo Meta
Browse files Browse the repository at this point in the history
  • Loading branch information
julianrubisch committed Nov 26, 2024
1 parent bbf4bd4 commit ba830e3
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,5 @@ gem "avo-record_link_field"
gem "pagy", "> 8"

gem "csv"

gem "avo-meta", github: "avo-hq/avo-meta", branch: "main"
53 changes: 32 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ GIT
acts-as-taggable-on (10.0.0)
activerecord (>= 6.1, < 8)

GIT
remote: https://github.com/avo-hq/avo-meta.git
revision: 874345836c3e686c2d716a0ae542caaad3aa8cab
branch: main
specs:
avo-meta (0.1.0)
avo (~> 3)
store_model (~> 4.1)

GIT
remote: https://github.com/rails/rails.git
revision: b88d9af34fbc1c84ce2769ba02584eab2c28ac6e
Expand Down Expand Up @@ -180,7 +189,7 @@ GEM
backport (1.2.0)
base64 (0.2.0)
bcrypt (3.1.20)
benchmark (0.3.0)
benchmark (0.4.0)
benchmark-ips (2.14.0)
better_html (2.1.1)
actionview (>= 6.0)
Expand Down Expand Up @@ -369,7 +378,7 @@ GEM
activesupport (>= 3.0)
nokogiri (>= 1.6)
io-console (0.7.2)
irb (1.14.0)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
iso (0.4.0)
Expand All @@ -392,7 +401,7 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.1)
loofah (2.22.0)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand All @@ -410,8 +419,8 @@ GEM
mini_histogram (0.3.1)
mini_magick (4.13.2)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.25.1)
mini_portile2 (2.8.8)
minitest (5.25.2)
monetize (1.13.0)
money (~> 6.12)
money (6.19.0)
Expand All @@ -438,7 +447,7 @@ GEM
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (9.0.9)
pagy (9.3.1)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
Expand All @@ -451,20 +460,19 @@ GEM
prettier_print (1.2.1)
prop_initializer (0.2.0)
zeitwerk (>= 2.6.18)
psych (5.1.2)
psych (5.2.0)
stringio
public_suffix (6.0.1)
puma (6.4.3)
nio4r (~> 2.0)
racc (1.8.1)
rack (3.1.7)
rack (3.1.8)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rackup (2.2.1)
rack (>= 3)
webrick (~> 1.8)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
Expand All @@ -489,7 +497,7 @@ GEM
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (2.8.4)
rdoc (6.7.0)
rdoc (6.8.1)
psych (>= 4.0.0)
redis (5.3.0)
redis-client (>= 0.22.0)
Expand All @@ -501,7 +509,7 @@ GEM
rainbow (>= 2.0, < 4.0)
rexml (~> 3.1)
regexp_parser (2.9.2)
reline (0.5.10)
reline (0.5.11)
io-console (~> 0.5)
responders (3.1.1)
actionpack (>= 5.2)
Expand Down Expand Up @@ -567,7 +575,7 @@ GEM
simplecov (>= 0.22.0)
tty-which (~> 0.5.0)
virtus (~> 2.0)
securerandom (0.3.1)
securerandom (0.3.2)
sexp_processor (4.17.2)
simplecov (0.22.0)
docile (~> 1.1)
Expand Down Expand Up @@ -621,7 +629,9 @@ GEM
standard-performance (1.4.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
stringio (3.1.1)
store_model (4.1.0)
activerecord (>= 7.0)
stringio (3.1.2)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
terminal-table (3.0.2)
Expand All @@ -630,9 +640,9 @@ GEM
thor (1.3.2)
thread_safe (0.3.6)
tilt (2.4.0)
timeout (0.4.1)
timeout (0.4.2)
tty-which (0.5.0)
turbo-rails (2.0.10)
turbo-rails (2.0.11)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
turbo_power (0.6.2)
Expand All @@ -641,10 +651,10 @@ GEM
concurrent-ruby (~> 1.0)
unaccent (0.4.0)
unicode-display_width (2.6.0)
uri (0.13.1)
uri (1.0.2)
useragent (0.16.10)
view_component (3.17.0)
activesupport (>= 5.2.0, < 8.0)
view_component (3.20.0)
activesupport (>= 5.2.0, < 8.1)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
virtus (2.0.0)
Expand All @@ -662,14 +672,14 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.2)
webrick (1.9.0)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.37)
zeitwerk (2.6.18)
zeitwerk (2.7.1)

PLATFORMS
ruby
Expand All @@ -687,6 +697,7 @@ DEPENDENCIES
annotate
appraisal
avo!
avo-meta!
avo-money_field
avo-record_link_field
aws-sdk-s3
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/avo/resources/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def fields
# suggestions_max_items: 2,
help: "The only allowed values here are `one`, `two`, and `three`"

meta_panel

field :cover_photo_attachment, as: :has_one

field :comments, as: :has_many, use_resource: Avo::Resources::PhotoComment
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/avo/resources/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def fields

user_information_panel

meta_panel

first_tabs_group
second_tabs_group

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# slug :string
#
class Post < ApplicationRecord
include Avo::Metaable

if Gem::Version.new(Rails.version) >= Gem::Version.new("7.3.0")
enum :status, [:draft, :published, :archived]
else
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
class User < ApplicationRecord
ACCOUNT_STRUCT = Struct.new(:id, :name) unless const_defined?(:ACCOUNT_STRUCT)

include Avo::Metaable
extend FriendlyId

# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
get "custom_tool", to: "avo/tools#custom_tool", as: :custom_tool
end

mount Avo::Meta::Engine, at: "#{Avo.configuration.root_path}/avo_meta/"
mount Avo::Engine, at: Avo.configuration.root_path
# Uncomment to test constraints /123/en/admin
# scope ":course", constraints: {course: /\w+(-\w+)*/} do
Expand Down
5 changes: 5 additions & 0 deletions spec/dummy/db/migrate/20241030100735_add_meta_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMetaToUsers < ActiveRecord::Migration[8.0]
def change
add_column :users, :meta, :json
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This migration comes from avo_meta (originally 20241111092303)
class CreateAvoMetaSchemas < ActiveRecord::Migration[7.2]
def change
create_table :avo_meta_schemas do |t|
t.string :resource_name
t.json :schema_entries

t.timestamps
end

add_index :avo_meta_schemas, :resource_name, unique: true
end
end
25 changes: 23 additions & 2 deletions spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

ActiveRecord::Schema[8.0].define(version: 2024_11_14_165947) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "pg_catalog.plpgsql"

create_table "action_text_rich_texts", force: :cascade do |t|
t.string "name", null: false
Expand Down Expand Up @@ -52,6 +52,26 @@
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end

create_table "avo_meta_schemas", force: :cascade do |t|
t.string "resource_name"
t.json "schema_entries"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["resource_name"], name: "index_avo_meta_schemas_on_resource_name", unique: true
end

create_table "avo_resources", force: :cascade do |t|
t.string "name", null: false
t.json "fields", null: false
t.json "includes"
t.json "attachments"
t.json "single_includes"
t.json "single_attachments"
t.json "meta", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

create_table "cities", force: :cascade do |t|
t.string "name"
t.integer "population"
Expand Down Expand Up @@ -172,7 +192,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "price_cents", default: 0, null: false
t.string "price_currency", default: "'USD'::character varying", null: false
t.string "price_currency", default: "USD", null: false
end

create_table "projects", force: :cascade do |t|
Expand Down Expand Up @@ -290,6 +310,7 @@
t.datetime "updated_at", null: false
t.boolean "active", default: true
t.string "slug"
t.json "meta"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["slug"], name: "index_users_on_slug", unique: true
Expand Down

0 comments on commit ba830e3

Please sign in to comment.