2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-08-20 18:52:44 +08:00

FIX: Improve automation on/off toggle (#33482)

This commit replaces the "enabled" checkbox on the automation page with a
toggle at the top of the automation page. We've made this change to make
the automation edit page consistent with the automations list page where
a toggle is used for turning on/off automations, and also consistent
with the rest of admin pages where we've been using toggle for
controlling the enable/disable state.

Internal topic: t/153523.
This commit is contained in:
Osama Sayegh 2025-08-14 10:16:20 +03:00 committed by GitHub
parent 5dfa0f3cb6
commit 91e33664ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 522 additions and 51 deletions

View file

@ -137,6 +137,31 @@ module DiscourseAutomation
fields.map { |f| f[:component] }.uniq
end
def missing_required_fields
if automation.blank?
raise RuntimeError.new("`missing_required_fields` cannot be called without `@automation`")
end
required = Set.new
fields.each do |field|
next if !field[:required]
required << field[:name].to_s
end
return [] if required.empty?
automation
.fields
.where(target: "script", name: required)
.pluck(:name, :metadata)
.each do |name, metadata|
required.delete(name) if metadata.present? && metadata["value"].present?
end
required.to_a
end
def utils
Utils
end