mirror of
https://github.com/discourse/discourse.git
synced 2026-08-14 13:58:53 +08:00
Sometimes for upcoming changes we need to tell the admin about some settings that must be enabled for the change to take effect. Currently the only way to do this is with a note in the change description which is not ideal. This commit introduces a way to display the depends_on settings for the upcoming change in the admin upcoming changes page. The warning only shows if any of the settings are not enabled, if all dependencies are satisfied we do not show the warning to the admin. There is a link to each setting from the upcoming changes list to make it easy for the admin to enable the setting if needed. <img width="1280" height="720" alt="image" src="https://github.com/user-attachments/assets/724762a9-cc40-45b4-b080-d6ee87dc57ca" />
113 lines
2.9 KiB
Ruby
Vendored
113 lines
2.9 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Components
|
|
class AdminUpcomingChangeItem < PageObjects::Components::Base
|
|
def initialize(setting_name)
|
|
@setting_name = setting_name
|
|
end
|
|
|
|
def has_text?(text)
|
|
find_item(@setting_name).has_text?(text)
|
|
end
|
|
|
|
def find_item(setting_name)
|
|
page.find(change_item_selector(setting_name))
|
|
end
|
|
|
|
def exists?
|
|
page.has_css?(change_item_selector(@setting_name))
|
|
end
|
|
|
|
def does_not_exist?
|
|
page.has_no_css?(change_item_selector(@setting_name))
|
|
end
|
|
|
|
def change_item_selector(setting_name)
|
|
".upcoming-change-row[data-upcoming-change='#{setting_name}']"
|
|
end
|
|
|
|
def has_status?(status)
|
|
find_item(@setting_name).has_css?(".upcoming-change__badge.--status-#{status}")
|
|
end
|
|
|
|
def has_impact_role?(impact_type)
|
|
find_item(@setting_name).has_css?(".upcoming-change__badge.--impact-role-#{impact_type}")
|
|
end
|
|
|
|
def has_plugin_name?(plugin_name)
|
|
find_item(@setting_name).find(".upcoming-change__plugin").has_text?(plugin_name)
|
|
end
|
|
|
|
def has_permanent_soon_notice?
|
|
find_item(@setting_name).has_css?(".upcoming-change__status-notice")
|
|
end
|
|
|
|
def has_no_permanent_soon_notice?
|
|
find_item(@setting_name).has_no_css?(".upcoming-change__status-notice")
|
|
end
|
|
|
|
def has_depends_on_notice?(text)
|
|
find_item(@setting_name).has_css?(".upcoming-change__depends-on-notice", text: text)
|
|
end
|
|
|
|
def has_no_depends_on_notice?
|
|
find_item(@setting_name).has_no_css?(".upcoming-change__depends-on-notice")
|
|
end
|
|
|
|
def select_enabled_for(option)
|
|
enabled_for_dropdown.select(option)
|
|
end
|
|
|
|
def save_groups
|
|
find_item(@setting_name).find(".upcoming-change__save-groups").click
|
|
end
|
|
|
|
def enabled?
|
|
enabled_for != "no_one"
|
|
end
|
|
|
|
def disabled?
|
|
enabled_for == "no_one"
|
|
end
|
|
|
|
def enabled_for
|
|
enabled_for_dropdown.value
|
|
end
|
|
|
|
def enabled_for_dropdown
|
|
PageObjects::Components::DSelect.new(
|
|
"#{change_item_selector(@setting_name)} .upcoming-change__enabled-for",
|
|
)
|
|
end
|
|
|
|
def enabled_for_options
|
|
enabled_for_dropdown.select_element.all("option").map { |o| o["value"] }
|
|
end
|
|
|
|
def group_selector
|
|
PageObjects::Components::GroupSelector.new(change_item_selector(@setting_name))
|
|
end
|
|
|
|
def has_no_group_selector?
|
|
expect(group_selector).to be_hidden
|
|
end
|
|
|
|
def has_groups?(*group_names)
|
|
group_selector.has_selected_groups?(*group_names)
|
|
end
|
|
|
|
def has_no_groups?
|
|
group_selector.has_no_selected_groups?
|
|
end
|
|
|
|
def add_group(group_name)
|
|
group_selector.add_group(group_name)
|
|
end
|
|
|
|
def remove_group(group_name)
|
|
group_selector.remove_group(group_name)
|
|
end
|
|
end
|
|
end
|
|
end
|