Skip to content

Conversation

@AlexB52
Copy link

@AlexB52 AlexB52 commented Oct 9, 2025

Fixes #307

Based on the discussion on issue #307, this also works and could be enough?
Happy to provide a change for either approach

:where(lexxy-editor) {
  &[attachments="false"] button[name="upload"] {
    display: none;
  }
}

@AlexB52 AlexB52 marked this pull request as ready for review October 9, 2025 22:10
@AlexB52 AlexB52 force-pushed the hide-upload-button branch 2 times, most recently from 1d0b87e to 33f2c3e Compare October 9, 2025 22:30
Comment on lines 109 to 113
test "disable attachments" do
visit edit_post_path(posts(:empty), attachments_disabled: true)

assert_no_selector "lexxy-toolbar button[name=upload]"
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be worth testing that the button is still present when false or blank?

test "enable attachments" do
  visit edit_post_path(posts(:empty), attachments_disabled: [false, nil].sample)

  assert_no_selector "lexxy-toolbar button[name=upload]"
end

Copy link
Author

@AlexB52 AlexB52 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I've updated the tests.

Note: The form on the page edit_post_path(posts(:empty), attachments_disabled: true) also needed a change for the test to work. To some extent, we're more testing the query parameter than the actual attachments attribute with these new tests.

@kcamcam kcamcam mentioned this pull request Oct 17, 2025
@AlexB52 AlexB52 force-pushed the hide-upload-button branch from 33f2c3e to aeb835d Compare October 17, 2025 20:50
@AlexB52
Copy link
Author

AlexB52 commented Oct 17, 2025

I've rebased onto basecamp/lexxy/main to update the js builds to the latest version.

<%= form.label :body, style: "display: block" %>
<%= form.rich_text_area :body, placeholder: "Write something...",
attachments: params[:attachments_disabled] ? "false" : nil,
attachments: (params[:attachments_disabled] != "true"),
Copy link
Author

@AlexB52 AlexB52 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit annoying as this change now diverges from the other query parameter disabling option logic on L15: params[:toolbar_disabled] ? "false" : nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

attachments="false" do not hide the image button in toolbar

2 participants