FIX: Do not show quote copy button to anon (#25471)

This was an oversight in 51016e56dd,
anon doesn't have any need to copy quotes, just as they have
no need to open the composer with a quote prefilled.
This commit is contained in:
Martin Brennan 2024-01-30 13:19:35 +10:00 committed by GitHub
parent 38eef3306f
commit 304a7f3e1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 15 deletions

View File

@ -260,7 +260,10 @@ export default class PostTextSelection extends Component {
} }
get canCopyQuote() { get canCopyQuote() {
return this.siteSettings.enable_quote_copy; return (
this.siteSettings.enable_quote_copy &&
this.currentUser?.get("user_option.enable_quoting")
);
} }
// on Desktop, shows the bar at the beginning of the selection // on Desktop, shows the bar at the beginning of the selection

View File

@ -8,6 +8,7 @@ describe "Post selection | Copy quote", type: :system do
fab!(:post) { Fabricate(:post, topic: topic, raw: "Hello world it's time for quoting!") } fab!(:post) { Fabricate(:post, topic: topic, raw: "Hello world it's time for quoting!") }
fab!(:current_user) { Fabricate(:admin) } fab!(:current_user) { Fabricate(:admin) }
context "when logged in" do
before do before do
sign_in(current_user) sign_in(current_user)
cdp.allow_clipboard cdp.allow_clipboard
@ -32,3 +33,13 @@ describe "Post selection | Copy quote", type: :system do
expect(page).not_to have_css(topic_page.copy_quote_button_selector) expect(page).not_to have_css(topic_page.copy_quote_button_selector)
end end
end end
context "when anon" do
it "does not show the copy quote button to anon users" do
topic_page.visit_topic(topic)
select_text_range("#{topic_page.post_by_number_selector(1)} .cooked p", 0, 10)
expect(page).not_to have_css(topic_page.copy_quote_button_selector)
end
end
end