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 blueslip from "./blueslip";
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
|
import * as confirm_dialog from "./confirm_dialog";
|
||||||
import {$t, $t_html} from "./i18n";
|
import {$t, $t_html} from "./i18n";
|
||||||
import * as ListWidget from "./list_widget";
|
import * as ListWidget from "./list_widget";
|
||||||
import * as loading from "./loading";
|
import * as loading from "./loading";
|
||||||
|
@ -95,12 +96,8 @@ function populate_invites(invites_data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_revoke_invite() {
|
function do_revoke_invite() {
|
||||||
const modal_invite_id = $("#revoke_invite_modal #do_revoke_invite_button").attr(
|
const modal_invite_id = $(".confirm_dialog_yes_button").attr("data-invite-id");
|
||||||
"data-invite-id",
|
const modal_is_multiuse = $(".confirm_dialog_yes_button").attr("data-is-multiuse");
|
||||||
);
|
|
||||||
const modal_is_multiuse = $("#revoke_invite_modal #do_revoke_invite_button").attr(
|
|
||||||
"data-is-multiuse",
|
|
||||||
);
|
|
||||||
const revoke_button = meta.current_revoke_invite_user_modal_row.find("button.revoke");
|
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) {
|
if (modal_invite_id !== meta.invite_id || modal_is_multiuse !== meta.is_multiuse) {
|
||||||
|
@ -112,7 +109,7 @@ function do_revoke_invite() {
|
||||||
$("#home-error"),
|
$("#home-error"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$("#revoke_invite_modal").modal("hide");
|
|
||||||
revoke_button.prop("disabled", true).text($t({defaultMessage: "Working…"}));
|
revoke_button.prop("disabled", true).text($t({defaultMessage: "Working…"}));
|
||||||
let url = "/json/invites/" + meta.invite_id;
|
let url = "/json/invites/" + meta.invite_id;
|
||||||
|
|
||||||
|
@ -170,16 +167,21 @@ export function on_load_success(invites_data, initialize_event_handlers) {
|
||||||
email,
|
email,
|
||||||
referred_by,
|
referred_by,
|
||||||
};
|
};
|
||||||
const rendered_revoke_modal = render_settings_revoke_invite_modal(ctx);
|
const modal_parent = $("#admin_invites_table");
|
||||||
$("#revoke_invite_modal_holder").html(rendered_revoke_modal);
|
const html_body = render_settings_revoke_invite_modal(ctx);
|
||||||
$("#revoke_invite_modal #do_revoke_invite_button").attr("data-invite-id", meta.invite_id);
|
|
||||||
$("#revoke_invite_modal #do_revoke_invite_button").attr(
|
confirm_dialog.launch({
|
||||||
"data-is-multiuse",
|
parent: modal_parent,
|
||||||
meta.is_multiuse,
|
html_heading: ctx.is_multiuse
|
||||||
);
|
? $t_html({defaultMessage: "Revoke invitation link"})
|
||||||
$("#revoke_invite_modal").modal("show");
|
: $t_html({defaultMessage: "Revoke invitation to {email}"}, {email}),
|
||||||
$("#do_revoke_invite_button").off("click");
|
html_body,
|
||||||
$("#do_revoke_invite_button").on("click", do_revoke_invite);
|
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) => {
|
$(".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">
|
{{#if is_multiuse}}
|
||||||
<div class="modal-header">
|
<p>{{#tr}}Are you sure you want to revoke this invitation link created by <strong>{referred_by}</strong>?{{/tr}}</p>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="{{t 'Close' }}"><span aria-hidden="true">×</span></button>
|
{{else}}
|
||||||
{{#if is_multiuse}}
|
<p>{{#tr}}Are you sure you want to revoke the invitation to <strong>{email}</strong>?{{/tr}}</p>
|
||||||
<h3 id="revoke_invite_modal_label">{{#tr}}Revoke invitation link{{/tr}}</h3>
|
{{/if}}
|
||||||
{{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>
|
|
||||||
|
|
Loading…
Reference in New Issue