Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
dialog_widget: Remove is_confirm_dialog variable.
Tim Abbott6fb0d414b43b
diff --git a/static/js/confirm_dialog.js b/static/js/confirm_dialog.jsindex 12af40c8c13..36b0beeef45 100644--- a/static/js/confirm_dialog.js+++ b/static/js/confirm_dialog.js@@ -1,10 +1,13 @@-import {$t_html} from "./i18n";import * as dialog_widget from "./dialog_widget";+import {$t_html} from "./i18n";export function launch(conf) {- dialog_widget.launch(- {...conf,- html_submit_button: $t_html({defaultMessage: "Confirm"}),- is_confirm_dialog: true,- });+ dialog_widget.launch({+ ...conf,+ close_on_submit: true,+ danger_submit_button: true,+ focus_submit_on_open: true,+ html_submit_button: $t_html({defaultMessage: "Confirm"}),+ // Used to control button colors in the template.+ });}diff --git a/static/js/dialog_widget.js b/static/js/dialog_widget.jsindex 20599d55b50..4cafb649458 100644--- a/static/js/dialog_widget.js+++ b/static/js/dialog_widget.js@@ -62,9 +62,6 @@ export function show_dialog_spinner() {}export function launch(conf) {- const html = render_dialog_widget({fade: conf.fade, is_confirm_dialog: conf.is_confirm_dialog});- const dialog = $(html);-const mandatory_fields = [// The html_ fields should be safe HTML. If callers// interpolate user data into strings, they should use@@ -75,12 +72,25 @@ export function launch(conf) {"parent",];+ // Optional parameters:+ // * html_submit_button: Submit button text.+ // * close_on_submit: Whether to close modal on clicking submit.+ // * focus_submit_on_open: Whether to focus submit button on open.+ // * danger_submit_button: Whether to use danger button styling for submit button.+ // * help_link: A help link in the heading area.+for (const f of mandatory_fields) {if (conf[f] === undefined) {blueslip.error("programmer omitted " + f);}}+ const html = render_dialog_widget({+ fade: conf.fade,+ danger_submit_button: conf.danger_submit_button,+ });+ const dialog = $(html);+conf.parent.append(dialog);// Close any existing modals--on settings screens you can@@ -99,7 +109,7 @@ export function launch(conf) {const submit_button_span = dialog.find(".dialog_submit_button span");- let html_submit_button = conf.html_submit_button || $t_html({defaultMessage: "Save changes"});+ const html_submit_button = conf.html_submit_button || $t_html({defaultMessage: "Save changes"});submit_button_span.html(html_submit_button);if (conf.post_render !== undefined) {@@ -111,7 +121,7 @@ export function launch(conf) {submit_button.on("click", () => {if (conf.loading_spinner) {show_dialog_spinner();- } else if (conf.is_confirm_dialog) {+ } else if (conf.close_on_submit) {overlays.close_modal("#dialog_widget_modal");}conf.on_click();@@ -124,7 +134,7 @@ export function launch(conf) {// Open the modaloverlays.open_modal("#dialog_widget_modal");- if (conf.is_confirm_dialog) {+ if (conf.focus_submit_on_open) {conf.parent.on("shown.bs.modal", () => {submit_button.trigger("focus");});diff --git a/static/templates/dialog_widget.hbs b/static/templates/dialog_widget.hbsindex 7d816559cf2..30bb59719fd 100644--- a/static/templates/dialog_widget.hbs+++ b/static/templates/dialog_widget.hbs@@ -8,7 +8,7 @@</div><div class="modal-footer"><button class="button rounded close-modal-btn" data-dismiss="modal">{{t "Cancel" }}</button>- <button class="button rounded {{#if is_confirm_dialog}}btn-danger{{else}}sea-green{{/if}} dialog_submit_button">+ <button class="button rounded {{#if danger_submit_button}}btn-danger{{else}}sea-green{{/if}} dialog_submit_button"><object class="loader" type="image/svg+xml" data="/static/images/loader.svg"></object><span></span></button>