Skip to content

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

UX: show search button on DMs and Threads tabs (#36133)

Joffrey JAFFEUXd0d53409794e
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/direct-messages.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/direct-messages.gjs
index 7849db75e30..d6e2dd30467 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/direct-messages.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/direct-messages.gjs
@@ -14,6 +14,7 @@ export default class ChatDrawerRoutesDirectMessages extends Component {
<Navbar @onClick={{this.chat.toggleDrawer}} as |navbar|>
<navbar.Title @title={{i18n "chat.heading"}} />
<navbar.Actions as |a|>
+ <a.SearchButton />
<a.ToggleDrawerButton />
<a.FullPageButton />
<a.CloseDrawerButton />
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/search.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/search.gjs
index 8484cdcd104..14132660e00 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/search.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/search.gjs
@@ -8,12 +8,13 @@ import ChatSearch from "discourse/plugins/chat/discourse/components/chat-search"
export default class ChatDrawerRoutesSearch extends Component {
@service chat;
@service chatStateManager;
+ @service chatHistory;
@service chatSearchQuery;
<template>
<div class="c-drawer-routes --search">
<Navbar @onClick={{this.chat.toggleDrawer}} as |navbar|>
- <navbar.BackButton />
+ <navbar.BackButton @route={{this.chatHistory.previousRoute.name}} />
<navbar.Title @title={{i18n "chat.search.title"}} />
<navbar.Actions as |action|>
<action.ToggleDrawerButton />
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/threads.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/threads.gjs
index 4da661f5f99..a69cb317c89 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/threads.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat/drawer-routes/threads.gjs
@@ -14,6 +14,7 @@ export default class ChatDrawerRoutesThreads extends Component {
<Navbar @onClick={{this.chat.toggleDrawer}} as |navbar|>
<navbar.Title @title={{i18n "chat.heading"}} />
<navbar.Actions as |action|>
+ <action.SearchButton />
<action.ThreadsListButton />
<action.ToggleDrawerButton />
<action.FullPageButton />
diff --git a/plugins/chat/spec/system/chat_channel_search/drawer_spec.rb b/plugins/chat/spec/system/chat_channel_search/drawer_spec.rb
index 5d6d8aee0a4..de85749ac7e 100644
--- a/plugins/chat/spec/system/chat_channel_search/drawer_spec.rb
+++ b/plugins/chat/spec/system/chat_channel_search/drawer_spec.rb
@@ -18,14 +18,6 @@ RSpec.describe "Chat channel search - drawer", type: :system do
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
- context "when navigating on chat channels" do
- it "shows a button for chat search" do
- drawer_page.visit_index
-
- expect(page).to have_selector(".chat-channel-search-btn")
- end
- end
-
context "when searching for messages" do
it "shows search results and allows navigation" do
message_1 =
diff --git a/plugins/chat/spec/system/drawer/direct_messages_spec.rb b/plugins/chat/spec/system/drawer/direct_messages_spec.rb
new file mode 100644
index 00000000000..976e7f5d0d0
--- /dev/null
+++ b/plugins/chat/spec/system/drawer/direct_messages_spec.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+RSpec.describe "Drawer - direct messages", type: :system do
+ fab!(:current_user, :user)
+
+ let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
+
+ before do
+ chat_system_bootstrap
+ sign_in(current_user)
+ end
+
+ it "shows a button for chat search" do
+ drawer_page.visit_direct_messages
+ drawer_page.open_chat_search
+
+ expect(drawer_page).to have_open_chat_search
+
+ drawer_page.back
+
+ expect(drawer_page).to have_open_direct_messages
+ end
+end
diff --git a/plugins/chat/spec/system/drawer/index_spec.rb b/plugins/chat/spec/system/drawer/index_spec.rb
index ed34d0c065e..60c9aebef26 100644
--- a/plugins/chat/spec/system/drawer/index_spec.rb
+++ b/plugins/chat/spec/system/drawer/index_spec.rb
@@ -10,6 +10,17 @@ RSpec.describe "Drawer - index", type: :system do
sign_in(current_user)
end
+ it "shows a button for chat search" do
+ drawer_page.visit_index
+ drawer_page.open_chat_search
+
+ expect(drawer_page).to have_open_chat_search
+
+ drawer_page.back
+
+ expect(drawer_page).to have_open_channels
+ end
+
it "can leave a direct message" do
channel = Fabricate(:direct_message_channel, users: [current_user])
row = PageObjects::Components::Chat::ChannelRow.new(channel.id)
diff --git a/plugins/chat/spec/system/drawer/threads_spec.rb b/plugins/chat/spec/system/drawer/threads_spec.rb
new file mode 100644
index 00000000000..9f19c065a5b
--- /dev/null
+++ b/plugins/chat/spec/system/drawer/threads_spec.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+RSpec.describe "Drawer - threads", type: :system do
+ fab!(:current_user, :user)
+ fab!(:channel_1) { Fabricate(:chat_channel, threading_enabled: true) }
+
+ let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
+
+ before do
+ SiteSetting.chat_threads_enabled = true
+ channel_1.add(current_user)
+ chat_system_bootstrap
+ sign_in(current_user)
+ end
+
+ it "shows a button for chat search" do
+ drawer_page.visit_user_threads
+ drawer_page.open_chat_search
+
+ expect(drawer_page).to have_open_chat_search
+
+ drawer_page.back
+
+ expect(drawer_page).to have_open_user_threads
+ end
+end
diff --git a/plugins/chat/spec/system/page_objects/chat_drawer/chat_drawer.rb b/plugins/chat/spec/system/page_objects/chat_drawer/chat_drawer.rb
index 6a4d4f26ff9..28a353e730e 100644
--- a/plugins/chat/spec/system/page_objects/chat_drawer/chat_drawer.rb
+++ b/plugins/chat/spec/system/page_objects/chat_drawer/chat_drawer.rb
@@ -38,11 +38,25 @@ module PageObjects
open_channel(channel)
end
+ def visit_direct_messages
+ visit_index
+ click_direct_messages
+ end
+
+ def visit_user_threads
+ visit_index
+ click_user_threads
+ end
+
def visit_browse
visit_index
open_browse
end
+ def open_chat_search
+ find(".chat-channel-search-btn").click
+ end
+
def open_channel(channel)
channels_index.open_channel(channel)
has_no_css?(".chat-skeleton")
@@ -142,6 +156,11 @@ module PageObjects
has_css?("#{VISIBLE_DRAWER} .direct-message-channels")
end
+ def has_open_chat_search?
+ has_css?("html.has-drawer-chat")
+ has_css?("#{VISIBLE_DRAWER} .c-search")
+ end
+
def has_open_user_threads?
has_css?("html.has-drawer-chat")
has_css?("#{VISIBLE_DRAWER} .c-user-threads")