Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream_edit: Refactor stream_deactivation modal to confirm_dialog module.
aryanshridharef17d0234dea
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.jsindex 52cedf897e1..f8e4d7855a2 100644--- a/static/js/stream_edit.js+++ b/static/js/stream_edit.js@@ -910,28 +910,39 @@ export function initialize() {);return;}++ function do_archive_stream() {+ const stream_id = $(".confirm_dialog_yes_button").data("stream-id");+ if (!stream_id) {+ ui_report.client_error(+ $t_html({defaultMessage: "Invalid stream id"}),+ $(".stream_change_property_info"),+ );+ return;+ }+ const row = $(".stream-row.active");+ archive_stream(stream_id, $(".stream_change_property_info"), row);+ }++ const modal_parent = $("#subscription_overlay");const stream_name = stream_data.maybe_get_stream_name(stream_id);- const deactivate_stream_modal = render_settings_deactivation_stream_modal({+ const html_body = render_settings_deactivation_stream_modal({stream_name,- stream_id,});- $("#deactivation_stream_modal").remove();- $("#subscriptions_table").append(deactivate_stream_modal);- overlays.open_modal("#deactivation_stream_modal");- });- $("#subscriptions_table").on("click", "#do_deactivate_stream_button", (e) => {- const stream_id = $(e.target).data("stream-id");- overlays.close_modal("#deactivation_stream_modal");- if (!stream_id) {- ui_report.client_error(- $t_html({defaultMessage: "Invalid stream id"}),- $(".stream_change_property_info"),- );- return;- }- const row = $(".stream-row.active");- archive_stream(stream_id, $(".stream_change_property_info"), row);+ confirm_dialog.launch({+ parent: modal_parent,+ html_heading: $t_html(+ {defaultMessage: "Archive stream {stream}"},+ {stream: stream_name},+ ),+ help_link: "/help/archive-a-stream",+ html_body,+ html_yes_button: $t_html({defaultMessage: "Confirm"}),+ on_click: do_archive_stream,+ });++ $(".confirm_dialog_yes_button").attr("data-stream-id", stream_id);});$("#subscriptions_table").on("click", ".stream-row", function (e) {diff --git a/static/templates/settings/deactivation_stream_modal.hbs b/static/templates/settings/deactivation_stream_modal.hbsindex 28caf43aa1c..0f4e5da7870 100644--- a/static/templates/settings/deactivation_stream_modal.hbs+++ b/static/templates/settings/deactivation_stream_modal.hbs@@ -1,17 +1,2 @@-<div id="deactivation_stream_modal" class="modal modal-bg hide fade new-style" tabindex="-1" role="dialog" aria-labelledby="deactivation_stream_modal_label" aria-hidden="true">- <div class="modal-header">- <button type="button" class="close close-modal-btn" data-dismiss="modal" aria-label="{{t 'Close' }}"><span aria-hidden="true">×</span></button>- <h3 id="deactivation_stream_modal_label">- {{t "Archive stream" }} <span class="stream_name">{{stream_name}}</span>- {{> ../help_link_widget link="/help/archive-a-stream" }}- </h3>- </div>- <div class="modal-body">- Archiving stream <strong>{{stream_name}}</strong> <span>will immediately unsubscribe everyone. This action cannot be undone.</span>- <p><strong>{{t "Are you sure you want to archive this stream?" }}</strong></p>- </div>- <div class="modal-footer">- <button class="button rounded close-modal-btn" data-dismiss="modal">{{t "Cancel" }}</button>- <button class="button rounded btn-danger" id="do_deactivate_stream_button" data-stream-id="{{stream_id}}">{{t "Confirm" }}</button>- </div>-</div>+Archiving stream <strong>{{stream_name}}</strong> <span>will immediately unsubscribe everyone. This action cannot be undone.</span>+<p><strong>{{t "Are you sure you want to archive this stream?" }}</strong></p>