mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 20:33:03 +08:00
The `AdminFilterControls` component isn't really admin specific, and I want to use it in more places. Renaming to `DFilterControls`. No backwards compat needed, it's only used in core + core plugins. Also add `customEmptyState` to `DFilterControls`, which allows caller to show a custom empty state for `DFilterControls` in a yield when the array of result items is empty, for cases where you might want to show e.g. a different message and CTA when the filter is empty. E.g. used in Kanban: <img width="1107" height="439" alt="image" src="https://github.com/user-attachments/assets/1466e4d9-ac4d-4c59-81e5-6e0e3e259c6f" />
67 lines
2 KiB
Ruby
Vendored
67 lines
2 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class AdminUpcomingChanges < PageObjects::Pages::Base
|
|
def visit
|
|
page.visit("/admin/config/upcoming-changes")
|
|
end
|
|
|
|
def change_item(setting_name)
|
|
PageObjects::Components::AdminUpcomingChangeItem.new(setting_name)
|
|
end
|
|
|
|
def has_change?(setting_name, description: nil)
|
|
description ||= SiteSettings::LabelFormatter.description(setting_name)
|
|
change_item(setting_name).exists?
|
|
change_item(setting_name).has_text?(description)
|
|
change_item(setting_name).has_text?(
|
|
SiteSettings::LabelFormatter.humanized_name(setting_name),
|
|
)
|
|
end
|
|
|
|
def has_no_change?(setting_name)
|
|
change_item(setting_name).does_not_exist?
|
|
end
|
|
|
|
def filter_controls
|
|
PageObjects::Components::DFilterControls.new(
|
|
".upcoming-changes",
|
|
has_multiple_dropdowns: true,
|
|
)
|
|
end
|
|
|
|
def has_enabled_for_success_toast?(
|
|
enabled_for,
|
|
translation_args: {},
|
|
locale: SiteSetting.default_locale
|
|
)
|
|
enabled_for_text =
|
|
if enabled_for == "specific_groups_with_group_names"
|
|
I18n.t(
|
|
"admin_js.admin.upcoming_changes.enabled_for_options.#{enabled_for}",
|
|
translation_args.merge(locale: locale),
|
|
).downcase
|
|
else
|
|
I18n.t(
|
|
"admin_js.admin.upcoming_changes.enabled_for_options.#{enabled_for}",
|
|
translation_args.merge(locale: locale),
|
|
).downcase
|
|
end
|
|
|
|
enabled_for_success_text =
|
|
I18n.t(
|
|
"admin_js.admin.upcoming_changes.change_enabled_for_success",
|
|
enabledFor: enabled_for_text,
|
|
locale: locale,
|
|
)
|
|
|
|
page.has_content?(enabled_for_success_text)
|
|
end
|
|
|
|
def has_disabled_success_toast?
|
|
page.has_content?(I18n.t("admin_js.admin.upcoming_changes.change_disabled"))
|
|
end
|
|
end
|
|
end
|
|
end
|