mirror of https://github.com/zulip/zulip.git
settings_invite: Refactor revoke_invite modal to confirm_dialog module.
This commit is contained in:
parent
e79acba4dc
commit
0e3a305a67
|
@ -5,6 +5,7 @@ import render_settings_revoke_invite_modal from "../templates/settings/revoke_in
|
|||
|
||||
import * as blueslip from "./blueslip";
|
||||
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";
|
||||
|
@ -95,12 +96,8 @@ function populate_invites(invites_data) {
|
|||
}
|
||||
|
||||
function do_revoke_invite() {
|
||||
const modal_invite_id = $("#revoke_invite_modal #do_revoke_invite_button").attr(
|
||||
"data-invite-id",
|
||||
);
|
||||
const modal_is_multiuse = $("#revoke_invite_modal #do_revoke_invite_button").attr(
|
||||
"data-is-multiuse",
|
||||
);
|
||||
const modal_invite_id = $(".confirm_dialog_yes_button").attr("data-invite-id");
|
||||
const modal_is_multiuse = $(".confirm_dialog_yes_button").attr("data-is-multiuse");
|
||||
const revoke_button = meta.current_revoke_invite_user_modal_row.find("button.revoke");
|
||||
|
||||
if (modal_invite_id !== meta.invite_id || modal_is_multiuse !== meta.is_multiuse) {
|
||||
|
@ -112,7 +109,7 @@ function do_revoke_invite() {
|
|||
$("#home-error"),
|
||||
);
|
||||
}
|
||||
$("#revoke_invite_modal").modal("hide");
|
||||
|
||||
revoke_button.prop("disabled", true).text($t({defaultMessage: "Working…"}));
|
||||
let url = "/json/invites/" + meta.invite_id;
|
||||
|
||||
|
@ -170,16 +167,21 @@ export function on_load_success(invites_data, initialize_event_handlers) {
|
|||
email,
|
||||
referred_by,
|
||||
};
|
||||
const rendered_revoke_modal = render_settings_revoke_invite_modal(ctx);
|
||||
$("#revoke_invite_modal_holder").html(rendered_revoke_modal);
|
||||
$("#revoke_invite_modal #do_revoke_invite_button").attr("data-invite-id", meta.invite_id);
|
||||
$("#revoke_invite_modal #do_revoke_invite_button").attr(
|
||||
"data-is-multiuse",
|
||||
meta.is_multiuse,
|
||||
);
|
||||
$("#revoke_invite_modal").modal("show");
|
||||
$("#do_revoke_invite_button").off("click");
|
||||
$("#do_revoke_invite_button").on("click", do_revoke_invite);
|
||||
const modal_parent = $("#admin_invites_table");
|
||||
const html_body = render_settings_revoke_invite_modal(ctx);
|
||||
|
||||
confirm_dialog.launch({
|
||||
parent: modal_parent,
|
||||
html_heading: ctx.is_multiuse
|
||||
? $t_html({defaultMessage: "Revoke invitation link"})
|
||||
: $t_html({defaultMessage: "Revoke invitation to {email}"}, {email}),
|
||||
html_body,
|
||||
html_yes_button: $t_html({defaultMessage: "Confirm"}),
|
||||
on_click: do_revoke_invite,
|
||||
});
|
||||
|
||||
$(".confirm_dialog_yes_button").attr("data-invite-id", meta.invite_id);
|
||||
$(".confirm_dialog_yes_button").attr("data-is-multiuse", meta.is_multiuse);
|
||||
});
|
||||
|
||||
$(".admin_invites_table").on("click", ".resend", (e) => {
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
<div id="revoke_invite_modal" class="modal modal-bg hide fade" tabindex="-1" role="dialog" aria-labelledby="revoke_invite_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">×</span></button>
|
||||
{{#if is_multiuse}}
|
||||
<h3 id="revoke_invite_modal_label">{{#tr}}Revoke invitation link{{/tr}}</h3>
|
||||
{{else}}
|
||||
<h3 id="revoke_invite_modal_label">{{#tr}}Revoke invitation to {email}{{/tr}}</h3>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="modal-body" id="revoke_invite_message">
|
||||
{{#if is_multiuse}}
|
||||
<p>{{#tr}}Are you sure you want to revoke this invitation link created by <strong>{referred_by}</strong>?{{/tr}}</p>
|
||||
{{else}}
|
||||
<p>{{#tr}}Are you sure you want to revoke the invitation to <strong>{email}</strong>?{{/tr}}</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="button rounded" data-dismiss="modal">{{t "Cancel" }}</button>
|
||||
<button class="button rounded btn-danger" id="do_revoke_invite_button">{{t "Confirm" }}</button>
|
||||
</div>
|
||||
</div>
|
||||
{{#if is_multiuse}}
|
||||
<p>{{#tr}}Are you sure you want to revoke this invitation link created by <strong>{referred_by}</strong>?{{/tr}}</p>
|
||||
{{else}}
|
||||
<p>{{#tr}}Are you sure you want to revoke the invitation to <strong>{email}</strong>?{{/tr}}</p>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in New Issue