mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-07 17:36:22 +08:00
To make things a bit clearer for admins, and to bury the option to enable changes only for specific groups a bit since we don't think most sites will do this, this commit changes the upcoming change toggle to an "Enabled for:" dropdown with the following options: * No one * Everyone * Staff only * Specific group(s) We automatically save the staff site setting group in the background if staff only is selected, and we only save specific groups (and toggle the change on) once more than one group is selected. --------- Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
48 lines
1.6 KiB
Ruby
48 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Components
|
|
# NOTE: GroupSelector is the only user of the DMultiSelect component at the moment.
|
|
# At some point, we might want to make a separate PageObject for DMultiSelect if
|
|
# more components start using it.
|
|
class GroupSelector < PageObjects::Components::Base
|
|
def initialize(context)
|
|
@context = context
|
|
end
|
|
|
|
def hidden?
|
|
find("#{@context}").has_no_css?(".group-selector")
|
|
end
|
|
|
|
def has_selected_groups?(*group_names)
|
|
selected_groups =
|
|
find("#{@context} .group-selector")
|
|
.all(".d-multi-select-trigger__selected-item")
|
|
.map { |item| item[:innerText] }
|
|
expect(selected_groups & group_names).to match_array(group_names)
|
|
end
|
|
|
|
def has_no_selected_groups?
|
|
find("#{@context} .group-selector").has_no_css?(".d-multi-select-trigger__selected-item")
|
|
end
|
|
|
|
def open
|
|
find(@context).find(".group-selector .d-multi-select-trigger__expand-btn").click
|
|
expect(page).to have_css(".fk-d-menu.d-multi-select-content")
|
|
end
|
|
|
|
def add_group(group_name)
|
|
self.open
|
|
find(".dropdown-menu__item.d-multi-select__search-container").fill_in(with: group_name)
|
|
find(".dropdown-menu__item.d-multi-select__result[title='#{group_name}']").click
|
|
end
|
|
|
|
def remove_group(group_name)
|
|
find(@context)
|
|
.find(".group-selector .d-multi-select-trigger__selected-item", text: group_name)
|
|
.find(".d-multi-select-trigger__remove-selection-icon")
|
|
.click
|
|
end
|
|
end
|
|
end
|
|
end
|