discourse/lib/seed_data/admin_dashboard_sections.rb
Natalie Tay 8d43a7c5d7
DEV: Persist dashboard configuration in table and *not* on closure of the dialog (#40546)
The configuration used to be saved as a pipe-separated value in site
settings, with only the enabled ones. This meant there would be no order
kept if something is disabled as they were simply omitted from the site
setting.

This commit moves us to a DB table to save the settings so order can be
kept. Also, the change is committed immediately now instead of on
closure of the modal. It is also smart about not refreshing when
toggling "off" or rearranging.
2026-06-04 10:53:59 +08:00

14 lines
432 B
Ruby
Vendored

# frozen_string_literal: true
module SeedData
class AdminDashboardSections
def self.create
AdminDashboardSectionConfiguration::KNOWN_SECTIONS.each do |section_id|
next if AdminDashboardSection.exists?(section_id:)
next_position = (AdminDashboardSection.maximum(:position) || -1) + 1
AdminDashboardSection.create!(section_id:, position: next_position, visible: true)
end
end
end
end