mirror of
https://github.com/discourse/discourse.git
synced 2025-02-06 11:28:18 +00:00
01e36cbb47
A previous refactor has prevented errors to show correctly. The guilt of the issue is that we were not calling the error variable correctly in the templates. This commit also adds a spec for this case, and removes the need for `I18n.backend.store_translations` in specs so we don't have to write too much boilerplate each time we write a spec.
31 lines
1007 B
Ruby
31 lines
1007 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_/, "")
|
|
description_key = "discourse_automation.scriptables.#{id}.description"
|
|
doc_key = "discourse_automation.scriptables.#{id}.doc"
|
|
|
|
{
|
|
id: id,
|
|
name:
|
|
I18n.t(
|
|
"discourse_automation.scriptables.#{id}.title",
|
|
default: "Missing translation for discourse_automation.scriptables.#{id}.title",
|
|
),
|
|
description: I18n.exists?(description_key, :en) ? I18n.t(description_key) : nil,
|
|
doc: I18n.exists?(doc_key, :en) ? I18n.t(doc_key) : nil,
|
|
}
|
|
end
|
|
|
|
scriptables.sort_by! { |s| s[:name] }
|
|
render_json_dump(scriptables: scriptables)
|
|
end
|
|
end
|
|
end
|