Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

bookend: Use it to advertise recent topics for spectators.

Aman Agrawal0ce2ae178277
diff --git a/static/js/message_list.js b/static/js/message_list.js
index 9163bee091f..01d3d9c635f 100644
--- a/static/js/message_list.js
+++ b/static/js/message_list.js
@@ -241,6 +241,7 @@ export class MessageList {
if (stream_name === undefined) {
return;
}
+
let deactivated = false;
let just_unsubscribed = false;
let show_button = true;
@@ -254,7 +255,7 @@ export class MessageList {
just_unsubscribed = true;
// For invite only streams hide the resubscribe button
- // Hide button for guest users
+ // Hide button for guest users and spectators
show_button = !page_params.is_guest && !sub.invite_only;
}
this.view.render_trailing_bookend(
@@ -263,6 +264,7 @@ export class MessageList {
deactivated,
just_unsubscribed,
show_button,
+ page_params.is_spectator,
);
}
diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js
index 661a451c46c..070692c5804 100644
--- a/static/js/message_list_view.js
+++ b/static/js/message_list_view.js
@@ -836,7 +836,7 @@ export class MessageListView {
// If user narrows to a stream, doesn't update
// trailing bookend if user is subscribed.
const sub = stream_data.get_sub(stream_name);
- if (sub === undefined || !sub.subscribed) {
+ if (sub === undefined || !sub.subscribed || page_params.is_spectator) {
list.update_trailing_bookend();
}
}
@@ -1295,7 +1295,14 @@ export class MessageListView {
trailing_bookend.remove();
}
- render_trailing_bookend(stream_name, subscribed, deactivated, just_unsubscribed, show_button) {
+ render_trailing_bookend(
+ stream_name,
+ subscribed,
+ deactivated,
+ just_unsubscribed,
+ show_button,
+ is_spectator,
+ ) {
const rendered_trailing_bookend = $(
render_bookend({
stream_name,
@@ -1303,6 +1310,7 @@ export class MessageListView {
subscribed,
deactivated,
just_unsubscribed,
+ is_spectator,
}),
);
rows.get_table(this.table_name).append(rendered_trailing_bookend);
diff --git a/static/styles/zulip.css b/static/styles/zulip.css
index 25f898372c4..f3c6e5d1410 100644
--- a/static/styles/zulip.css
+++ b/static/styles/zulip.css
@@ -2500,6 +2500,10 @@ div.topic_edit_spinner .loading_indicator_spinner {
overflow: hidden;
text-transform: uppercase;
font-size: 0.8em;
+}
+
+.sub-unsub-message .stream-status,
+.date_row span {
opacity: 0.5;
}
diff --git a/static/templates/bookend.hbs b/static/templates/bookend.hbs
index 3a26a165aa7..9aa2b23e8bc 100644
--- a/static/templates/bookend.hbs
+++ b/static/templates/bookend.hbs
@@ -1,16 +1,22 @@
{{! Client-side Mustache template for rendering the trailing bookend.}}
<div class="{{#if trailing}}trailing_bookend{{/if}} bookend sub-unsub-message">
- <span>
- {{#if deactivated}}
- {{t "This stream has been deactivated" }}
- {{else if subscribed }}
- {{#tr}}You subscribed to stream {stream_name}{{/tr}}
- {{else if just_unsubscribed }}
- {{#tr}}You unsubscribed from stream {stream_name}{{/tr}}
- {{else}}
- {{#tr}}You are not subscribed to stream {stream_name}{{/tr}}
- {{/if}}
- </span>
+ {{#if is_spectator}}
+ <span class="recent-topics-link">
+ <a href="#recent_topics">{{t "Browse recent topics" }}</a>
+ </span>
+ {{else}}
+ <span class="stream-status">
+ {{#if deactivated}}
+ {{t "This stream has been deactivated" }}
+ {{else if subscribed }}
+ {{#tr}}You subscribed to stream {stream_name}{{/tr}}
+ {{else if just_unsubscribed }}
+ {{#tr}}You unsubscribed from stream {stream_name}{{/tr}}
+ {{else}}
+ {{#tr}}You are not subscribed to stream {stream_name}{{/tr}}
+ {{/if}}
+ </span>
+ {{/if}}
{{#if trailing}}
<div class="sub_button_row new-style">
<button class="button white rounded stream_sub_unsub_button {{#unless subscribed}}sea-green{{/unless}}" type="button" name="subscription">