mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: Move about_stat_groups to DiscoursePluginRegistry (#20496)
Follow up to 098ab29d4150a5a39880d59ef6cad5f6795a18fd. Since we just used a `cattr_reader` on `About` this was not safe for multisite, since some sites could have the chat plugin enabled and some may not. Using `DiscoursePluginRegistry` gets around this issue, and makes it so the chat stats only show for a site if `chat_enabled` is true.
This commit is contained in:
@ -1129,7 +1129,17 @@ class Plugin::Instance
|
||||
# table. Some stats may be needed purely for reporting purposes and thus
|
||||
# do not need to be shown in the UI to admins/users.
|
||||
def register_about_stat_group(plugin_stat_group_name, show_in_ui: false, &block)
|
||||
About.add_plugin_stat_group(plugin_stat_group_name, show_in_ui: show_in_ui, &block)
|
||||
# We do not want to register and display the same group multiple times.
|
||||
if DiscoursePluginRegistry.about_stat_groups.any? { |stat_group|
|
||||
stat_group[:name] == plugin_stat_group_name
|
||||
}
|
||||
return
|
||||
end
|
||||
|
||||
DiscoursePluginRegistry.register_about_stat_group(
|
||||
{ name: plugin_stat_group_name, show_in_ui: show_in_ui, block: block },
|
||||
self,
|
||||
)
|
||||
end
|
||||
|
||||
##
|
||||
|
Reference in New Issue
Block a user