mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
deactivation-stream-modal: Make stream name a template variable.
In stream deactivation modal, make "stream_name" a template variable, rather than patching stream name to modal header in javascript. Add tests for deactivation stream modal.
This commit is contained in:
@@ -577,6 +577,20 @@ function render(template_name, args) {
|
||||
global.write_handlebars_output("compose_stream_alert", html);
|
||||
}());
|
||||
|
||||
(function deactivate_stream_modal() {
|
||||
var args = {
|
||||
stream_name: "Public stream",
|
||||
};
|
||||
var html = render('deactivation-stream-modal', args);
|
||||
global.write_handlebars_output("deactivation-stream-modal", html);
|
||||
|
||||
var modal_header = $(html).find("#deactivation_stream_modal_label");
|
||||
assert.equal(modal_header.text(), "translated: Delete stream " + args.stream_name);
|
||||
|
||||
var button = $(html).find("#do_deactivate_stream_button");
|
||||
assert.equal(button.text(), "translated: Yes, delete this stream");
|
||||
}());
|
||||
|
||||
(function dev_env_email_access() {
|
||||
var html = render('dev_env_email_access');
|
||||
global.write_handlebars_output("dev_env_email_access", html);
|
||||
|
||||
@@ -129,8 +129,9 @@ exports.set_up = function () {
|
||||
row.addClass("active_stream_row");
|
||||
|
||||
var stream_name = row.find('.stream_name').text();
|
||||
var deactivate_stream_modal = templates.render('deactivation-stream-modal', {stream_name: stream_name});
|
||||
$("#settings_content .organization-box").append(deactivate_stream_modal);
|
||||
|
||||
$("#deactivation_stream_modal .stream_name").text(stream_name);
|
||||
overlays.open_modal('deactivation_stream_modal');
|
||||
});
|
||||
|
||||
@@ -167,19 +168,24 @@ exports.set_up = function () {
|
||||
default_stream_input[0].value = "";
|
||||
});
|
||||
|
||||
$("#do_deactivate_stream_button").click(function () {
|
||||
$("#settings_content").on("click", "#do_deactivate_stream_button", function () {
|
||||
if ($("#deactivation_stream_modal .stream_name").text() !== $(".active_stream_row").find('.stream_name').text()) {
|
||||
blueslip.error("Stream deactivation canceled due to non-matching fields.");
|
||||
ui_report.message(i18n.t("Deactivation encountered an error. Please reload and try again."),
|
||||
$("#home-error"), 'alert-error');
|
||||
}
|
||||
overlays.close_modal('deactivation_stream_modal');
|
||||
$("#deactivation_stream_modal").remove();
|
||||
$(".active_stream_row button").prop("disabled", true).text(i18n.t("Working…"));
|
||||
var stream_name = $(".active_stream_row").find('.stream_name').text();
|
||||
var stream_id = stream_data.get_sub(stream_name).stream_id;
|
||||
var row = $(".active_stream_row");
|
||||
exports.delete_stream(stream_id, $("#organization-status"), row);
|
||||
});
|
||||
|
||||
$("#settings_content").on("hide.bs.modal", "#deactivation_stream_modal", function () {
|
||||
$("#deactivation_stream_modal").remove();
|
||||
});
|
||||
};
|
||||
|
||||
exports.delete_stream = function (stream_id, alert_element, stream_row) {
|
||||
|
||||
@@ -595,9 +595,8 @@ $(function () {
|
||||
return;
|
||||
}
|
||||
var stream_name = stream_data.maybe_get_stream_name(stream_id);
|
||||
var deactivate_stream_modal = templates.render("deactivation-stream-modal");
|
||||
var deactivate_stream_modal = templates.render("deactivation-stream-modal", {stream_name: stream_name});
|
||||
$(".subscription_settings").append(deactivate_stream_modal);
|
||||
$("#deactivation_stream_modal .stream_name").text(stream_name);
|
||||
overlays.open_modal('deactivation_stream_modal');
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<div class="alert" id="organization-status"></div>
|
||||
|
||||
{{ partial "deactivation-user-modal" }}
|
||||
{{ partial "deactivation-stream-modal" }}
|
||||
{{ partial "realm-domains-modal" }}
|
||||
{{ partial "revoke-invite-modal" }}
|
||||
{{ partial "resend-invite-modal" }}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div id="deactivation_stream_modal" class="modal modal-bg hide fade" tabindex="-1" role="dialog" aria-labelledby="deactivation_stream_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>
|
||||
<h3 id="deactivation_stream_modal_label">{{t "Delete stream" }} <span class="stream_name"></span></h3>
|
||||
<h3 id="deactivation_stream_modal_label">{{t "Delete stream" }} <span class="stream_name">{{stream_name}}</span></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{{t "Deleting this stream will immediately unsubscribe everyone, and the stream's content will not be recoverable." }} <strong>{{t "Are you sure you want to do this?" }}</strong></p>
|
||||
|
||||
Reference in New Issue
Block a user