2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-02-06 16:32:59 -06:00
|
|
|
class AdminPluginSerializer < ApplicationSerializer
|
2015-02-10 11:14:23 -06:00
|
|
|
attributes :id,
|
|
|
|
:name,
|
2021-02-12 10:19:07 -06:00
|
|
|
:about,
|
2015-02-06 16:32:59 -06:00
|
|
|
:version,
|
2015-02-06 17:08:57 -06:00
|
|
|
:url,
|
2015-07-02 11:45:17 -05:00
|
|
|
:admin_route,
|
|
|
|
:enabled,
|
2018-04-05 21:54:58 -05:00
|
|
|
:enabled_setting,
|
2020-05-12 03:18:19 -05:00
|
|
|
:has_settings,
|
2023-06-25 23:39:57 -05:00
|
|
|
:is_official,
|
2023-11-20 17:37:11 -06:00
|
|
|
:is_discourse_owned,
|
2023-11-29 18:53:17 -06:00
|
|
|
:label,
|
2023-06-25 23:39:57 -05:00
|
|
|
:commit_hash,
|
2023-10-09 19:16:13 -05:00
|
|
|
:commit_url,
|
2023-11-20 17:37:11 -06:00
|
|
|
:meta_url,
|
2024-03-12 22:15:12 -05:00
|
|
|
:authors,
|
|
|
|
:admin_config_nav_routes
|
|
|
|
|
|
|
|
def admin_config_nav_routes
|
|
|
|
object.admin_config_nav_routes
|
|
|
|
end
|
2015-02-06 16:32:59 -06:00
|
|
|
|
2015-02-10 11:14:23 -06:00
|
|
|
def id
|
2020-05-10 06:07:45 -05:00
|
|
|
object.directory_name
|
2015-02-10 11:14:23 -06:00
|
|
|
end
|
|
|
|
|
2015-02-06 16:32:59 -06:00
|
|
|
def name
|
|
|
|
object.metadata.name
|
|
|
|
end
|
|
|
|
|
2021-02-12 10:19:07 -06:00
|
|
|
def about
|
|
|
|
object.metadata.about
|
|
|
|
end
|
|
|
|
|
2015-02-06 16:32:59 -06:00
|
|
|
def version
|
|
|
|
object.metadata.version
|
|
|
|
end
|
|
|
|
|
2015-02-06 17:08:57 -06:00
|
|
|
def url
|
|
|
|
object.metadata.url
|
|
|
|
end
|
|
|
|
|
2023-11-20 17:37:11 -06:00
|
|
|
def authors
|
|
|
|
object.metadata.authors
|
|
|
|
end
|
|
|
|
|
2015-07-02 11:45:17 -05:00
|
|
|
def enabled
|
|
|
|
object.enabled?
|
|
|
|
end
|
|
|
|
|
2018-05-07 21:30:33 -05:00
|
|
|
def include_enabled_setting?
|
2018-05-16 01:26:03 -05:00
|
|
|
enabled_setting.present?
|
2015-07-02 11:45:17 -05:00
|
|
|
end
|
|
|
|
|
2018-05-07 21:30:33 -05:00
|
|
|
def enabled_setting
|
2018-05-16 01:26:03 -05:00
|
|
|
object.enabled_site_setting
|
2018-05-07 21:30:33 -05:00
|
|
|
end
|
|
|
|
|
2020-05-12 03:18:19 -05:00
|
|
|
def has_settings
|
|
|
|
SiteSetting.plugins.values.include?(id)
|
|
|
|
end
|
|
|
|
|
2015-02-06 17:08:57 -06:00
|
|
|
def include_url?
|
|
|
|
url.present?
|
|
|
|
end
|
|
|
|
|
2015-02-06 16:32:59 -06:00
|
|
|
def admin_route
|
|
|
|
route = object.admin_route
|
|
|
|
return unless route
|
|
|
|
|
|
|
|
ret = route.slice(:location, :label)
|
2024-03-12 22:15:12 -05:00
|
|
|
if route[:use_new_show_route]
|
|
|
|
ret[:full_location] = "adminPlugins.show.#{ret[:location]}"
|
|
|
|
ret[:use_new_show_route] = true
|
|
|
|
else
|
|
|
|
ret[:full_location] = "adminPlugins.#{ret[:location]}"
|
|
|
|
end
|
2015-02-06 16:32:59 -06:00
|
|
|
ret
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_admin_route?
|
|
|
|
admin_route.present?
|
|
|
|
end
|
2018-04-05 21:54:58 -05:00
|
|
|
|
|
|
|
def is_official
|
|
|
|
Plugin::Metadata::OFFICIAL_PLUGINS.include?(object.name)
|
|
|
|
end
|
2023-06-25 23:39:57 -05:00
|
|
|
|
2023-11-29 18:53:17 -06:00
|
|
|
def include_label?
|
|
|
|
is_discourse_owned
|
|
|
|
end
|
|
|
|
|
|
|
|
def label
|
|
|
|
return if !is_discourse_owned
|
|
|
|
object.metadata.label
|
2023-11-20 17:37:11 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def is_discourse_owned
|
|
|
|
object.discourse_owned?
|
|
|
|
end
|
|
|
|
|
2023-06-25 23:39:57 -05:00
|
|
|
def commit_hash
|
|
|
|
object.commit_hash
|
|
|
|
end
|
|
|
|
|
|
|
|
def commit_url
|
|
|
|
object.commit_url
|
|
|
|
end
|
2023-10-09 19:16:13 -05:00
|
|
|
|
|
|
|
def meta_url
|
|
|
|
return if object.metadata.meta_topic_id.blank?
|
|
|
|
"https://meta.discourse.org/t/#{object.metadata.meta_topic_id}"
|
|
|
|
end
|
2015-02-06 16:32:59 -06:00
|
|
|
end
|