A platform for community discussion. Free, open, simple.
FIX: show nested reply login prompt to anonymous users (#40906)
Mark VanLandingham472f7dfae7d8
diff --git a/frontend/discourse/app/components/nested/floating-actions.gjs b/frontend/discourse/app/components/nested/floating-actions.gjsindex 142c91888cd..71c7e85f009 100644--- a/frontend/discourse/app/components/nested/floating-actions.gjs+++ b/frontend/discourse/app/components/nested/floating-actions.gjs@@ -1,4 +1,5 @@import Component from "@glimmer/component";+import { action } from "@ember/object";import { getOwner } from "@ember/owner";import { service } from "@ember/service";import PluginOutlet from "discourse/components/plugin-outlet";@@ -17,7 +18,20 @@ export default class NestedFloatingActions extends Component {topicRoute = getOwner(this).lookup("route:topic");get canCreatePost() {- return this.currentUser && this.args.topic?.details?.can_create_post;+ return this.args.topic?.details?.can_create_post;+ }++ get showReplyButton() {+ return !this.currentUser || this.canCreatePost;+ }++ @action+ reply() {+ if (!this.currentUser) {+ return getOwner(this).lookup("route:application").send("showLogin");+ }++ return this.args.replyAction?.();}<template>@@ -53,10 +67,10 @@ export default class NestedFloatingActions extends Component {@showChangeTimestamp={{this.topicRoute.showChangeTimestamp}}/>- {{#if this.canCreatePost}}+ {{#if this.showReplyButton}}<DButtonclass="btn-primary nested-view__floating-reply"- @action={{@replyAction}}+ @action={{this.reply}}@icon="reply"@label="topic.reply.title"title={{i18n "topic.reply.help"}}diff --git a/spec/system/nested_floating_actions_spec.rb b/spec/system/nested_floating_actions_spec.rbindex 076b46a4c18..60d0ecc4dc2 100644--- a/spec/system/nested_floating_actions_spec.rb+++ b/spec/system/nested_floating_actions_spec.rb@@ -73,10 +73,10 @@ RSpec.describe "Nested view floating actions" doenddescribe "as anonymous user" do- it "does not show notification button or reply button" do+ it "does not show notification button but does show login reply button" donested_view.visit_nested(topic)expect(nested_view).to have_no_notification_button- expect(nested_view).to have_no_floating_reply_button+ expect(nested_view).to have_floating_reply_buttonendenddiff --git a/spec/system/nested_replying_spec.rb b/spec/system/nested_replying_spec.rbindex 6107b065901..98e35552756 100644--- a/spec/system/nested_replying_spec.rb+++ b/spec/system/nested_replying_spec.rb@@ -58,10 +58,15 @@ RSpec.describe "Nested view replying" doexpect(nested_view).to have_floating_reply_buttonend- it "is not visible for anonymous users" do+ it "is visible for anonymous users and opens the login flow" doCapybara.reset_sessions!nested_view.visit_nested(topic)- expect(nested_view).to have_no_floating_reply_button++ expect(nested_view).to have_floating_reply_button++ nested_view.click_floating_reply_button++ expect(page).to have_css("#login-account-name")endit "opens the composer for a top-level reply" dodiff --git a/spec/system/nested_view_spec.rb b/spec/system/nested_view_spec.rbindex fe2339f54b4..35634b57417 100644--- a/spec/system/nested_view_spec.rb+++ b/spec/system/nested_view_spec.rb@@ -549,12 +549,12 @@ RSpec.describe "Nested view" doexpect(nested_view).to have_op_postend- it "does not show reply buttons for anonymous users" do+ it "shows login reply only in floating actions for anonymous users" donested_view.visit_nested(topic)expect(nested_view).to have_no_reply_button_for(root_reply)expect(nested_view).to have_no_reply_button_on_op- expect(nested_view).to have_no_floating_reply_button+ expect(nested_view).to have_floating_reply_buttonendit "shows login page when anonymous user clicks like" do