Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_list_view: For spectators, show login button for failed images.
Aman Agrawald006b6cc3d34
diff --git a/static/js/message_list_view.js b/static/js/message_list_view.jsindex fe66ffefeeb..adadbbfec75 100644--- a/static/js/message_list_view.js+++ b/static/js/message_list_view.js@@ -4,6 +4,7 @@ import _ from "lodash";import * as resolved_topic from "../shared/js/resolved_topic";import render_bookend from "../templates/bookend.hbs";+import render_login_to_view_image_button from "../templates/login_to_view_image_button.hbs";import render_message_group from "../templates/message_group.hbs";import render_recipient_row from "../templates/recipient_row.hbs";import render_single_message from "../templates/single_message.hbs";@@ -631,6 +632,16 @@ export class MessageListView {this._put_row($row);this._post_process_single_row($row);}++ if (page_params.is_spectator) {+ // For images that fail to load due to being rate limited or being denied access+ // by server in general, we tell user to login to be able to view the image.+ $message_rows.find(".message_inline_image img").on("error", (e) => {+ $(e.target)+ .closest(".message_inline_image")+ .replaceWith(render_login_to_view_image_button());+ });+ }}_post_process_single_row($row) {diff --git a/static/styles/zulip.css b/static/styles/zulip.cssindex 5f097cc936b..cbf1fdec5c1 100644--- a/static/styles/zulip.css+++ b/static/styles/zulip.css@@ -3120,3 +3120,21 @@ select.inline_select_topic_edit {top: -1px;font-weight: 600;}++.spectator_login_for_image_button {+ max-width: 250px;+ height: 50px;++ :hover {+ text-decoration: none;+ }++ .login_button {+ padding: 5px;+ margin-top: 5px;++ .fa {+ top: 1px;+ }+ }+}diff --git a/static/templates/login_to_view_image_button.hbs b/static/templates/login_to_view_image_button.hbsnew file mode 100644index 00000000000..fa6b813c3d8--- /dev/null+++ b/static/templates/login_to_view_image_button.hbs@@ -0,0 +1,6 @@+<div class="spectator_login_for_image_button">+ <a class="login_button color_animated_button" href="/login/">+ <i class='fa fa-sign-in'></i>+ <span>Log in to view image</span>+ </a>+</div>