frontend: Remove html_submit_button paramter passed to dialog_widget.

We used html_submit_button to pass text to be present in the modal
submit button. There are only two possible options as of now -
"Confirm" and "Save changes" and the correct one can be determined
using is_confirm_modal parameter. So, we remove this paramter for
now and we can add it later if we have more type of modals using
this widget.
This commit is contained in:
sahil839 2021-07-07 23:05:50 +05:30 committed by Tim Abbott
parent ec3c5547ff
commit dff374a48b
16 changed files with 12 additions and 23 deletions

View File

@ -103,7 +103,6 @@ export function build_user_avatar_widget(upload_function) {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Delete profile picture"}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: delete_user_avatar,
fade: true,
});

View File

@ -1,5 +1,10 @@
import {$t_html} from "./i18n";
import * as dialog_widget from "./dialog_widget";
export function launch(conf) {
dialog_widget.launch({...conf, is_confirm_dialog: true});
dialog_widget.launch(
{...conf,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
is_confirm_dialog: true,
});
}

View File

@ -4,6 +4,7 @@ import render_dialog_widget from "../templates/dialog_widget.hbs";
import render_dialog_heading from "../templates/dialog_widget_heading.hbs";
import * as blueslip from "./blueslip";
import {$t_html} from "./i18n";
import * as overlays from "./overlays";
import * as settings_data from "./settings_data";
@ -64,18 +65,17 @@ export function launch(conf) {
const html = render_dialog_widget({fade: conf.fade});
const dialog = $(html);
const conf_fields = [
// The next three fields should be safe HTML. If callers
const mandatory_fields = [
// The html_ fields should be safe HTML. If callers
// interpolate user data into strings, they should use
// templates.
"html_heading",
"html_body",
"html_submit_button",
"on_click",
"parent",
];
for (const f of conf_fields) {
for (const f of mandatory_fields) {
if (conf[f] === undefined) {
blueslip.error("programmer omitted " + f);
}
@ -99,7 +99,8 @@ export function launch(conf) {
const submit_button_span = dialog.find(".dialog_submit_button span");
submit_button_span.html(conf.html_submit_button);
let html_submit_button = conf.html_submit_button || $t_html({defaultMessage: "Save changes"});
submit_button_span.html(html_submit_button);
if (conf.post_render !== undefined) {
conf.post_render();

View File

@ -1004,7 +1004,6 @@ export function delete_message(msg_id) {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Delete message"}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
help_link: "/help/edit-or-delete-a-message#delete-a-message",
on_click: do_delete_message,
loading_spinner: true,

View File

@ -37,7 +37,6 @@ export function confirm_mute_user(user_id) {
html_heading: $t({defaultMessage: "Mute user"}),
help_link: "/help/mute-a-user",
html_body,
html_submit_button: $t({defaultMessage: "Confirm"}),
on_click,
});
}

View File

@ -603,7 +603,6 @@ export function set_up() {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Deactivate your account"}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: handle_confirm,
help_link: "/help/deactivate-your-account",
fade: true,

View File

@ -269,7 +269,6 @@ export function set_up() {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Override built-in emoji?"}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: submit_custom_emoji_request,
fade: true,
});

View File

@ -206,7 +206,6 @@ export function on_load_success(invites_data, initialize_event_handlers) {
? $t_html({defaultMessage: "Revoke invitation link"})
: $t_html({defaultMessage: "Revoke invitation to {email}"}, {email}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: do_revoke_invite,
fade: true,
});
@ -232,7 +231,6 @@ export function on_load_success(invites_data, initialize_event_handlers) {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Resend invitation"}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: do_resend_invite,
fade: true,
});

View File

@ -1174,7 +1174,6 @@ export function build_page() {
html_heading: $t_html({defaultMessage: "Deactivate organization"}),
help_link: "/help/deactivate-your-organization",
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: do_deactivate_realm,
fade: true,
});

View File

@ -366,7 +366,6 @@ export function set_up() {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Delete user group"}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: delete_user_group,
fade: true,
});

View File

@ -447,7 +447,6 @@ function confirm_deactivation(row, user_id, status_field) {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Deactivate {email}"}, {email: user.email}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: handle_confirm,
fade: true,
});

View File

@ -16,7 +16,6 @@ export function confirm_unstar_all_messages() {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Unstar all messages"}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: message_flags.unstar_all_messages,
});
}
@ -41,7 +40,6 @@ export function confirm_unstar_all_messages_in_topic(stream_id, topic) {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Unstar messages in topic"}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click,
});
}

View File

@ -441,7 +441,6 @@ export function set_up_handlers() {
parent: modal_parent,
html_heading: $t_html({defaultMessage: "Large number of subscribers"}),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: () => {
create_stream();
},

View File

@ -899,7 +899,6 @@ export function initialize() {
{stream_name: sub.name},
),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: remove_user_from_private_stream,
fade: true,
});
@ -968,7 +967,6 @@ export function initialize() {
),
help_link: "/help/archive-a-stream",
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: do_archive_stream,
fade: true,
});

View File

@ -671,7 +671,6 @@ export function register_topic_handlers() {
html_heading: $t_html({defaultMessage: "Delete topic"}),
help_link: "/help/delete-a-topic",
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: () => {
message_edit.delete_topic(stream_id, topic);
},

View File

@ -970,7 +970,6 @@ export function unsubscribe_from_private_stream(sub, from_stream_popover) {
{stream_name: sub.name},
),
html_body,
html_submit_button: $t_html({defaultMessage: "Confirm"}),
on_click: unsubscribe_from_stream,
fade: true,
});