mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 12:43:54 -06:00
b58f660cd2
For the admin plugin list we want to be able to link to a meta topic for plugins, but we have no standard way to do this at the moment. This adds support for meta_topic_id alongside other plugin metadata like authors, URL etc, that gets built into a Meta topic URL in the serializer.
88 lines
1.4 KiB
Ruby
88 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class AdminPluginSerializer < ApplicationSerializer
|
|
attributes :id,
|
|
:name,
|
|
:about,
|
|
:version,
|
|
:url,
|
|
:admin_route,
|
|
:enabled,
|
|
:enabled_setting,
|
|
:has_settings,
|
|
:is_official,
|
|
:commit_hash,
|
|
:commit_url,
|
|
:meta_url
|
|
|
|
def id
|
|
object.directory_name
|
|
end
|
|
|
|
def name
|
|
object.metadata.name
|
|
end
|
|
|
|
def about
|
|
object.metadata.about
|
|
end
|
|
|
|
def version
|
|
object.metadata.version
|
|
end
|
|
|
|
def url
|
|
object.metadata.url
|
|
end
|
|
|
|
def enabled
|
|
object.enabled?
|
|
end
|
|
|
|
def include_enabled_setting?
|
|
enabled_setting.present?
|
|
end
|
|
|
|
def enabled_setting
|
|
object.enabled_site_setting
|
|
end
|
|
|
|
def has_settings
|
|
SiteSetting.plugins.values.include?(id)
|
|
end
|
|
|
|
def include_url?
|
|
url.present?
|
|
end
|
|
|
|
def admin_route
|
|
route = object.admin_route
|
|
return unless route
|
|
|
|
ret = route.slice(:location, :label)
|
|
ret[:full_location] = "adminPlugins.#{ret[:location]}"
|
|
ret
|
|
end
|
|
|
|
def include_admin_route?
|
|
admin_route.present?
|
|
end
|
|
|
|
def is_official
|
|
Plugin::Metadata::OFFICIAL_PLUGINS.include?(object.name)
|
|
end
|
|
|
|
def commit_hash
|
|
object.commit_hash
|
|
end
|
|
|
|
def commit_url
|
|
object.commit_url
|
|
end
|
|
|
|
def meta_url
|
|
return if object.metadata.meta_topic_id.blank?
|
|
"https://meta.discourse.org/t/#{object.metadata.meta_topic_id}"
|
|
end
|
|
end
|