discourse/plugins/automation/app/controllers/discourse_automation/admin_scriptables_controlle...

24 lines
738 B
Ruby

# frozen_string_literal: true
module DiscourseAutomation
class AdminScriptablesController < ::Admin::AdminController
requires_plugin DiscourseAutomation::PLUGIN_NAME
def index
scriptables =
DiscourseAutomation::Scriptable.all.map do |s|
id = s.to_s.gsub(/^__scriptable_/, "")
{
id: id,
name: I18n.t("discourse_automation.scriptables.#{id}.title"),
description: I18n.t("discourse_automation.scriptables.#{id}.description", default: ""),
doc: I18n.t("discourse_automation.scriptables.#{id}.doc", default: ""),
}
end
scriptables.sort_by! { |s| s[:name] }
render_json_dump(scriptables: scriptables)
end
end
end