UX: do not show user tab preference when disabled (#23188)

Prior to this fix we would only check if the user is allowed to chat and not if chat is enabled.
This commit is contained in:
Joffrey JAFFEUX 2023-08-22 18:22:25 +02:00 committed by GitHub
parent b5b4a3f233
commit 0e00784218
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{{#if (or this.model.can_chat this.currentUser.admin)}}
<li class="user-nav__preferences-chat">
<LinkTo @route="preferences.chat">
{{d-icon "d-chat"}}
<span>{{i18n "chat.title_capitalized"}}</span>
</LinkTo>
{{/if}}
</li>

View File

@ -0,0 +1,7 @@
import Component from "@glimmer/component";
export default class ChatPreferences extends Component {
static shouldRender(model, { siteSettings, currentUser }) {
return siteSettings.chat_enabled && (model.can_chat || currentUser?.admin);
}
}

View File

@ -16,6 +16,12 @@ RSpec.describe "User chat preferences", type: :system do
sign_in(current_user)
end
it "doesnt show the tab" do
visit("/u/#{current_user.username}/preferences")
expect(page).to have_no_css(".user-nav__preferences-chat", visible: :all)
end
it "shows a not found page" do
visit("/u/#{current_user.username}/preferences/chat")