mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
UX: displays channel title in document title (#21242)
This commit is contained in:
@ -10,6 +10,18 @@ export default function withChatChannel(extendedClass) {
|
|||||||
return this.chatChannelsManager.find(params.channelId);
|
return this.chatChannelsManager.find(params.channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
titleToken() {
|
||||||
|
if (!this.currentModel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.currentModel.isDirectMessageChannel) {
|
||||||
|
return `${this.currentModel.title}`;
|
||||||
|
} else {
|
||||||
|
return `#${this.currentModel.title}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
afterModel(model) {
|
afterModel(model) {
|
||||||
this.controllerFor("chat-channel").set("targetMessageId", null);
|
this.controllerFor("chat-channel").set("targetMessageId", null);
|
||||||
this.chat.activeChannel = model;
|
this.chat.activeChannel = model;
|
||||||
|
39
plugins/chat/spec/system/document_title_spec.rb
Normal file
39
plugins/chat/spec/system/document_title_spec.rb
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe "Document title", type: :system, js: true do
|
||||||
|
fab!(:current_user) { Fabricate(:user) }
|
||||||
|
|
||||||
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
||||||
|
|
||||||
|
context "when visiting a public channel" do
|
||||||
|
fab!(:channel_1) { Fabricate(:category_channel) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
chat_system_bootstrap
|
||||||
|
channel_1.add(current_user)
|
||||||
|
sign_in(current_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "shows the channel name in the document title" do
|
||||||
|
chat_page.visit_channel(channel_1)
|
||||||
|
|
||||||
|
expect(page.title).to start_with("##{channel_1.title}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when visiting a direct message channel" do
|
||||||
|
fab!(:channel_1) { Fabricate(:direct_message_channel, users: [current_user]) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
chat_system_bootstrap
|
||||||
|
channel_1.add(current_user)
|
||||||
|
sign_in(current_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "shows the channel name in the document title" do
|
||||||
|
chat_page.visit_channel(channel_1)
|
||||||
|
|
||||||
|
expect(page.title).to start_with("#{channel_1.title(current_user)}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Reference in New Issue
Block a user