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.

message_report: Render widgets in message preview.

PieterCK5f88ca021982
diff --git a/web/src/message_report.ts b/web/src/message_report.ts
index 3ebdc7645a7..be78eac7cb0 100644
--- a/web/src/message_report.ts
+++ b/web/src/message_report.ts
@@ -18,7 +18,10 @@ import {
} from "./message_list_view.ts";
import type {Message} from "./message_store.ts";
import * as people from "./people.ts";
+import {update_elements} from "./rendered_markdown.ts";
+import * as rows from "./rows.ts";
import {realm} from "./state_data.ts";
+import {process_submessages} from "./submessage.ts";
import * as ui_report from "./ui_report.ts";
import {toggle_user_card_popover_for_message} from "./user_card_popover.ts";
@@ -100,6 +103,21 @@ function get_message_container_for_preview(message: Message): MessageContainer {
};
}
+function post_process_message_preview($row: JQuery): void {
+ const $content = $row.find(".message_content");
+ update_elements($content);
+ const id = rows.id($row);
+ process_submessages({
+ $row,
+ message_id: id,
+ });
+ // Disable most UI for interacting with message widget in the report
+ // message preview UI.
+ const $widget_content = $content.find(".widget-content");
+ $widget_content.find("button, input, select").prop("disabled", true);
+ $widget_content.find(".poll-edit-question, .poll-option-bar").hide();
+}
+
export function show_message_report_modal(message: Message): void {
const message_preview_body_args = get_message_container_for_preview(message);
const html_body = render_report_message_modal({
@@ -132,6 +150,7 @@ export function show_message_report_modal(message: Message): void {
message.sender_id,
);
+ post_process_message_preview($report_message_preview_container.find(".message_row"));
// Condense the message preview, the main motivation is to hide the
// potentially unpleasant message content.
$report_message_preview_container.find(".message_content").addClass("collapsed");
diff --git a/web/src/widgetize.ts b/web/src/widgetize.ts
index a2cc478d04f..fcade3b7895 100644
--- a/web/src/widgetize.ts
+++ b/web/src/widgetize.ts
@@ -67,8 +67,14 @@ export function activate(in_opts: WidgetOptions): void {
});
};
- if (!$row.attr("id")!.startsWith(`message-row-${message_lists.current?.id}-`)) {
- // Don't activate widgets for messages that are not in the current view.
+ const is_message_preview = $row.parent()?.attr("id") === "report-message-preview-container";
+
+ if (
+ !$row.attr("id")!.startsWith(`message-row-${message_lists.current?.id}-`) &&
+ !is_message_preview
+ ) {
+ // Don't activate widgets for messages that are not in the current view or
+ // in message report modal.
return;
}
@@ -83,7 +89,12 @@ export function activate(in_opts: WidgetOptions): void {
extra_data,
});
- widget_event_handlers.set(message.id, event_handler);
+ if (!is_message_preview) {
+ // Don't re-register the original message's widget event
+ // handler.
+ widget_event_handlers.set(message.id, event_handler);
+ }
+
set_widget_in_message($row, $widget_elem);
// Replay any events that already happened. (This is common
diff --git a/web/styles/message_row.css b/web/styles/message_row.css
index df4e873bc7a..4648573f32f 100644
--- a/web/styles/message_row.css
+++ b/web/styles/message_row.css
@@ -1239,8 +1239,10 @@
#report-message-preview-container {
/* Hide most UI for interacting with a message in the report message preview UI. */
+ .add-task-bar,
.change_visibility_policy,
.recipient-row-topic-menu,
+ .todo-edit-task-list-title,
.message_controls,
.message-reminders,
.message_reactions {