Skip to content

Commit

Permalink
message_feed: Add channel-settings-link to bookend.
Browse files Browse the repository at this point in the history
To replace the previous subscribe/subscribe buttons, we add a button
to visit channel settings (if not subscribed) or manage channel
settings (if subscribed) to trailing bookends.

Fixes zulip#32125.
  • Loading branch information
reharsh authored and timabbott committed Nov 15, 2024
1 parent a8f76f1 commit e0bd371
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions web/src/message_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ export class MessageList {
}

this.view.render_trailing_bookend(
stream_id,
sub?.name,
subscribed,
deactivated,
Expand Down
2 changes: 2 additions & 0 deletions web/src/message_list_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1949,6 +1949,7 @@ export class MessageListView {
}

render_trailing_bookend(
stream_id: number,
stream_name: string | undefined,
subscribed: boolean,
deactivated: boolean,
Expand All @@ -1961,6 +1962,7 @@ export class MessageListView {
// partial in message_group.hbs, which do not set is_trailing_bookend.
const $rendered_trailing_bookend = $(
render_bookend({
stream_id,
stream_name,
subscribed,
deactivated,
Expand Down
6 changes: 4 additions & 2 deletions web/templates/bookend.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
{{t "This channel has been archived." }}
{{else if subscribed }}
{{#tr}}
You subscribed to <z-stream-name></z-stream-name>.
You subscribed to <z-stream-name></z-stream-name>. <channel-settings-link></channel-settings-link>
{{#*inline "z-stream-name"}}{{> stream_privacy }} {{stream_name}}{{/inline}}
{{#*inline "channel-settings-link"}} <a href="#channels/{{stream_id}}/{{stream_name}}/personal">{{t 'Manage channel settings'}}</a>{{/inline}}
{{/tr}}
{{else if just_unsubscribed }}
{{#tr}}
You unsubscribed from <z-stream-name></z-stream-name>.
You unsubscribed from <z-stream-name></z-stream-name>. <channel-settings-link></channel-settings-link>
{{#*inline "z-stream-name"}}{{> stream_privacy }} {{stream_name}}{{/inline}}
{{#*inline "channel-settings-link"}} <a href="#channels/{{stream_id}}/{{stream_name}}/general">{{t 'View in channel settings'}}</a>{{/inline}}
{{/tr}}
{{else}}
{{#tr}}
Expand Down
8 changes: 8 additions & 0 deletions web/tests/message_list.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,13 @@ run_test("bookend", ({override}) => {
list.update_trailing_bookend();
assert.equal(stub.num_calls, 1);
const bookend = stub.get_args(
"stream_id",
"stream_name",
"subscribed",
"deactivated",
"just_unsubscribed",
);
assert.equal(bookend.stream_id, 5);
assert.equal(bookend.stream_name, "IceCream");
assert.equal(bookend.subscribed, true);
assert.equal(bookend.deactivated, false);
Expand All @@ -386,11 +388,13 @@ run_test("bookend", ({override}) => {
list.update_trailing_bookend();
assert.equal(stub.num_calls, 1);
const bookend = stub.get_args(
"stream_id",
"stream_name",
"subscribed",
"deactivated",
"just_unsubscribed",
);
assert.equal(bookend.stream_id, 5);
assert.equal(bookend.stream_name, "IceCream");
assert.equal(bookend.subscribed, false);
assert.equal(bookend.deactivated, false);
Expand All @@ -406,11 +410,13 @@ run_test("bookend", ({override}) => {
list.update_trailing_bookend();
assert.equal(stub.num_calls, 1);
const bookend = stub.get_args(
"stream_id",
"stream_name",
"subscribed",
"deactivated",
"just_unsubscribed",
);
assert.equal(bookend.stream_id, 5);
assert.equal(bookend.stream_name, "IceCream");
assert.equal(bookend.subscribed, false);
assert.equal(bookend.deactivated, false);
Expand All @@ -425,11 +431,13 @@ run_test("bookend", ({override}) => {
list.update_trailing_bookend();
assert.equal(stub.num_calls, 1);
const bookend = stub.get_args(
"stream_id",
"stream_name",
"subscribed",
"deactivated",
"just_unsubscribed",
);
assert.equal(bookend.stream_id, 5);
assert.equal(bookend.stream_name, "IceCream");
assert.equal(bookend.subscribed, false);
assert.equal(bookend.deactivated, false);
Expand Down

0 comments on commit e0bd371

Please sign in to comment.