UX: Add custom section button should not be shown to anon users (#21651)
This commit is contained in:
parent
96e3c5e102
commit
b183b997fb
|
@ -3,12 +3,14 @@
|
||||||
<div class="sidebar-footer-actions">
|
<div class="sidebar-footer-actions">
|
||||||
<PluginOutlet @name="sidebar-footer-actions" />
|
<PluginOutlet @name="sidebar-footer-actions" />
|
||||||
|
|
||||||
<DButton
|
{{#if this.currentUser}}
|
||||||
@icon="plus"
|
<DButton
|
||||||
@action={{action this.addSection}}
|
@icon="plus"
|
||||||
@class="btn-flat add-section"
|
@action={{action this.addSection}}
|
||||||
@title="sidebar.sections.custom.add"
|
@class="btn-flat add-section"
|
||||||
/>
|
@title="sidebar.sections.custom.add"
|
||||||
|
/>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
{{#if
|
{{#if
|
||||||
(or
|
(or
|
||||||
|
|
|
@ -7,9 +7,13 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||||
let(:sidebar) { PageObjects::Components::Sidebar.new }
|
let(:sidebar) { PageObjects::Components::Sidebar.new }
|
||||||
|
|
||||||
it "allows the user to create custom section" do
|
it "allows the user to create custom section" do
|
||||||
|
visit("/latest")
|
||||||
|
|
||||||
|
expect(sidebar).to have_no_add_section_button
|
||||||
|
|
||||||
sign_in user
|
sign_in user
|
||||||
visit("/latest")
|
visit("/latest")
|
||||||
sidebar.open_new_custom_section
|
sidebar.click_add_section_button
|
||||||
|
|
||||||
expect(section_modal).to be_visible
|
expect(section_modal).to be_visible
|
||||||
expect(section_modal).to have_disabled_save
|
expect(section_modal).to have_disabled_save
|
||||||
|
@ -29,7 +33,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||||
it "allows the user to create custom section with /my link" do
|
it "allows the user to create custom section with /my link" do
|
||||||
sign_in user
|
sign_in user
|
||||||
visit("/latest")
|
visit("/latest")
|
||||||
sidebar.open_new_custom_section
|
sidebar.click_add_section_button
|
||||||
|
|
||||||
expect(section_modal).to be_visible
|
expect(section_modal).to be_visible
|
||||||
expect(section_modal).to have_disabled_save
|
expect(section_modal).to have_disabled_save
|
||||||
|
@ -49,7 +53,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||||
it "allows the user to create custom section with external link" do
|
it "allows the user to create custom section with external link" do
|
||||||
sign_in user
|
sign_in user
|
||||||
visit("/latest")
|
visit("/latest")
|
||||||
sidebar.open_new_custom_section
|
sidebar.click_add_section_button
|
||||||
|
|
||||||
expect(section_modal).to be_visible
|
expect(section_modal).to be_visible
|
||||||
expect(section_modal).to have_disabled_save
|
expect(section_modal).to have_disabled_save
|
||||||
|
@ -167,7 +171,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||||
it "allows admin to create, edit and delete public section" do
|
it "allows admin to create, edit and delete public section" do
|
||||||
sign_in admin
|
sign_in admin
|
||||||
visit("/latest")
|
visit("/latest")
|
||||||
sidebar.open_new_custom_section
|
sidebar.click_add_section_button
|
||||||
|
|
||||||
section_modal.fill_name("Public section")
|
section_modal.fill_name("Public section")
|
||||||
section_modal.fill_link("Sidebar Tags", "/tags")
|
section_modal.fill_link("Sidebar Tags", "/tags")
|
||||||
|
@ -207,7 +211,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||||
it "validates custom section fields" do
|
it "validates custom section fields" do
|
||||||
sign_in user
|
sign_in user
|
||||||
visit("/latest")
|
visit("/latest")
|
||||||
sidebar.open_new_custom_section
|
sidebar.click_add_section_button
|
||||||
|
|
||||||
section_modal.fill_name("A" * (SidebarSection::MAX_TITLE_LENGTH + 1))
|
section_modal.fill_name("A" * (SidebarSection::MAX_TITLE_LENGTH + 1))
|
||||||
section_modal.fill_link("B" * (SidebarUrl::MAX_NAME_LENGTH + 1), "/wrong-url")
|
section_modal.fill_link("B" * (SidebarUrl::MAX_NAME_LENGTH + 1), "/wrong-url")
|
||||||
|
|
|
@ -15,8 +15,12 @@ module PageObjects
|
||||||
page.has_link?(category.name, class: "sidebar-section-link")
|
page.has_link?(category.name, class: "sidebar-section-link")
|
||||||
end
|
end
|
||||||
|
|
||||||
def open_new_custom_section
|
def click_add_section_button
|
||||||
find("button.add-section").click
|
click_button(add_section_button_text)
|
||||||
|
end
|
||||||
|
|
||||||
|
def has_no_add_section_button?
|
||||||
|
page.has_no_button?(add_section_button_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit_custom_section(name)
|
def edit_custom_section(name)
|
||||||
|
@ -68,6 +72,10 @@ module PageObjects
|
||||||
attributes[:class] += "--active" if active
|
attributes[:class] += "--active" if active
|
||||||
page.public_send(present ? :has_link? : :has_no_link?, name, **attributes)
|
page.public_send(present ? :has_link? : :has_no_link?, name, **attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_section_button_text
|
||||||
|
I18n.t("js.sidebar.sections.custom.add")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue