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.

delete_topic: Refactor delete_topic modal to confirm_dialog module.

aryanshridhar91b83cf09fd6
diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js
index 2df5c6d433f..b6983a8aebb 100644
--- a/static/js/stream_popover.js
+++ b/static/js/stream_popover.js
@@ -11,9 +11,10 @@ import * as blueslip from "./blueslip";
import * as browser_history from "./browser_history";
import * as channel from "./channel";
import * as compose_actions from "./compose_actions";
+import * as confirm_dialog from "./confirm_dialog";
import {DropdownListWidget as dropdown_list_widget} from "./dropdown_list_widget";
import * as hash_util from "./hash_util";
-import {$t} from "./i18n";
+import {$t, $t_html} from "./i18n";
import * as message_edit from "./message_edit";
import * as muting from "./muting";
import * as muting_ui from "./muting_ui";
@@ -600,14 +601,20 @@ export function register_topic_handlers() {
hide_topic_popover();
- $("#delete-topic-modal-holder").html(render_delete_topic_modal(args));
-
- $("#do_delete_topic_button").on("click", () => {
- message_edit.delete_topic(stream_id, topic);
+ const modal_parent = $("#delete-topic-modal-holder");
+ const html_body = render_delete_topic_modal(args);
+
+ confirm_dialog.launch({
+ parent: modal_parent,
+ html_heading: $t_html({defaultMessage: "Delete topic"}),
+ help_link: "/help/delete-a-topic",
+ html_body,
+ html_yes_button: $t_html({defaultMessage: "Confirm"}),
+ on_click: () => {
+ message_edit.delete_topic(stream_id, topic);
+ },
});
- $("#delete_topic_modal").modal("show");
-
e.stopPropagation();
});
diff --git a/static/templates/delete_topic_modal.hbs b/static/templates/delete_topic_modal.hbs
index 73ef64a131d..b0a5f30330e 100644
--- a/static/templates/delete_topic_modal.hbs
+++ b/static/templates/delete_topic_modal.hbs
@@ -1,19 +1,6 @@
-<div id="delete_topic_modal" class="modal modal-bg hide fade new-style" tabindex="-1" role="dialog" aria-labelledby="delete_topic_modal_label" aria-hidden="true">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="{{t 'Close' }}"><span aria-hidden="true">&times;</span></button>
- <h3 id="delete_topic_modal_label">
- {{t "Delete topic" }}
- {{> ./help_link_widget link="/help/delete-a-topic" }}
- </h3>
- </div>
- <div class="modal-body">
- <p>{{t "Deleting a topic will immediately remove it and its messages for everyone. Other users may find this confusing, especially if they had received an email or push notification related to the deleted messages." }}</p>
- <p>{{#tr}}Are you sure you want to permanently delete <b>{topic_name}</b>?{{/tr}}</p>
- </div>
- <div class="modal-footer">
- <button class="button" data-dismiss="modal">{{t "Cancel" }}</button>
- <button class="button btn-danger rounded" id="do_delete_topic_button">
- {{t "Confirm" }}
- </button>
- </div>
-</div>
+<p>
+ {{t "Deleting a topic will immediately remove it and its messages for everyone. Other users may find this confusing, especially if they had received an email or push notification related to the deleted messages." }}
+</p>
+<p>
+ {{#tr}}Are you sure you want to permanently delete <b>{topic_name}</b>?{{/tr}}
+</p>