* Remove Connect
* Remove more Connect specs
* Remove a lot more Connect code
* 🚮
* It all has to go
* Explicitly add httpclient
* Update application layout
* Remove messages association from User
* Start fixing specs
* reintroduce util function and refactor references
* Remove Connect Cypress test
* Fix more specs
* Remove Connect from listings
* Ignore contact_via_connect column on listings
* Remove contact_via_connect usages
* Ignore mod_chat_channel_id on tags
* Drop Connect tables
* Remove email_connect_messages from user notification settings
* Re-add httpclient 2.8.3
This was mistakenly removed as a merge conflict
* Don't need to exclude removed chat channel file
* Remove unneeded style for chat channels
* Remove unneeded channel list prop type
* Remove chat channels index/connect-link from getPageEntries
* Re-add comment from httpclient in Gemfile
* Remove connect references from mailers
Tag Moderators no longer have a chat channel
No longer will users be notified about new messages (there won't be
any)
No longer will users be notified about channel invites (you can't
invite anyone anymore)
* Don't configure Pusher and remove PUSHER_* from .env_sample
since it's removed from gemfile, the Pusher constant will not resolve, if this is
configured in the environment variables we'll fail to boot.
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Dan Uber <dan@forem.com>
111 lines
3.7 KiB
Ruby
111 lines
3.7 KiB
Ruby
# This "model" is not backed by the database. Its main purpose is to
|
|
# setup and provide methods to interact with the admin sidebar and tabbed menu
|
|
class AdminMenu
|
|
# On second level navigation with more children, we reference the default tabs controller. i.e look at developer_tools
|
|
# rubocop:disable Metrics/BlockLength
|
|
FEATURE_FLAGS = %i[profile_admin data_update_scripts].freeze
|
|
|
|
ITEMS = Menu.define do
|
|
scope :people, "group-2-line", [
|
|
item(name: "people", controller: "users"),
|
|
]
|
|
|
|
scope :content_manager, "dashboard-line", [
|
|
item(name: "posts", controller: "articles"),
|
|
item(name: "comments", controller: "comments"),
|
|
item(name: "badges", children: [
|
|
item(name: "library", controller: "badges"),
|
|
item(name: "achievements", controller: "badge_achievements"),
|
|
]),
|
|
item(name: "organizations"),
|
|
item(name: "podcasts"),
|
|
item(name: "tags"),
|
|
]
|
|
|
|
scope :customization, "tools-line", [
|
|
item(name: "config"),
|
|
item(name: "html variants", controller: "html_variants"),
|
|
item(name: "display ads"),
|
|
item(name: "navigation links"),
|
|
item(name: "pages"),
|
|
item(name: "profile fields", visible: false),
|
|
]
|
|
|
|
scope :admin_team, "user-line", [
|
|
item(name: "admin team", controller: "permissions"),
|
|
]
|
|
|
|
scope :moderation, "mod", [
|
|
item(name: "reports"),
|
|
item(name: "mods"),
|
|
item(name: "moderator actions ads", controller: "moderator_actions"),
|
|
item(name: "privileged reactions"),
|
|
# item(name: "interaction limits")
|
|
]
|
|
|
|
scope :advanced, "flashlight-line", [
|
|
item(name: "broadcasts"),
|
|
item(name: "response templates"),
|
|
item(name: "sponsorships"),
|
|
item(name: "developer tools", controller: "tools", children: [
|
|
item(name: "tools"),
|
|
item(name: "vault secrets", controller: "secrets"),
|
|
item(name: "webhooks", controller: "webhook_endpoints"),
|
|
item(name: "data update scripts", visible: false),
|
|
]),
|
|
]
|
|
|
|
scope :apps, "palette-line", [
|
|
item(name: "consumer apps", controller: "consumer_apps"),
|
|
item(name: "listings"),
|
|
item(name: "welcome"),
|
|
]
|
|
end.freeze
|
|
# rubocop:enable Metrics/BlockLength
|
|
|
|
def self.navigation_items
|
|
return ITEMS unless FEATURE_FLAGS.any? { |flag| FeatureFlag.enabled?(flag) }
|
|
|
|
feature_flagged_menu_items
|
|
end
|
|
|
|
def self.nested_menu_items(scope_name, nav_item)
|
|
return unless navigation_items.dig(scope_name.to_sym, :children)
|
|
|
|
navigation_items.dig(scope_name.to_sym, :children).each do |items|
|
|
return items if items[:controller] == nav_item
|
|
|
|
next unless items[:children]&.any?
|
|
|
|
items[:children].each do |child|
|
|
return items if child[:controller] == nav_item
|
|
end
|
|
end
|
|
end
|
|
|
|
def self.nested_menu_items_from_request(request)
|
|
scope, nav_item = request.path.split("/").last(2)
|
|
nested_menu_items(scope, nav_item)
|
|
end
|
|
|
|
def self.feature_flagged_menu_items
|
|
# We default to creating a ITEMS constant with visibility set to false
|
|
# and then simply amend the visibility of the feature flag when it's
|
|
# turned on, instead of creating the payload dynamically each time.
|
|
menu_items = ITEMS.deep_dup
|
|
|
|
if FeatureFlag.enabled?(:profile_admin)
|
|
profile_hash = menu_items.dig(:customization, :children).detect { |item| item[:controller] == "profile_fields" }
|
|
profile_hash[:visible] = true
|
|
end
|
|
|
|
if FeatureFlag.enabled?(:data_update_scripts)
|
|
data_update_script_hash = menu_items.dig(:advanced, :children)
|
|
.detect { |item| item[:controller] == "tools" }[:children]
|
|
.detect { |item| item[:controller] == "data_update_scripts" }
|
|
data_update_script_hash[:visible] = true
|
|
end
|
|
|
|
menu_items
|
|
end
|
|
end
|