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