Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Render topic actions for nested replies (#40372)

Mark VanLandingham8ee812449003
diff --git a/app/assets/stylesheets/common/nested-view.scss b/app/assets/stylesheets/common/nested-view.scss
index 515319ff6b9..3856c55519c 100644
--- a/app/assets/stylesheets/common/nested-view.scss
+++ b/app/assets/stylesheets/common/nested-view.scss
@@ -103,6 +103,25 @@
}
}
+ &__op > &__topic-map {
+ margin: 0.75em 0 0;
+ padding: 0.75em 0 0;
+ border-top: 1px solid var(--primary-low);
+ }
+
+ #topic-footer-buttons.nested-view__topic-actions {
+ flex-flow: row wrap;
+ align-items: center;
+ gap: 0.5em;
+ max-width: none;
+ margin-bottom: 0.75em;
+
+ .topic-footer-main-buttons {
+ flex-wrap: wrap;
+ justify-content: flex-start;
+ }
+ }
+
&__controls {
display: flex;
align-items: center;
@@ -114,7 +133,7 @@
&:not(.nested-context-view) > &__controls {
position: sticky;
top: var(--header-offset, 0);
- z-index: z("header") - 3;
+ z-index: z("timeline");
padding: 0.25em 0;
background: var(--secondary);
border-bottom: 1px solid var(--primary-low);
diff --git a/frontend/discourse/app/components/nested.gjs b/frontend/discourse/app/components/nested.gjs
index 87080c16598..723f7410d70 100644
--- a/frontend/discourse/app/components/nested.gjs
+++ b/frontend/discourse/app/components/nested.gjs
@@ -8,7 +8,6 @@ import { service } from "@ember/service";
import MoreTopics from "discourse/components/more-topics";
import PluginOutlet from "discourse/components/plugin-outlet";
import PostAvatar from "discourse/components/post/avatar";
-import TopicMap from "discourse/components/topic-map";
import lazyHash from "discourse/helpers/lazy-hash";
import PostStreamViewportTracker from "discourse/modifiers/post-stream-viewport-tracker";
import { and, gt, includes, not } from "discourse/truth-helpers";
@@ -22,6 +21,7 @@ import NestedHeader from "./nested/header";
import NestedOp from "./nested/op";
import NestedPost from "./nested/post";
import NestedSortSelector from "./nested/sort-selector";
+import NestedTopicActions from "./nested/topic-actions";
const postExcerpt = helper(([post]) => {
const element = document.createElement("div");
@@ -32,6 +32,7 @@ const postExcerpt = helper(([post]) => {
export default class Nested extends Component {
@service appEvents;
+ @service currentUser;
@service header;
@service screenTrack;
@service site;
@@ -304,13 +305,9 @@ export default class Nested extends Component {
@registerPost={{this.viewportTracker.registerPost}}
/>
- <div class="nested-view__topic-map topic-map">
- <TopicMap
- @model={{@topic}}
- @topicDetails={{@topic.details}}
- @showPMMap={{@topic.isPrivateMessage}}
- />
- </div>
+ {{#if this.currentUser}}
+ <NestedTopicActions @topic={{@topic}} />
+ {{/if}}
<div class="nested-view__controls">
<div class="nested-view__controls-left">
diff --git a/frontend/discourse/app/components/nested/op.gjs b/frontend/discourse/app/components/nested/op.gjs
index 9e6873f8454..8d1dbf87b82 100644
--- a/frontend/discourse/app/components/nested/op.gjs
+++ b/frontend/discourse/app/components/nested/op.gjs
@@ -10,6 +10,7 @@ import PostCookedHtml from "discourse/components/post/cooked-html";
import PostLinks from "discourse/components/post/links";
import PostMenu from "discourse/components/post/menu";
import PostMetaData from "discourse/components/post/meta-data";
+import TopicMap from "discourse/components/topic-map";
import lazyHash from "discourse/helpers/lazy-hash";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { isTesting } from "discourse/lib/environment";
@@ -169,6 +170,14 @@ export default class NestedOp extends Component {
</article>
</PluginOutlet>
{{/let}}
+
+ <div class="nested-view__topic-map topic-map">
+ <TopicMap
+ @model={{@topic}}
+ @topicDetails={{@topic.details}}
+ @showPMMap={{@topic.isPrivateMessage}}
+ />
+ </div>
</div>
{{/if}}
</template>
diff --git a/frontend/discourse/app/components/nested/topic-actions.gjs b/frontend/discourse/app/components/nested/topic-actions.gjs
new file mode 100644
index 00000000000..60cdeea592b
--- /dev/null
+++ b/frontend/discourse/app/components/nested/topic-actions.gjs
@@ -0,0 +1,36 @@
+import Component from "@glimmer/component";
+import { getOwner } from "@ember/owner";
+import TopicFooterButtons from "discourse/components/topic-footer-buttons";
+
+export default class NestedTopicActions extends Component {
+ topicController = getOwner(this).lookup("controller:topic");
+ topicRoute = getOwner(this).lookup("route:topic");
+
+ <template>
+ <TopicFooterButtons
+ @topic={{@topic}}
+ @toggleMultiSelect={{this.topicController.toggleMultiSelect}}
+ @showTopicSlowModeUpdate={{this.topicRoute.showTopicSlowModeUpdate}}
+ @deleteTopic={{this.topicController.deleteTopic}}
+ @recoverTopic={{this.topicController.recoverTopic}}
+ @toggleClosed={{this.topicController.toggleClosed}}
+ @toggleArchived={{this.topicController.toggleArchived}}
+ @toggleVisibility={{this.topicController.toggleVisibility}}
+ @showTopicTimerModal={{this.topicRoute.showTopicTimerModal}}
+ @showFeatureTopic={{this.topicRoute.showFeatureTopic}}
+ @showChangeTimestamp={{this.topicRoute.showChangeTimestamp}}
+ @resetBumpDate={{this.topicController.resetBumpDate}}
+ @convertToPublicTopic={{this.topicController.convertToPublicTopic}}
+ @convertToPrivateMessage={{this.topicController.convertToPrivateMessage}}
+ @toggleBookmark={{this.topicController.toggleBookmark}}
+ @showFlagTopic={{this.topicRoute.showFlagTopic}}
+ @toggleArchiveMessage={{this.topicController.toggleArchiveMessage}}
+ @editFirstPost={{this.topicController.editFirstPost}}
+ @deferTopic={{this.topicController.deferTopic}}
+ @replyToPost={{this.topicController.replyToPost}}
+ @showCreate={{false}}
+ @showPluginOutlets={{false}}
+ class="nested-view__topic-actions"
+ />
+ </template>
+}
diff --git a/frontend/discourse/app/components/topic-footer-buttons.gjs b/frontend/discourse/app/components/topic-footer-buttons.gjs
index b592c835932..84dab0490f5 100644
--- a/frontend/discourse/app/components/topic-footer-buttons.gjs
+++ b/frontend/discourse/app/components/topic-footer-buttons.gjs
@@ -133,6 +133,15 @@ export default class TopicFooterButtons extends Component {
return !this.topic?.isPrivateMessage;
}
+ @computed("showCreate", "topic.details.can_create_post")
+ get showCreateButton() {
+ return this.showCreate !== false && this.topic?.details?.can_create_post;
+ }
+
+ get renderPluginOutlets() {
+ return this.showPluginOutlets !== false;
+ }
+
<template>
<div
role="region"
@@ -269,13 +278,15 @@ export default class TopicFooterButtons extends Component {
{{/if}}
</div>
- <PluginOutlet
- @name="topic-footer-main-buttons-before-create"
- @outletArgs={{lazyHash topic=this.topic}}
- @connectorTagName="span"
- />
+ {{#if this.renderPluginOutlets}}
+ <PluginOutlet
+ @name="topic-footer-main-buttons-before-create"
+ @outletArgs={{lazyHash topic=this.topic}}
+ @connectorTagName="span"
+ />
+ {{/if}}
- {{#if this.topic.details.can_create_post}}
+ {{#if this.showCreateButton}}
<DButton
@icon="reply"
@action={{this.replyToPost}}
@@ -285,11 +296,13 @@ export default class TopicFooterButtons extends Component {
/>
{{/if}}
- <PluginOutlet
- @name="after-topic-footer-main-buttons"
- @outletArgs={{lazyHash topic=this.topic}}
- @connectorTagName="span"
- />
+ {{#if this.renderPluginOutlets}}
+ <PluginOutlet
+ @name="after-topic-footer-main-buttons"
+ @outletArgs={{lazyHash topic=this.topic}}
+ @connectorTagName="span"
+ />
+ {{/if}}
</div>
{{#if this.site.desktopView}}
@@ -320,11 +333,13 @@ export default class TopicFooterButtons extends Component {
{{/if}}
{{/if}}
- <PluginOutlet
- @name="after-topic-footer-buttons"
- @outletArgs={{lazyHash topic=this.topic}}
- @connectorTagName="span"
- />
+ {{#if this.renderPluginOutlets}}
+ <PluginOutlet
+ @name="after-topic-footer-buttons"
+ @outletArgs={{lazyHash topic=this.topic}}
+ @connectorTagName="span"
+ />
+ {{/if}}
</div>
</template>
}
diff --git a/spec/system/nested_view_spec.rb b/spec/system/nested_view_spec.rb
index 71572f5b81b..3a3d212be72 100644
--- a/spec/system/nested_view_spec.rb
+++ b/spec/system/nested_view_spec.rb
@@ -60,6 +60,19 @@ RSpec.describe "Nested view" do
expect(nested_view).to have_topic_map
expect(nested_view).to have_no_top_replies_button
end
+
+ it "lets users access topic actions before sorting replies" do
+ reader = Fabricate(:user, refresh_auto_groups: true)
+ sign_in(reader)
+
+ nested_view.visit_nested(topic)
+
+ expect(nested_view).to have_topic_actions_above_controls
+ expect(nested_view).to have_share_topic_action
+ expect(nested_view).to have_bookmark_topic_action
+ expect(nested_view).to have_flag_topic_action
+ expect(nested_view).to have_no_topic_action_reply_button
+ end
end
describe "topic title editing" do
diff --git a/spec/system/page_objects/pages/nested_view.rb b/spec/system/page_objects/pages/nested_view.rb
index d810f936099..bb17375ded5 100644
--- a/spec/system/page_objects/pages/nested_view.rb
+++ b/spec/system/page_objects/pages/nested_view.rb
@@ -224,11 +224,31 @@ module PageObjects
end
def has_topic_map?
- has_css?(".nested-view__topic-map .topic-map__contents")
+ has_css?(".nested-view__op > .nested-view__topic-map .topic-map__contents")
end
def has_no_top_replies_button?
- has_no_css?(".nested-view__topic-map .top-replies")
+ has_no_css?(".nested-view__op > .nested-view__topic-map .top-replies")
+ end
+
+ def has_topic_actions_above_controls?
+ has_css?(".nested-view__topic-actions + .nested-view__controls")
+ end
+
+ def has_share_topic_action?
+ has_css?(".nested-view__topic-actions #topic-footer-button-share-and-invite")
+ end
+
+ def has_bookmark_topic_action?
+ has_css?(".nested-view__topic-actions .bookmark-menu__trigger")
+ end
+
+ def has_flag_topic_action?
+ has_css?(".nested-view__topic-actions #topic-footer-button-flag")
+ end
+
+ def has_no_topic_action_reply_button?
+ has_no_css?(".nested-view__topic-actions .create")
end
def has_floating_reply_button?