mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: replaces topic-notifications-options by DMenu (#30298)
This commit introduces <NotificationsTracking /> which is a wrapper component around <DMenu /> which replaces the select-kit component <TopicNotificationsButton />. Each tracking case has its dedicated component: - topic -> `<TopicNotificationsTracking />` - group -> `<GroupNotificationsTracking />` - tag -> `<TagNotificationsTracking />` - category -> `<CategoryNotificationsTracking />` - chat thread -> `<ThreadNotificationsTracking />`
This commit is contained in:
@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Components
|
||||
class NotificationsTracking < PageObjects::Components::Base
|
||||
attr_reader :context
|
||||
|
||||
def initialize(context)
|
||||
@context = context
|
||||
end
|
||||
|
||||
def toggle
|
||||
trigger.click
|
||||
self
|
||||
end
|
||||
|
||||
def select_level_id(id)
|
||||
content.find("[data-level-id='#{id}']").click
|
||||
self
|
||||
end
|
||||
|
||||
def select_level_name(name)
|
||||
content.find("[data-level-name='#{name}']").click
|
||||
self
|
||||
end
|
||||
|
||||
def has_selected_level_name?(name)
|
||||
find("[data-trigger][data-identifier='#{identifier}'][data-level-name='#{name}']")
|
||||
end
|
||||
|
||||
def has_selected_level_id?(id)
|
||||
find("[data-trigger][data-identifier='#{identifier}'][data-level-id='#{id}']")
|
||||
end
|
||||
|
||||
def trigger
|
||||
if @context.is_a?(Capybara::Node::Element)
|
||||
@context
|
||||
else
|
||||
find(@context)
|
||||
end
|
||||
end
|
||||
|
||||
def content
|
||||
find("[data-content][data-identifier='#{identifier}']")
|
||||
end
|
||||
|
||||
def identifier
|
||||
trigger["data-identifier"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user