A platform for community discussion. Free, open, simple.
FIX: ensures chat sidebar is present when core sidebar is disabled (#19197)
Joffrey JAFFEUX637fb9831bdf
diff --git a/plugins/chat/assets/javascripts/discourse/controllers/chat.js b/plugins/chat/assets/javascripts/discourse/controllers/chat.jsindex d823b34f6e1..ea70452f449 100644--- a/plugins/chat/assets/javascripts/discourse/controllers/chat.js+++ b/plugins/chat/assets/javascripts/discourse/controllers/chat.js@@ -1,12 +1,25 @@import Controller from "@ember/controller";-import { action } from "@ember/object";import { inject as service } from "@ember/service";export default class ChatController extends Controller {@service chat;- @action- switchChannel(channel) {- this.chat.openChannel(channel);+ get shouldUseChatSidebar() {+ if (this.site.mobileView) {+ return false;+ }++ if (this.shouldUseCoreSidebar) {+ return false;+ }++ return true;+ }++ get shouldUseCoreSidebar() {+ return (+ this.siteSettings.enable_sidebar &&+ this.siteSettings.enable_experimental_sidebar_hamburger+ );}}diff --git a/plugins/chat/assets/javascripts/discourse/templates/chat.hbs b/plugins/chat/assets/javascripts/discourse/templates/chat.hbsindex 488edad1ebb..b0723f26183 100644--- a/plugins/chat/assets/javascripts/discourse/templates/chat.hbs+++ b/plugins/chat/assets/javascripts/discourse/templates/chat.hbs@@ -11,15 +11,13 @@class={{concat-class"full-page-chat"(if- this.siteSettings.enable_sidebar+ this.shouldUseCoreSidebar"full-page-chat-sidebar-enabled")}}>- {{#if- (and (not this.siteSettings.enable_sidebar) (not this.site.mobileView))- }}- <ChannelsList @onSelect={{action "switchChannel"}} />+ {{#if this.shouldUseChatSidebar}}+ <ChannelsList />{{/if}}<div id="main-chat-outlet">diff --git a/plugins/chat/spec/system/sidebars_spec.rb b/plugins/chat/spec/system/sidebars_spec.rbnew file mode 100644index 00000000000..64cd8f8df0f--- /dev/null+++ b/plugins/chat/spec/system/sidebars_spec.rb@@ -0,0 +1,55 @@+# frozen_string_literal: true++RSpec.describe "Navigation", type: :system, js: true do+ fab!(:category) { Fabricate(:category) }+ fab!(:topic) { Fabricate(:topic) }+ fab!(:post) { Fabricate(:post, topic: topic) }+ fab!(:user) { Fabricate(:admin) }+ fab!(:category_channel) { Fabricate(:category_channel) }+ fab!(:category_channel_2) { Fabricate(:category_channel) }+ let(:chat_page) { PageObjects::Pages::Chat.new }++ before do+ chat_system_bootstrap(user, [category_channel, category_channel_2])+ sign_in(user)+ end++ context "when core sidebar is enabled" do+ before do+ SiteSetting.enable_sidebar = true+ SiteSetting.enable_experimental_sidebar_hamburger = true+ end++ it "uses core sidebar" do+ visit("/chat")++ expect(page).to have_css("#d-sidebar")+ expect(page).to_not have_css(".channels-list")+ end++ context "when visiting on mobile" do+ it "has no sidebar" do+ visit("/?mobile_view=1")+ chat_page.visit_channel(category_channel_2)++ expect(page).to_not have_css("#d-sidebar")+ end+ end+ end++ it "uses chat sidebar" do+ visit("/chat")++ expect(page).to have_css(".channels-list")+ expect(page).to_not have_css("#d-sidebar")+ end++ context "when visiting on mobile" do+ it "has no sidebar" do+ visit("/?mobile_view=1")+ chat_page.visit_channel(category_channel_2)++ expect(page).to_not have_css(".channels-list")+ end+ end+end