DEV: Move settings to linkify to the serializer code. (#14553)

We aren't translating these settings, so it makes more sense to move them into the code. I added an instance method so plugins can add mappings for custom reasons.
This commit is contained in:
Roman Rizzi
2021-10-07 12:41:57 -03:00
committed by GitHub
parent 2af6052307
commit 9f3b82eeb2
5 changed files with 72 additions and 18 deletions

View File

@ -950,6 +950,26 @@ class Plugin::Instance
DiscoursePluginRegistry.register_presence_channel_prefix([prefix, block], self)
end
# Register a ReviewableScore setting_name associated with a reason.
# We'll use this to build a site setting link and add it to the reason's translation.
#
# If your plugin has a reason translation looking like this:
#
# my_plugin_reason: "This is the reason this post was flagged. See %{link}."
#
# And you associate the reason with a setting:
#
# add_reviewable_score_link(:my_plugin_reason, 'a_plugin_setting')
#
# We'll generate the following link and attach it to the translation:
#
# <a href="/admin/site_settings/category/all_results?filter=a_plugin_setting">
# a plugin setting
# </a>
def add_reviewable_score_link(reason, setting_name)
DiscoursePluginRegistry.register_reviewable_score_link({ reason: reason.to_sym, setting: setting_name }, self)
end
protected
def self.js_path