Skip to content

Commit

Permalink
backstage admin
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Jul 13, 2024
1 parent fd283bd commit 0314a1e
Show file tree
Hide file tree
Showing 151 changed files with 578 additions and 836 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,5 @@ gem "sequel", "~> 5.71"

gem "mrsk", "~> 0.15.1"

gem 'backstage-rails', path: 'backstage-rails'
# gem 'backstage-rails', path: 'backstage-rails'
gem 'backstage', path: 'backstage'
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ GIT
rspec-support (3.13.0.pre)

PATH
remote: backstage-rails
remote: backstage
specs:
backstage-rails (0.1.0)
backstage (0.1.0)
rails (>= 7.1.3.2)

GEM
Expand Down Expand Up @@ -655,7 +655,7 @@ DEPENDENCIES
acts_as_list (~> 0.9.19)
aws-sdk-rails
aws-sdk-s3 (~> 1.48)
backstage-rails!
backstage!
bootsnap
browser (~> 5.3)
capybara
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Admin::CategoriesController < Backstage::Rails::BaseController
class Admin::CategoriesController < Backstage::BaseController

private

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/admin/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Admin::DashboardController < Backstage::Rails::BaseController
class Admin::DashboardController < Backstage::BaseController
def index
readme_path = Rails.root.join('app', 'views', 'admin', 'README.md')
@readme_content = File.exist?(readme_path) ? File.read(readme_path) : "Welcome to the Admin Panel"
render "index"
end
end
2 changes: 1 addition & 1 deletion app/controllers/admin/posts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Admin::PostsController < Backstage::Rails::BaseController
class Admin::PostsController < Backstage::BaseController

private

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/terms_and_conditions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Admin::TermsAndConditionsController < Backstage::Rails::BaseController
class Admin::TermsAndConditionsController < Backstage::BaseController

private

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Admin::UsersController < Backstage::Rails::BaseController
class Admin::UsersController < Backstage::BaseController

private

Expand Down
84 changes: 0 additions & 84 deletions app/models/admin.rb

This file was deleted.

85 changes: 85 additions & 0 deletions app/models/backstage_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
require "backstage/config"

module BackstageConfig

Backstage::Config.configure do
resource :users do
column :id
column :email
column :username
column :role
column :editor

scope :all
scope :admins, -> { where(role: 'admin') }
scope :recent, -> { where('created_at > ?', 1.week.ago) }

filter :email_cont, :string, label: 'Email contains'
filter :username_cont, :string, label: 'Username contains'
filter :role_cont, :select, collection: -> { User.roles.keys }

filterable_field :username, :string
filterable_field :email, :string
filterable_field :role, :select, collection: -> { [:admin, :artist] }

form_field :email, :email
form_field :username, :string
form_field :role, :select, collection: -> { User.roles.keys }, include_blank: false
form_field :seller, :boolean
form_field :editor, :check_box

action :view
action :edit
action :delete
end

resource :categories do
column :id
column :name

filter :name, :string, label: 'Name contains'

form_field :name_cont, :string

action :view
action :edit
action :delete
end

resource :posts do
column :id
column :title
column :author do |post, view|
view.link_to post.user.full_name, view.admin_user_path(post.user)
end

scope :all
scope :published, -> { where(published: true) }
scope :draft, -> { where(published: false) }
scope :recent, -> { where('created_at > ?', 1.week.ago) }

filter :title, :string, label: 'Name contains'

form_field :title_cont, :string

action :view
action :edit
action :delete
end

resource :terms_and_conditions do

column :id
column :title

form_field :title, :string
form_field :category, :string
form_field :content, :custom, ->(view, form) { view.render("shared/simple_editor", form: form, field: :content) }

action :view
action :edit
action :delete
end
end

end
12 changes: 5 additions & 7 deletions app/views/admin/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<div class="bg-white shadow rounded-lg p-6">
<h1 class="text-2xl font-semibold mb-6">Admin Dashboard</h1>

<div class="prose prose-sm sm:prose lg:prose-lg xl:prose-xl mx-auto">
<%= markdown(@readme_content) %>
</div>
</div>
<h1 class="text-2xl font-semibold mb-6">Admin Dashboard</h1>

<div class="prose prose-sm sm:prose lg:prose-lg xl:prose-xl mx-auto">
<%= markdown(@readme_content) %>
</div>
8 changes: 0 additions & 8 deletions app/views/admin/default--/add_filter.turbo_stream.erb

This file was deleted.

10 changes: 0 additions & 10 deletions app/views/admin/default--/edit.html.erb

This file was deleted.

26 changes: 0 additions & 26 deletions app/views/admin/default--/index.html.erb

This file was deleted.

9 changes: 0 additions & 9 deletions app/views/admin/default--/new.html.erb

This file was deleted.

27 changes: 0 additions & 27 deletions app/views/admin/default--/show.html.erb

This file was deleted.

19 changes: 0 additions & 19 deletions app/views/admin/shared--/_form.erb

This file was deleted.

11 changes: 0 additions & 11 deletions app/views/admin/shared--/_scopes_menu.html.erb

This file was deleted.

Loading

0 comments on commit 0314a1e

Please sign in to comment.