DEV: Switch edit nav menu tags/categories modal to component (#22401)

Why this change?

A new component based API for modals was introduced in
b3a23bd9d6. This commit moves the edit
navigation menu tags and categories modal to the new API.
This commit is contained in:
Alan Guo Xiang Tan 2023-07-04 09:45:21 +08:00 committed by GitHub
parent 2f5cb0a280
commit fe294ab1a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 172 additions and 184 deletions

View File

@ -1,4 +1,4 @@
<Sidebar::EditNavigationModalForm::Modal <Sidebar::EditNavigationMenu::Modal
@title="sidebar.categories_form_modal.title" @title="sidebar.categories_form_modal.title"
@disableSaveButton={{this.saving}} @disableSaveButton={{this.saving}}
@save={{this.save}} @save={{this.save}}
@ -15,6 +15,7 @@
@resetFilter={{this.resetFilter}} @resetFilter={{this.resetFilter}}
@filterSelected={{this.filterSelected}} @filterSelected={{this.filterSelected}}
@filterUnselected={{this.filterUnselected}} @filterUnselected={{this.filterUnselected}}
@closeModal={{@closeModal}}
> >
<form class="sidebar-categories-form"> <form class="sidebar-categories-form">
{{#if (gt this.filteredCategoriesGroupings.length 0)}} {{#if (gt this.filteredCategoriesGroupings.length 0)}}
@ -68,4 +69,4 @@
</div> </div>
{{/if}} {{/if}}
</form> </form>
</Sidebar::EditNavigationModalForm::Modal> </Sidebar::EditNavigationMenu::Modal>

View File

@ -0,0 +1,73 @@
<DModal
class="sidebar__edit-navigation-menu__modal"
@title={{i18n @title}}
@closeModal={{@closeModal}}
>
<:headerBelowTitle>
<p class="sidebar__edit-navigation-menu__deselect-wrapper">
<DButton
@class="btn-flat sidebar__edit-navigation-menu__deselect-button"
@label="sidebar.edit_navigation_modal_form.deselect_button_text"
@ariaLabel="sidebar.edit_navigation_modal_form.deselect_button_text"
@action={{@deselectAll}}
/>
{{@deselectAllText}}
</p>
</:headerBelowTitle>
<:belowHeader>
<div class="sidebar__edit-navigation-menu__filter">
<div class="sidebar__edit-navigation-menu__filter-input">
{{d-icon
"search"
class="sidebar__edit-navigation-menu__filter-input-icon"
}}
<Input
class="sidebar__edit-navigation-menu__filter-input-field"
placeholder={{@inputFilterPlaceholder}}
@type="text"
@value={{this.filter}}
{{on "input" (action @onFilterInput value="target.value")}}
autofocus="true"
/>
</div>
<div class="sidebar__edit-navigation-menu__filter-dropdown-wrapper">
<DropdownSelectBox
@class="sidebar__edit-navigation-menu__filter-dropdown"
@value={{this.filterDropdownValue}}
@content={{this.filterDropdownContent}}
@onChange={{this.onFilterDropdownChange}}
@options={{hash showCaret=true}}
/>
</div>
</div>
</:belowHeader>
<:body>
{{yield}}
</:body>
<:footer>
<div class="sidebar__edit-navigation-menu__footer">
<DButton
@class="btn-primary sidebar__edit-navigation-menu__save-button"
@label="save"
@disabled={{@saving}}
@action={{@save}}
/>
{{#if @showResetDefaultsButton}}
<DButton
@icon="undo"
@class="btn-flat btn-text sidebar__edit-navigation-menu__reset-defaults-button"
@label="sidebar.edit_navigation_modal_form.reset_to_defaults"
@disabled={{@saving}}
@action={{@resetToDefaults}}
/>
{{/if}}
</div>
</:footer>
</DModal>

View File

@ -26,10 +26,6 @@ export default class extends Component {
}, },
]; ];
get modalHeaderAfterTitleElement() {
return document.getElementById("modal-header-after-title");
}
@action @action
onFilterInput(value) { onFilterInput(value) {
this.args.onFilterInput(value); this.args.onFilterInput(value);

View File

@ -1,4 +1,4 @@
<Sidebar::EditNavigationModalForm::Modal <Sidebar::EditNavigationMenu::Modal
@title="sidebar.tags_form_modal.title" @title="sidebar.tags_form_modal.title"
@saving={{this.saving}} @saving={{this.saving}}
@save={{this.save}} @save={{this.save}}
@ -13,6 +13,7 @@
@resetFilter={{this.resetFilter}} @resetFilter={{this.resetFilter}}
@filterSelected={{this.filterSelected}} @filterSelected={{this.filterSelected}}
@filterUnselected={{this.filterUnselected}} @filterUnselected={{this.filterUnselected}}
@closeModal={{@closeModal}}
> >
<form class="sidebar-tags-form"> <form class="sidebar-tags-form">
{{#if this.tagsLoading}} {{#if this.tagsLoading}}
@ -52,4 +53,4 @@
{{/if}} {{/if}}
{{/if}} {{/if}}
</form> </form>
</Sidebar::EditNavigationModalForm::Modal> </Sidebar::EditNavigationMenu::Modal>

View File

@ -1,68 +0,0 @@
{{#in-element this.modalHeaderAfterTitleElement}}
<p class="sidebar__edit-navigation-modal-form__deselect-wrapper">
<DButton
@class="btn-flat sidebar__edit-navigation-modal-form__deselect-button"
@label="sidebar.edit_navigation_modal_form.deselect_button_text"
@ariaLabel="sidebar.edit_navigation_modal_form.deselect_button_text"
@action={{@deselectAll}}
/>
{{@deselectAllText}}
</p>
{{/in-element}}
<div class="sidebar__edit-navigation-modal-form__filter">
<div class="sidebar__edit-navigation-modal-form__filter-input">
{{d-icon
"search"
class="sidebar__edit-navigation-modal-form__filter-input-icon"
}}
<Input
class="sidebar__edit-navigation-modal-form__filter-input-field"
placeholder={{@inputFilterPlaceholder}}
@type="text"
@value={{this.filter}}
{{on "input" (action @onFilterInput value="target.value")}}
autofocus="true"
/>
</div>
<div class="sidebar__edit-navigation-modal-form__filter-dropdown-wrapper">
<DropdownSelectBox
@class="sidebar__edit-navigation-modal-form__filter-dropdown"
@value={{this.filterDropdownValue}}
@content={{this.filterDropdownContent}}
@onChange={{this.onFilterDropdownChange}}
@options={{hash showCaret=true}}
/>
</div>
</div>
<div class="sidebar__edit-navigation-modal-form">
<DModalBody
@title={{@title}}
@class="sidebar__edit-navigation-modal-form__body"
>
{{yield}}
</DModalBody>
</div>
<div class="modal-footer sidebar__edit-navigation-modal-form__footer">
<DButton
@class="btn-primary sidebar__edit-navigation-modal-form__save-button"
@label="save"
@disabled={{@saving}}
@action={{@save}}
/>
{{#if @showResetDefaultsButton}}
<DButton
@icon="undo"
@class="btn-flat btn-text sidebar__edit-navigation-modal-form__reset-defaults-button"
@label="sidebar.edit_navigation_modal_form.reset_to_defaults"
@disabled={{@saving}}
@action={{@resetToDefaults}}
/>
{{/if}}
</div>

View File

@ -3,7 +3,7 @@
@headerLinkText={{i18n "sidebar.sections.categories.header_link_text"}} @headerLinkText={{i18n "sidebar.sections.categories.header_link_text"}}
@headerActions={{array @headerActions={{array
(hash (hash
action=this.editTracked action=(fn (mut this.isModalVisible) true)
title=(i18n "sidebar.sections.categories.header_action_title") title=(i18n "sidebar.sections.categories.header_action_title")
) )
}} }}
@ -47,3 +47,9 @@
/> />
{{/if}} {{/if}}
</Sidebar::Section> </Sidebar::Section>
{{#if this.isModalVisible}}
<Sidebar::EditNavigationMenu::CategoriesModal
@closeModal={{fn (mut this.isModalVisible) false}}
/>
{{/if}}

View File

@ -1,20 +1,21 @@
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { action } from "@ember/object"; import { cached, tracked } from "@glimmer/tracking";
import { cached } from "@glimmer/tracking";
import { debounce } from "discourse-common/utils/decorators"; import { debounce } from "discourse-common/utils/decorators";
import Category from "discourse/models/category"; import Category from "discourse/models/category";
import SidebarCommonCategoriesSection from "discourse/components/sidebar/common/categories-section"; import SidebarCommonCategoriesSection from "discourse/components/sidebar/common/categories-section";
import showModal from "discourse/lib/show-modal";
import { hasDefaultSidebarCategories } from "discourse/lib/sidebar/helpers"; import { hasDefaultSidebarCategories } from "discourse/lib/sidebar/helpers";
export const REFRESH_COUNTS_APP_EVENT_NAME = export const REFRESH_COUNTS_APP_EVENT_NAME =
"sidebar:refresh-categories-section-counts"; "sidebar:refresh-categories-section-counts";
export default class SidebarUserCategoriesSection extends SidebarCommonCategoriesSection { export default class SidebarUserCategoriesSection extends SidebarCommonCategoriesSection {
@service router;
@service currentUser;
@service appEvents; @service appEvents;
@service currentUser;
@service modal;
@service router;
@tracked isModalVisible = false;
constructor() { constructor() {
super(...arguments); super(...arguments);
@ -63,9 +64,4 @@ export default class SidebarUserCategoriesSection extends SidebarCommonCategorie
get hasDefaultSidebarCategories() { get hasDefaultSidebarCategories() {
return hasDefaultSidebarCategories(this.siteSettings); return hasDefaultSidebarCategories(this.siteSettings);
} }
@action
editTracked() {
showModal("sidebar-categories-form");
}
} }

View File

@ -3,7 +3,7 @@
@headerLinkText={{i18n "sidebar.sections.tags.header_link_text"}} @headerLinkText={{i18n "sidebar.sections.tags.header_link_text"}}
@headerActions={{array @headerActions={{array
(hash (hash
action=this.editTracked action=(fn (mut this.isModalVisible) true)
title=(i18n "sidebar.sections.tags.header_action_title") title=(i18n "sidebar.sections.tags.header_action_title")
) )
}} }}
@ -45,3 +45,9 @@
/> />
{{/if}} {{/if}}
</Sidebar::Section> </Sidebar::Section>
{{#if this.isModalVisible}}
<Sidebar::EditNavigationMenu::TagsModal
@closeModal={{fn (mut this.isModalVisible) false}}
/>
{{/if}}

View File

@ -1,19 +1,20 @@
import { cached } from "@glimmer/tracking"; import { cached, tracked } from "@glimmer/tracking";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { action } from "@ember/object";
import SidebarCommonTagsSection from "discourse/components/sidebar/common/tags-section"; import SidebarCommonTagsSection from "discourse/components/sidebar/common/tags-section";
import TagSectionLink from "discourse/lib/sidebar/user/tags-section/tag-section-link"; import TagSectionLink from "discourse/lib/sidebar/user/tags-section/tag-section-link";
import PMTagSectionLink from "discourse/lib/sidebar/user/tags-section/pm-tag-section-link"; import PMTagSectionLink from "discourse/lib/sidebar/user/tags-section/pm-tag-section-link";
import { hasDefaultSidebarTags } from "discourse/lib/sidebar/helpers"; import { hasDefaultSidebarTags } from "discourse/lib/sidebar/helpers";
import showModal from "discourse/lib/show-modal";
export default class SidebarUserTagsSection extends SidebarCommonTagsSection { export default class SidebarUserTagsSection extends SidebarCommonTagsSection {
@service router;
@service topicTrackingState;
@service pmTopicTrackingState;
@service currentUser; @service currentUser;
@service modal;
@service pmTopicTrackingState;
@service router;
@service siteSettings; @service siteSettings;
@service topicTrackingState;
@tracked isModalVisible = false;
constructor() { constructor() {
super(...arguments); super(...arguments);
@ -77,9 +78,4 @@ export default class SidebarUserTagsSection extends SidebarCommonTagsSection {
get hasDefaultSidebarTags() { get hasDefaultSidebarTags() {
return hasDefaultSidebarTags(this.siteSettings); return hasDefaultSidebarTags(this.siteSettings);
} }
@action
editTracked() {
showModal("sidebar-tags-form");
}
} }

View File

@ -1,6 +0,0 @@
import Controller from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
export default class SidebarCategoriesForm extends Controller.extend(
ModalFunctionality
) {}

View File

@ -1,3 +0,0 @@
<Sidebar::EditNavigationModalForm::CategoriesForm
@closeModal={{(action "closeModal")}}
/>

View File

@ -139,7 +139,7 @@ acceptance("Sidebar - Logged on user - Categories Section", function (needs) {
); );
assert.true( assert.true(
exists(".sidebar-categories-form-modal"), exists(".sidebar-categories-form"),
"it shows the categories form modal" "it shows the categories form modal"
); );
}); });

View File

@ -111,10 +111,7 @@ acceptance("Sidebar - Logged on user - Tags section", function (needs) {
".sidebar-section[data-section-name='tags'] .sidebar-section-header-button" ".sidebar-section[data-section-name='tags'] .sidebar-section-header-button"
); );
assert.true( assert.true(exists(".sidebar-tags-form"), "it shows the tags form modal");
exists(".sidebar-tags-form-modal"),
"it shows the tags form modal"
);
}); });
test("tags section is displayed with site's top tags when user has not added any tags and there are no default tags configured", async function (assert) { test("tags section is displayed with site's top tags when user has not added any tags and there are no default tags configured", async function (assert) {

View File

@ -133,10 +133,10 @@
} }
} }
&:not(.history-modal) { &:not(.history-modal):not(.sidebar__edit-navigation-menu__modal) {
.modal-body:not(.reorder-categories):not(.poll-ui-builder):not( .modal-body:not(.reorder-categories):not(.poll-ui-builder):not(
.poll-breakdown .poll-breakdown
):not(.sidebar__edit-navigation-modal-form__body) { ) {
max-height: 80vh !important; max-height: 80vh !important;
@media screen and (max-height: 500px) { @media screen and (max-height: 500px) {
max-height: 65vh !important; max-height: 65vh !important;

View File

@ -28,9 +28,9 @@
@import "relative-time-picker"; @import "relative-time-picker";
@import "share-and-invite-modal"; @import "share-and-invite-modal";
@import "download-calendar"; @import "download-calendar";
@import "sidebar/edit-navigation-modal-form/categories-form"; @import "sidebar/edit-navigation-menu/categories-modal";
@import "sidebar/edit-navigation-modal-form/modal"; @import "sidebar/edit-navigation-menu/modal";
@import "sidebar/edit-navigation-modal-form/tags-form"; @import "sidebar/edit-navigation-menu/tags-modal";
@import "svg"; @import "svg";
@import "tap-tile"; @import "tap-tile";
@import "time-input"; @import "time-input";

View File

@ -1,15 +1,15 @@
.sidebar__edit-navigation-modal-form { .sidebar__edit-navigation-menu__modal {
.modal-body { .modal-body {
min-height: 50vh; min-height: 50vh;
} }
} }
.sidebar__edit-navigation-modal-form__filter { .sidebar__edit-navigation-menu__filter {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding: 1em 1em 0 1em; padding: 1em 1em 0 1em;
.sidebar__edit-navigation-modal-form__filter-dropdown { .sidebar__edit-navigation-menu__filter-dropdown {
margin-left: 0.5em; margin-left: 0.5em;
.select-kit-header { .select-kit-header {
@ -30,7 +30,7 @@
} }
} }
.sidebar__edit-navigation-modal-form__filter-input { .sidebar__edit-navigation-menu__filter-input {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
margin-right: auto; margin-right: auto;
@ -38,14 +38,14 @@
position: relative; position: relative;
} }
.sidebar__edit-navigation-modal-form__filter-input-icon { .sidebar__edit-navigation-menu__filter-input-icon {
position: absolute; position: absolute;
left: 0.5em; left: 0.5em;
top: 0.65em; top: 0.65em;
color: var(--primary-low-mid); color: var(--primary-low-mid);
} }
.sidebar__edit-navigation-modal-form__filter-input-field { .sidebar__edit-navigation-menu__filter-input-field {
border-color: var(--primary-low-mid); border-color: var(--primary-low-mid);
padding-left: 1.75em; padding-left: 1.75em;
width: 100%; width: 100%;
@ -59,8 +59,11 @@
} }
} }
.sidebar__edit-navigation-modal-form__footer { .sidebar__edit-navigation-menu__footer {
.btn.sidebar__edit-navigation-modal-form__reset-defaults-button { display: flex;
width: 100%;
.btn.sidebar__edit-navigation-menu__reset-defaults-button {
margin-left: auto; margin-left: auto;
margin-right: 0em; margin-right: 0em;
@ -76,10 +79,10 @@
} }
} }
.sidebar__edit-navigation-modal-form__deselect-wrapper { .sidebar__edit-navigation-menu__deselect-wrapper {
margin: 0; margin: 0;
.btn-flat.sidebar__edit-navigation-modal-form__deselect-button { .btn-flat.sidebar__edit-navigation-menu__deselect-button {
margin-left: auto; margin-left: auto;
padding: 0; padding: 0;

View File

@ -1,5 +1,5 @@
@import "sidebar/edit-navigation-modal-form/categories-form"; @import "sidebar/edit-navigation-menu/categories-modal";
@import "sidebar/edit-navigation-modal-form/tags-form"; @import "sidebar/edit-navigation-menu/tags-modal";
@import "user-card"; @import "user-card";
@import "user-info"; @import "user-info";
@import "user-stream-item"; @import "user-stream-item";

View File

@ -1,5 +1,5 @@
@import "sidebar/edit-navigation-modal-form/modal"; @import "sidebar/edit-navigation-menu/modal";
@import "sidebar/edit-navigation-modal-form/tags-form"; @import "sidebar/edit-navigation-menu/tags-modal";
@import "topic-footer-mobile-dropdown"; @import "topic-footer-mobile-dropdown";
@import "user-card"; @import "user-card";
@import "user-stream-item"; @import "user-stream-item";

View File

@ -0,0 +1,15 @@
.sidebar__edit-navigation-menu {
.modal-inner-container {
width: 35em;
}
}
.sidebar__edit-navigation-menu__filter {
flex-direction: column;
padding: 0.667em;
.sidebar__edit-navigation-menu__filter-dropdown {
margin-left: 0;
width: 100%;
}
}

View File

@ -1,15 +0,0 @@
.sidebar__edit-navigation-modal-form {
.modal-inner-container {
width: 35em;
}
}
.sidebar__edit-navigation-modal-form__filter {
flex-direction: column;
padding: 0.667em;
.sidebar__edit-navigation-modal-form__filter-dropdown {
margin-left: 0;
width: 100%;
}
}

View File

@ -5,32 +5,24 @@ require_relative "sidebar_edit_navigation_modal"
module PageObjects module PageObjects
module Modals module Modals
class SidebarEditCategories < SidebarEditNavigationModal class SidebarEditCategories < SidebarEditNavigationModal
def closed?
has_no_css?(".sidebar-categories-form-modal")
end
def has_right_title?(title)
has_css?(".sidebar-categories-form-modal #discourse-modal-title", text: title)
end
def has_parent_category_color?(category) def has_parent_category_color?(category)
has_css?( has_css?(
".sidebar-categories-form-modal .sidebar-categories-form__row", ".sidebar-categories-form .sidebar-categories-form__row",
style: "border-left-color: ##{category.color} ", style: "border-left-color: ##{category.color} ",
) )
end end
def has_category_description_excerpt?(category) def has_category_description_excerpt?(category)
has_css?( has_css?(
".sidebar-categories-form-modal .sidebar-categories-form__category-row", ".sidebar-categories-form .sidebar-categories-form__category-row",
text: category.description_excerpt, text: category.description_excerpt,
) )
end end
def has_no_categories? def has_no_categories?
has_no_css?(".sidebar-categories-form-modal .sidebar-categories-form__category-row") && has_no_css?(".sidebar-categories-form .sidebar-categories-form__category-row") &&
has_css?( has_css?(
".sidebar-categories-form-modal .sidebar-categories-form__no-categories", ".sidebar-categories-form .sidebar-categories-form__no-categories",
text: I18n.t("js.sidebar.categories_form_modal.no_categories"), text: I18n.t("js.sidebar.categories_form_modal.no_categories"),
) )
end end
@ -40,7 +32,7 @@ module PageObjects
categories = categories =
all( all(
".sidebar-categories-form-modal .sidebar-categories-form__category-row", ".sidebar-categories-form .sidebar-categories-form__category-row",
count: category_names.length, count: category_names.length,
) )
@ -49,13 +41,13 @@ module PageObjects
def has_checkbox?(category, disabled: false) def has_checkbox?(category, disabled: false)
has_selector?( has_selector?(
".sidebar-categories-form-modal .sidebar-categories-form__category-row[data-category-id='#{category.id}'] .sidebar-categories-form__input#{disabled ? "[disabled]" : ""}", ".sidebar-categories-form .sidebar-categories-form__category-row[data-category-id='#{category.id}'] .sidebar-categories-form__input#{disabled ? "[disabled]" : ""}",
) )
end end
def toggle_category_checkbox(category) def toggle_category_checkbox(category)
find( find(
".sidebar-categories-form-modal .sidebar-categories-form__category-row[data-category-id='#{category.id}'] .sidebar-categories-form__input", ".sidebar-categories-form .sidebar-categories-form__category-row[data-category-id='#{category.id}'] .sidebar-categories-form__input",
).click ).click
self self
@ -63,7 +55,7 @@ module PageObjects
def has_checkbox?(category, disabled: false) def has_checkbox?(category, disabled: false)
has_selector?( has_selector?(
".sidebar-categories-form-modal .sidebar-categories-form__category-row[data-category-id='#{category.id}'] .sidebar-categories-form__input#{disabled ? "[disabled]" : ""}", ".sidebar-categories-form .sidebar-categories-form__category-row[data-category-id='#{category.id}'] .sidebar-categories-form__input#{disabled ? "[disabled]" : ""}",
) )
end end
end end

View File

@ -3,13 +3,21 @@
module PageObjects module PageObjects
module Modals module Modals
class SidebarEditNavigationModal < PageObjects::Modals::Base class SidebarEditNavigationModal < PageObjects::Modals::Base
def closed?
has_no_css?(".sidebar__edit-navigation-menu__modal")
end
def has_right_title?(title)
has_css?(".sidebar__edit-navigation-menu__modal .title", text: title)
end
def has_focus_on_filter_input? def has_focus_on_filter_input?
evaluate_script("document.activeElement").native == evaluate_script("document.activeElement").native ==
find(".sidebar__edit-navigation-modal-form__filter-input-field").native find(".sidebar__edit-navigation-menu__filter-input-field").native
end end
def filter(text) def filter(text)
find(".sidebar__edit-navigation-modal-form__filter-input-field").fill_in(with: text) find(".sidebar__edit-navigation-menu__filter-input-field").fill_in(with: text)
self self
end end
@ -23,7 +31,7 @@ module PageObjects
end end
def save def save
find(".sidebar__edit-navigation-modal-form__save-button").click find(".sidebar__edit-navigation-menu__save-button").click
self self
end end
@ -59,9 +67,7 @@ module PageObjects
private private
def dropdown_filter def dropdown_filter
PageObjects::Components::SelectKit.new( PageObjects::Components::SelectKit.new(".sidebar__edit-navigation-menu__filter-dropdown")
".sidebar__edit-navigation-modal-form__filter-dropdown",
)
end end
end end
end end

View File

@ -5,34 +5,26 @@ require_relative "sidebar_edit_navigation_modal"
module PageObjects module PageObjects
module Modals module Modals
class SidebarEditTags < SidebarEditNavigationModal class SidebarEditTags < SidebarEditNavigationModal
def closed?
has_no_css?(".sidebar-tags-form-modal")
end
def has_right_title?(title)
has_css?(".sidebar-tags-form-modal #discourse-modal-title", text: title)
end
def has_tag_checkboxes?(tags) def has_tag_checkboxes?(tags)
tag_names = tags.map(&:name) tag_names = tags.map(&:name)
has_css?(".sidebar-tags-form-modal .sidebar-tags-form__tag", count: tag_names.length) && has_css?(".sidebar-tags-form .sidebar-tags-form__tag", count: tag_names.length) &&
all(".sidebar-tags-form-modal .sidebar-tags-form__tag").all? do |row| all(".sidebar-tags-form .sidebar-tags-form__tag").all? do |row|
tag_names.include?(row["data-tag-name"].to_s) tag_names.include?(row["data-tag-name"].to_s)
end end
end end
def has_no_tag_checkboxes? def has_no_tag_checkboxes?
has_no_css?(".sidebar-tags-form-modal .sidebar-tags-form__tag") && has_no_css?(".sidebar-tags-form .sidebar-tags-form__tag") &&
has_css?( has_css?(
".sidebar-tags-form-modal .sidebar-tags-form__no-tags", ".sidebar-tags-form .sidebar-tags-form__no-tags",
text: I18n.t("js.sidebar.tags_form_modal.no_tags"), text: I18n.t("js.sidebar.tags_form_modal.no_tags"),
) )
end end
def toggle_tag_checkbox(tag) def toggle_tag_checkbox(tag)
find( find(
".sidebar-tags-form-modal .sidebar-tags-form__tag[data-tag-name='#{tag.name}'] .sidebar-tags-form__input", ".sidebar-tags-form .sidebar-tags-form__tag[data-tag-name='#{tag.name}'] .sidebar-tags-form__input",
).click ).click
self self