UX: Add custom section button should not be shown to anon users (#21651)

This commit is contained in:
Alan Guo Xiang Tan 2023-05-19 10:31:25 +09:00 committed by GitHub
parent 96e3c5e102
commit b183b997fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 13 deletions

View File

@ -3,12 +3,14 @@
<div class="sidebar-footer-actions">
<PluginOutlet @name="sidebar-footer-actions" />
<DButton
@icon="plus"
@action={{action this.addSection}}
@class="btn-flat add-section"
@title="sidebar.sections.custom.add"
/>
{{#if this.currentUser}}
<DButton
@icon="plus"
@action={{action this.addSection}}
@class="btn-flat add-section"
@title="sidebar.sections.custom.add"
/>
{{/if}}
{{#if
(or

View File

@ -7,9 +7,13 @@ describe "Custom sidebar sections", type: :system, js: true do
let(:sidebar) { PageObjects::Components::Sidebar.new }
it "allows the user to create custom section" do
visit("/latest")
expect(sidebar).to have_no_add_section_button
sign_in user
visit("/latest")
sidebar.open_new_custom_section
sidebar.click_add_section_button
expect(section_modal).to be_visible
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
sign_in user
visit("/latest")
sidebar.open_new_custom_section
sidebar.click_add_section_button
expect(section_modal).to be_visible
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
sign_in user
visit("/latest")
sidebar.open_new_custom_section
sidebar.click_add_section_button
expect(section_modal).to be_visible
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
sign_in admin
visit("/latest")
sidebar.open_new_custom_section
sidebar.click_add_section_button
section_modal.fill_name("Public section")
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
sign_in user
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_link("B" * (SidebarUrl::MAX_NAME_LENGTH + 1), "/wrong-url")

View File

@ -15,8 +15,12 @@ module PageObjects
page.has_link?(category.name, class: "sidebar-section-link")
end
def open_new_custom_section
find("button.add-section").click
def click_add_section_button
click_button(add_section_button_text)
end
def has_no_add_section_button?
page.has_no_button?(add_section_button_text)
end
def edit_custom_section(name)
@ -68,6 +72,10 @@ module PageObjects
attributes[:class] += "--active" if active
page.public_send(present ? :has_link? : :has_no_link?, name, **attributes)
end
def add_section_button_text
I18n.t("js.sidebar.sections.custom.add")
end
end
end
end