2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-02-07 06:32:59 +08:00
|
|
|
class AdminPluginSerializer < ApplicationSerializer
|
2015-02-11 01:14:23 +08:00
|
|
|
attributes :id,
|
|
|
|
:name,
|
2015-02-07 06:32:59 +08:00
|
|
|
:version,
|
2015-02-07 07:08:57 +08:00
|
|
|
:url,
|
2015-07-03 00:45:17 +08:00
|
|
|
:admin_route,
|
|
|
|
:enabled,
|
2018-04-06 10:54:58 +08:00
|
|
|
:enabled_setting,
|
2018-05-08 10:30:33 +08:00
|
|
|
:is_official,
|
|
|
|
:enabled_setting_filter
|
2015-02-07 06:32:59 +08:00
|
|
|
|
2015-02-11 01:14:23 +08:00
|
|
|
def id
|
|
|
|
object.metadata.name
|
|
|
|
end
|
|
|
|
|
2015-02-07 06:32:59 +08:00
|
|
|
def name
|
|
|
|
object.metadata.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def version
|
|
|
|
object.metadata.version
|
|
|
|
end
|
|
|
|
|
2015-02-07 07:08:57 +08:00
|
|
|
def url
|
|
|
|
object.metadata.url
|
|
|
|
end
|
|
|
|
|
2015-07-03 00:45:17 +08:00
|
|
|
def enabled
|
|
|
|
object.enabled?
|
|
|
|
end
|
|
|
|
|
2018-05-08 10:30:33 +08:00
|
|
|
def include_enabled_setting?
|
2018-05-16 14:26:03 +08:00
|
|
|
enabled_setting.present?
|
2015-07-03 00:45:17 +08:00
|
|
|
end
|
|
|
|
|
2018-05-08 10:30:33 +08:00
|
|
|
def enabled_setting
|
2018-05-16 14:26:03 +08:00
|
|
|
object.enabled_site_setting
|
2018-05-08 10:30:33 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def include_enabled_setting_filter?
|
|
|
|
object.enabled_site_setting_filter.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def enabled_setting_filter
|
|
|
|
object.enabled_site_setting_filter
|
2015-07-03 00:45:17 +08:00
|
|
|
end
|
|
|
|
|
2015-02-07 07:08:57 +08:00
|
|
|
def include_url?
|
|
|
|
url.present?
|
|
|
|
end
|
|
|
|
|
2015-02-07 06:32:59 +08:00
|
|
|
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
|
2018-04-06 10:54:58 +08:00
|
|
|
|
|
|
|
def is_official
|
|
|
|
Plugin::Metadata::OFFICIAL_PLUGINS.include?(object.name)
|
|
|
|
end
|
2015-02-07 06:32:59 +08:00
|
|
|
end
|