mirror of
https://github.com/discourse/discourse.git
synced 2025-06-21 10:31:51 +08:00

This list of all reports is needed in the admin search controller as well, so this commit refactors it into a service, adds specs, and also updates the admin search code to use this new service & avoid a second AJAX call to the server.
29 lines
881 B
Ruby
29 lines
881 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Admin::SearchController < Admin::AdminController
|
|
RESULT_TYPES = %w[page setting theme component report].freeze
|
|
|
|
def index
|
|
respond_to do |format|
|
|
format.json do
|
|
render_json_dump(
|
|
settings:
|
|
SiteSetting.all_settings(
|
|
filter_names: params[:filter_names],
|
|
filter_area: params[:filter_area],
|
|
filter_plugin: params[:plugin],
|
|
filter_categories: Array.wrap(params[:categories]),
|
|
include_locale_setting: params[:filter_area] == "localization",
|
|
basic_attributes: true,
|
|
),
|
|
themes_and_components:
|
|
serialize_data(Theme.include_relations.order(:name), BasicThemeSerializer),
|
|
reports: Reports::ListQuery.call,
|
|
)
|
|
end
|
|
|
|
format.html { render body: nil }
|
|
end
|
|
end
|
|
end
|