mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 19:29:34 +08:00
DEV: Add a new type_source
field to the Reviewable
model. (#31325)
This change adds a new `type_source` field to the `Reviewable` model, indicating whether the Reviewable type was registered by `core`, a plugin, or an `unknown` source. When a plugin that registered a Reviewable type is disabled, this allows us to tell the user which plugin they need to re-enable to handle any orphan reviewable items.
This commit is contained in:
@ -50,6 +50,8 @@ class DiscoursePluginRegistry
|
||||
define_singleton_method("register_#{register_name.to_s.singularize}") do |value, plugin|
|
||||
public_send(:"_raw_#{register_name}") << { plugin: plugin, value: value }
|
||||
end
|
||||
|
||||
yield(self) if block_given?
|
||||
end
|
||||
|
||||
define_register :javascripts, Set
|
||||
@ -129,6 +131,14 @@ class DiscoursePluginRegistry
|
||||
|
||||
define_filtered_register :custom_filter_mappings
|
||||
|
||||
define_filtered_register :reviewable_types do |singleton|
|
||||
singleton.define_singleton_method("reviewable_types_lookup") do
|
||||
public_send(:"_raw_reviewable_types")
|
||||
.filter_map { |h| { plugin: h[:plugin].name, klass: h[:value] } if h[:plugin].enabled? }
|
||||
.uniq
|
||||
end
|
||||
end
|
||||
|
||||
def self.register_auth_provider(auth_provider)
|
||||
self.auth_providers << auth_provider
|
||||
end
|
||||
|
Reference in New Issue
Block a user