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.

subscription: Refactor subscription_invite modal to confirm_dialog module.

aryanshridhare79acba4dc6b
diff --git a/static/js/stream_create.js b/static/js/stream_create.js
index 58b9b4f8f86..b88b3594f63 100644
--- a/static/js/stream_create.js
+++ b/static/js/stream_create.js
@@ -6,6 +6,7 @@ import render_new_stream_users from "../templates/new_stream_users.hbs";
import render_subscription_invites_warning_modal from "../templates/subscription_invites_warning_modal.hbs";
import * as channel from "./channel";
+import * as confirm_dialog from "./confirm_dialog";
import {$t, $t_html} from "./i18n";
import * as ListWidget from "./list_widget";
import * as loading from "./loading";
@@ -430,25 +431,26 @@ export function set_up_handlers() {
}
if (principals.length >= 50) {
- const invites_warning_modal = render_subscription_invites_warning_modal({
+ const modal_parent = $("#subscription_overlay");
+ const html_body = render_subscription_invites_warning_modal({
stream_name,
count: principals.length,
});
- $("#stream-creation").append(invites_warning_modal);
+
+ confirm_dialog.launch({
+ parent: modal_parent,
+ html_heading: $t_html({defaultMessage: "Large number of subscribers"}),
+ html_body,
+ html_yes_button: $t_html({defaultMessage: "Confirm"}),
+ on_click: () => {
+ create_stream();
+ },
+ });
} else {
create_stream();
}
});
- container.on("click", ".close-invites-warning-modal", () => {
- $("#invites-warning-overlay").remove();
- });
-
- container.on("click", ".confirm-invites-warning-modal", () => {
- create_stream();
- $("#invites-warning-overlay").remove();
- });
-
container.on("input", "#create_stream_name", () => {
const stream_name = $("#create_stream_name").val().trim();
diff --git a/static/templates/subscription_invites_warning_modal.hbs b/static/templates/subscription_invites_warning_modal.hbs
index e11f5a227f0..4a62a6fc6e3 100644
--- a/static/templates/subscription_invites_warning_modal.hbs
+++ b/static/templates/subscription_invites_warning_modal.hbs
@@ -1,15 +1,5 @@
-<div id='invites-warning-overlay' class='overlay new-style show' style='z-index:1000;'>
- <div class="modal modal-bg" id="invites-warning-modal" tabindex="-1" role="dialog" aria-labelledby="invites-warning-label" aria-hidden="true">
- <div class="modal-header">
- <button type="button" class="close close-invites-warning-modal" aria-label="{{t 'Close' }}"><span aria-hidden="true">&times;</span></button>
- <h3 id="invites-warning-label">{{t "Large number of subscribers" }}</h3>
- </div>
- <div class="modal-body">
- <p>{{#tr}}Are you sure you want to create stream ''''{stream_name}'''' and subscribe {count} users to it?{{/tr}}</p>
- </div>
- <div class="modal-footer">
- <button class="btn btn-default close-invites-warning-modal">{{t "Go back" }}</button>
- <button class="btn btn-warning confirm-invites-warning-modal">{{#tr}}Yes, subscribe {count} users!{{/tr}}</button>
- </div>
- </div>
-</div>
+<p>
+ {{#tr}}
+ Are you sure you want to create stream ''''{stream_name}'''' and subscribe {count} users to it?
+ {{/tr}}
+</p>