Files
discourse/app/controllers/admin/search_controller.rb
Martin Brennan 38920724a0 DEV: Refactor reports index into service (#31667)
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.
2025-03-11 14:36:06 +10:00

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