mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 02:33:45 +08:00
Previously, the theme picker modal had small blurry screenshots, only the "Use this theme" button was interactive (not the card), and changing themes showed a toast notification that appeared briefly before the page reloaded. This change makes the modal wider with taller image previews, lets users select a card first and then apply with a "Use selected theme" button (with an inline loading state replacing the toast), and skips the API call entirely when the already-active theme is reselected. https://github.com/user-attachments/assets/6496bbfa-bf4e-4c7a-9168-3b3e0039c3de
32 lines
852 B
Ruby
Vendored
32 lines
852 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Modals
|
|
class AdminOnboardingThemePicker < PageObjects::Modals::Base
|
|
MODAL_SELECTOR = ".theme-picker-modal"
|
|
CARD_SELECTOR = ".theme-picker-modal__card"
|
|
NAME_SELECTOR = ".theme-card-preview__name"
|
|
|
|
def open?
|
|
has_css?(MODAL_SELECTOR)
|
|
end
|
|
|
|
def has_theme_cards?(**options)
|
|
has_css?(CARD_SELECTOR, **options)
|
|
end
|
|
|
|
def first_selectable_theme_name
|
|
find("#{CARD_SELECTOR}:not(.--selected) #{NAME_SELECTOR}", match: :first).text
|
|
end
|
|
|
|
def select_theme(name)
|
|
find(CARD_SELECTOR, text: name).click
|
|
find(".theme-picker-modal__footer .btn-primary").click
|
|
end
|
|
|
|
def select_first_selectable_theme
|
|
first_selectable_theme_name.tap { |name| select_theme(name) }
|
|
end
|
|
end
|
|
end
|
|
end
|