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.

move_topic_modal: Only include messages senders in warning banner.

bedo7eadabe10a5f
diff --git a/web/src/stream_popover.ts b/web/src/stream_popover.ts
index 7c7c0b200cb..7875f0b2912 100644
--- a/web/src/stream_popover.ts
+++ b/web/src/stream_popover.ts
@@ -516,23 +516,55 @@ export async function build_move_topic_to_stream_popover(
}
let curr_selected_stream: number;
- // Warn if any of current topic participants are NOT subscribed
+
+ function get_messages_to_be_moved(
+ propagate_mode: string,
+ selected_message: Message | undefined,
+ ): Message[] {
+ const all_locally_cached_conversation_messages = message_util.get_loaded_messages_in_topic(
+ current_stream_id,
+ topic_name,
+ );
+
+ // It's move-topic modal, so no message is selected.
+ if (selected_message === undefined) {
+ return all_locally_cached_conversation_messages;
+ }
+
+ // Move only selected message.
+ if (propagate_mode === "change_one") {
+ return [selected_message];
+ }
+
+ // Move selected message and all its following messages.
+ if (propagate_mode === "change_later") {
+ return all_locally_cached_conversation_messages.filter(
+ (msg) => msg.id >= selected_message.id,
+ );
+ }
+
+ // Move all messages in topic.
+ return all_locally_cached_conversation_messages;
+ }
+
+ // Warn if any sender of the messages being moved is NOT subscribed
// to the destination stream.
- async function warn_unsubscribed_participants(destination_stream_id: number): Promise<void> {
+ async function warn_unsubscribed_participants(selected_propagate_mode: string): Promise<void> {
$("#move_topic_modal .unsubscribed-participants-warning").remove();
+ const destination_stream_id = stream_widget_value;
+
// Do nothing if it's the same stream.
- if (destination_stream_id === current_stream_id) {
+ if (destination_stream_id === undefined || destination_stream_id === current_stream_id) {
return;
}
- const locally_cached_conversation_messages = message_util.get_loaded_messages_in_topic(
- current_stream_id,
- topic_name,
- );
+ // Only participants who sent the messages being moved should appear in the banner,
+ // so we fetch those messages first.
+ const messages_to_be_moved = get_messages_to_be_moved(selected_propagate_mode, message);
const active_human_participant_ids = new ConversationParticipants(
- locally_cached_conversation_messages,
+ messages_to_be_moved,
).visible();
const unsubscribed_participant_ids: number[] = [];
@@ -587,6 +619,7 @@ export async function build_move_topic_to_stream_popover(
: null,
hide_close_button: true,
stream: destination_stream,
+ selected_propagate_mode,
unsubscribed_participant_formatted_names_list,
unsubscribed_participants_count,
few_unsubscribed_participants,
@@ -811,7 +844,8 @@ export async function build_move_topic_to_stream_popover(
render_selected_stream();
maybe_show_topic_already_exists_warning();
update_topic_input_placeholder_visibility(topic_input_value);
- void warn_unsubscribed_participants(stream_widget_value);
+ const selected_propagate_mode = String($("#message_move_select_options").val());
+ void warn_unsubscribed_participants(selected_propagate_mode);
dropdown.hide();
event.preventDefault();
@@ -1050,6 +1084,7 @@ export async function build_move_topic_to_stream_popover(
$("#message_move_select_options").on("change", function () {
selected_option = String($(this).val());
last_propagate_mode_for_conversation.set(conversation_key, selected_option);
+ void warn_unsubscribed_participants(selected_option);
maybe_show_topic_already_exists_warning();
update_move_messages_count_text(selected_option, message?.id);
});
diff --git a/web/templates/modal_banner/unsubscribed_participants_warning_banner.hbs b/web/templates/modal_banner/unsubscribed_participants_warning_banner.hbs
index e95b5bd8e03..901f01dac69 100644
--- a/web/templates/modal_banner/unsubscribed_participants_warning_banner.hbs
+++ b/web/templates/modal_banner/unsubscribed_participants_warning_banner.hbs
@@ -1,6 +1,13 @@
{{#> modal_banner . }}
<p class="banner_message">
- {{#if few_unsubscribed_participants}}
+ {{#if (eq selected_propagate_mode "change_one")}}
+ {{#tr}}
+ Message sender <z-user-names></z-user-names> is not subscribed to &nbsp;<z-stream></z-stream>.
+ {{#*inline "z-user-names"}}({{{unsubscribed_participant_formatted_names_list}}}){{/inline}}
+ {{#*inline "z-stream"}}<strong>{{> ../inline_decorated_channel_name stream=stream show_colored_icon=true}}</strong>{{/inline}}
+ {{/tr}}
+
+ {{else if few_unsubscribed_participants}}
{{#tr}}
Some topic participants <z-user-names></z-user-names> are not subscribed to &nbsp;<z-stream></z-stream>.
{{#*inline "z-user-names"}}({{{unsubscribed_participant_formatted_names_list}}}){{/inline}}