mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-06 03:39:06 +08:00
We have a "Staff" option for upcoming change items that was sending the `staff` group name to the server. I had assumed that our automatic groups could not be renamed, but this is not the case. If your `default_locale` for your site is changed, the automatic group names change via `Group.refresh_automatic_groups!` in a background job. This means that if you change your `default_locale` to `de` (German), the `staff` group becomes `Team`, and the upcoming changes that are set to "Staff" will now be looking for the `staff` group, which no longer exists, causing errors. This commit fixes the issue by always using the localized staff automatic group name, both for the value of the dropdown, and in successs messsages etc. c.f. https://meta.discourse.org/t/issue-with-enabling-upcoming-changes/395881/16 --------- Co-authored-by: Régis Hanol <regis@hanol.fr>
67 lines
2 KiB
Ruby
67 lines
2 KiB
Ruby
# 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::AdminFilterControls.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
|