move_topic_modal: Use dialog_error to display error.

Fixes #20210
This commit is contained in:
Ganesh Pawar
2021-11-24 20:33:21 +05:30
committed by Tim Abbott
parent f4dac2dd77
commit 19c4a63d51
4 changed files with 13 additions and 23 deletions

View File

@@ -1063,10 +1063,10 @@ export function move_topic_containing_message_to_stream(
dialog_widget.close_modal();
}
if (currently_topic_editing_messages.includes(message_id)) {
$("#topic_stream_edit_form_error .error-msg").text(
$t({defaultMessage: "A Topic Move already in progress."}),
ui_report.client_error(
$t_html({defaultMessage: "A Topic Move already in progress."}),
$("#move_topic_modal #dialog_error"),
);
$("#topic_stream_edit_form_error").show();
return;
}
currently_topic_editing_messages.push(message_id);

View File

@@ -33,6 +33,7 @@ import * as stream_color from "./stream_color";
import * as stream_data from "./stream_data";
import * as stream_settings_ui from "./stream_settings_ui";
import * as sub_store from "./sub_store";
import * as ui_report from "./ui_report";
import * as unread_ops from "./unread_ops";
import {user_settings} from "./user_settings";
@@ -405,11 +406,6 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
hide_topic_popover();
function move_topic() {
function show_error_msg(msg) {
$("#topic_stream_edit_form_error .error-msg").text(msg);
$("#topic_stream_edit_form_error").show();
}
const params = Object.fromEntries(
$("#move_topic_form")
.serializeArray()
@@ -435,7 +431,10 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
new_topic_name.toLowerCase() === old_topic_name.toLowerCase()
) {
dialog_widget.hide_dialog_spinner();
show_error_msg("Please select a different stream or change topic name.");
ui_report.client_error(
$t_html({defaultMessage: "Please select a different stream or change topic name."}),
$("#move_topic_modal #dialog_error"),
);
return;
}
@@ -462,7 +461,11 @@ function build_move_topic_to_stream_popover(e, current_stream_id, topic_name) {
},
(xhr) => {
dialog_widget.hide_dialog_spinner();
show_error_msg(xhr.responseJSON.msg);
ui_report.error(
$t_html({defaultMessage: "Error moving topic"}),
xhr,
$("#move_topic_modal #dialog_error"),
);
},
);
}
@@ -815,8 +818,4 @@ export function register_topic_handlers() {
e.stopPropagation();
e.preventDefault();
});
$("body").on("click", "#topic_stream_edit_form_error .send-status-close", () => {
$("#topic_stream_edit_form_error").hide();
});
}

View File

@@ -695,11 +695,6 @@ ul {
margin-bottom: 10px;
}
#topic_stream_edit_form_error {
background-color: hsla(0, 70%, 87%, 0.7);
color: hsl(0, 100%, 50%);
}
.topic_stream_edit_header {
display: flex;
flex-wrap: wrap;

View File

@@ -1,9 +1,5 @@
<p>{{#tr}}Move all messages in <strong>{topic_name}</strong>{{/tr}} to:</p>
<form class="new-style" id="move_topic_form">
<div id="topic_stream_edit_form_error" class="alert">
<span class="send-status-close">&times;</span>
<span class="error-msg"></span>
</div>
<p>{{t "Select a stream below or change topic name." }}</p>
<div class="topic_stream_edit_header">
<div class="stream_header_colorblock"></div>