UX: Add back button in chat browse screen on mobile (#18849)

This commit is contained in:
Keegan George 2022-11-03 01:06:30 -07:00 committed by GitHub
parent 9ff091dc01
commit 0028149ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 1 deletions

View File

@ -87,6 +87,11 @@ export default class ChatBrowseView extends Component {
showModal("create-channel"); showModal("create-channel");
} }
@action
returnToChannelsList() {
return this.router.transitionTo("chat.index");
}
@bind @bind
filterChannels(filter) { filterChannels(filter) {
this.canLoadMore = true; this.canLoadMore = true;

View File

@ -6,6 +6,14 @@
<div class="chat-browse-view"> <div class="chat-browse-view">
<div class="chat-browse-view__header"> <div class="chat-browse-view__header">
{{#if this.site.mobileView}}
<DButton
@action={{action "returnToChannelsList"}}
@icon="chevron-left"
@class="chat-browse-view__back"
@title="chat.browse.back"
/>
{{/if}}
<h1 class="chat-browse-view__title">{{i18n "chat.browse.title"}}</h1> <h1 class="chat-browse-view__title">{{i18n "chat.browse.title"}}</h1>
{{#if this.currentUser.staff}} {{#if this.currentUser.staff}}
<DButton <DButton

View File

@ -10,13 +10,14 @@
&__header { &__header {
display: flex; display: flex;
justify-content: space-between; gap: 1rem;
align-items: center; align-items: center;
margin: 1rem 0 1rem 1rem; margin: 1rem 0 1rem 1rem;
} }
&__title { &__title {
box-sizing: border-box; box-sizing: border-box;
margin-bottom: 0;
} }
&__content_wrapper { &__content_wrapper {
@ -28,6 +29,10 @@
} }
} }
.new-channel-btn {
margin-left: auto;
}
&__cards { &__cards {
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);

View File

@ -176,6 +176,7 @@ en:
open: "Open" open: "Open"
browse: browse:
back: "Back"
title: Channels title: Channels
filter_all: All filter_all: All
filter_open: Opened filter_open: Opened

View File

@ -23,6 +23,11 @@ acceptance("Discourse Chat - Mobile test", function (needs) {
server.get("/u/search/users", () => { server.get("/u/search/users", () => {
return helper.response([]); return helper.response([]);
}); });
server.get("/chat/api/chat_channels.json", () => {
const channels = [];
return helper.response(channels);
});
}); });
needs.settings({ needs.settings({
@ -54,4 +59,14 @@ acceptance("Discourse Chat - Mobile test", function (needs) {
"Clicking the left arrow button returns to the channels list" "Clicking the left arrow button returns to the channels list"
); );
}); });
test("Chat browse screen back button", async function (assert) {
await visit("/chat/browse");
await click(".chat-browse-view__back");
assert.strictEqual(
currentURL(),
"/chat",
"Clicking the back button returns to the channels list"
);
});
}); });