2020-04-19 13:35:58 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-12-10 08:01:59 -08:00
|
|
|
# workaround to get pagination right
|
|
|
|
RailsAdmin.config do |config|
|
2023-01-03 03:30:53 -08:00
|
|
|
config.asset_source = :sprockets
|
2022-07-27 12:09:32 -07:00
|
|
|
config.main_app_name = %w[justask Kontrollzentrum]
|
|
|
|
config.parent_controller = "::ApplicationController"
|
2014-12-10 08:01:59 -08:00
|
|
|
|
|
|
|
## == Authentication ==
|
|
|
|
config.authenticate_with do
|
2020-04-19 13:35:58 -07:00
|
|
|
redirect_to main_app.root_path unless current_user&.has_role?(:administrator)
|
2014-12-10 08:01:59 -08:00
|
|
|
end
|
|
|
|
config.current_user_method(&:current_user)
|
|
|
|
|
|
|
|
config.actions do
|
|
|
|
dashboard # mandatory
|
|
|
|
index # mandatory
|
|
|
|
new
|
|
|
|
export
|
|
|
|
bulk_delete
|
|
|
|
show
|
|
|
|
edit
|
|
|
|
delete
|
|
|
|
show_in_app
|
|
|
|
|
|
|
|
## With an audit adapter, you can add:
|
|
|
|
# history_index
|
|
|
|
# history_show
|
|
|
|
end
|
|
|
|
|
|
|
|
config.included_models = %w[
|
2022-07-05 14:17:22 -07:00
|
|
|
Appendable
|
|
|
|
Appendable::Reaction
|
2014-12-10 08:01:59 -08:00
|
|
|
Answer
|
2022-06-15 06:38:04 -07:00
|
|
|
AnonymousBlock
|
2014-12-10 08:01:59 -08:00
|
|
|
Comment
|
2020-05-25 09:04:54 -07:00
|
|
|
List
|
|
|
|
ListMember
|
2014-12-10 08:01:59 -08:00
|
|
|
Inbox
|
2022-01-02 07:24:30 -08:00
|
|
|
MuteRule
|
2014-12-26 05:31:59 -08:00
|
|
|
Notification
|
2021-12-31 10:25:17 -08:00
|
|
|
Profile
|
2014-12-10 08:01:59 -08:00
|
|
|
Question
|
|
|
|
Relationship
|
2022-06-15 06:38:04 -07:00
|
|
|
Relationships::Follow
|
|
|
|
Relationships::Block
|
2023-01-01 09:21:21 -08:00
|
|
|
Relationships::Mute
|
2014-12-27 05:35:09 -08:00
|
|
|
Report
|
2014-12-26 05:31:59 -08:00
|
|
|
Service
|
|
|
|
Services::Twitter
|
2015-08-25 12:10:08 -07:00
|
|
|
Theme
|
2014-12-10 08:01:59 -08:00
|
|
|
User
|
2021-12-30 12:39:05 -08:00
|
|
|
UserBan
|
2023-01-03 08:31:43 -08:00
|
|
|
WebPushSubscription
|
2014-12-10 08:01:59 -08:00
|
|
|
]
|
2022-07-27 12:09:27 -07:00
|
|
|
|
|
|
|
# set up icons for some models
|
|
|
|
{
|
|
|
|
"AnonymousBlock" => "user-secret",
|
|
|
|
"Answer" => "exclamation",
|
|
|
|
"Appendable" => "paperclip",
|
|
|
|
"Appendable::Reaction" => "smile",
|
|
|
|
"Comment" => "comment",
|
|
|
|
"Inbox" => "inbox",
|
|
|
|
"List" => "list",
|
|
|
|
"ListMember" => "users",
|
|
|
|
"MuteRule" => "volume-mute",
|
|
|
|
"Notification" => "bell",
|
|
|
|
"Profile" => "id-card",
|
|
|
|
"Question" => "question",
|
|
|
|
"Relationship" => "people-arrows",
|
|
|
|
"Relationships::Block" => "user-slash",
|
|
|
|
"Relationships::Follow" => "user-friends",
|
2023-01-01 09:21:21 -08:00
|
|
|
"Relationships::Mute" => "volume-mute",
|
2022-07-27 12:09:27 -07:00
|
|
|
"Report" => "exclamation-triangle",
|
|
|
|
"Service" => "network-wired",
|
|
|
|
"Services::Twitter" => "dumpster-fire",
|
|
|
|
"Theme" => "paint-brush",
|
|
|
|
"User" => "user",
|
2023-01-04 14:46:06 -08:00
|
|
|
"UserBan" => "user-lock",
|
|
|
|
"WebPushSubscription" => "dot-circle"
|
2022-07-27 12:09:27 -07:00
|
|
|
}.each do |model, icon|
|
|
|
|
config.model model do
|
|
|
|
navigation_icon "fa fa-fw fa-#{icon} me-1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# set up custom parents for certain models to group them nicely together
|
|
|
|
{
|
2023-01-04 14:46:06 -08:00
|
|
|
"AnonymousBlock" => User,
|
|
|
|
"Inbox" => User,
|
|
|
|
"List" => User,
|
|
|
|
"MuteRule" => User,
|
|
|
|
"Notification" => User,
|
|
|
|
"Profile" => User,
|
|
|
|
"Relationship" => User,
|
|
|
|
"Service" => User,
|
|
|
|
"Theme" => User,
|
|
|
|
"WebPushSubscription" => User,
|
2022-07-27 12:09:27 -07:00
|
|
|
|
2023-01-04 14:46:06 -08:00
|
|
|
"ListMember" => List
|
2022-07-27 12:09:27 -07:00
|
|
|
}.each do |model, parent_model|
|
|
|
|
config.model model do
|
|
|
|
parent parent_model
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# create groups inside nav tree
|
|
|
|
{
|
|
|
|
"User content" => %w[
|
|
|
|
Answer
|
|
|
|
Appendable
|
|
|
|
Comment
|
|
|
|
Question
|
|
|
|
User
|
|
|
|
],
|
|
|
|
"Global" => %w[
|
|
|
|
Report
|
|
|
|
UserBan
|
|
|
|
]
|
|
|
|
}.each do |label, models|
|
|
|
|
models.each do |model|
|
|
|
|
config.model model do
|
|
|
|
navigation_label label
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-12-10 08:01:59 -08:00
|
|
|
end
|