admin: Fix deactivating bot users.

The previous code was using the same codepath as for real users, which
was unfortunate in two ways:
* It hit the wrong endpoint on the server and thus failed
* It popped up the "remove a user prompt" which described a bunch of
  things not relevant to bots.
This commit is contained in:
Tim Abbott
2015-10-28 09:40:30 -07:00
parent 5161891fbd
commit 958ada9f44
2 changed files with 36 additions and 2 deletions

View File

@@ -141,7 +141,41 @@ exports.setup_page = function () {
$("#deactivation_stream_modal").modal("show");
});
$(".admin_user_table").on("click", ".reactivate", function (e) {
$(".admin_bot_table").on("click", ".deactivate", function (e) {
e.preventDefault();
e.stopPropagation();
$(".active_user_row").removeClass("active_user_row");
$(e.target).closest(".user_row").addClass("active_user_row");
var user_name = $(".active_user_row").find('.user_name').text();
var email = $(".active_user_row").find('.email').text();
channel.del({
url: '/json/bots/' + email,
error: function (xhr, error_type) {
if (xhr.status.toString().charAt(0) === "4") {
$(".active_user_row button").closest("td").html(
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg)
);
} else {
$(".active_user_row button").text("Failed!");
}
},
success: function () {
var row = $(".active_user_row");
var button = $(".active_user_row button.deactivate");
button.addClass("btn-warning");
button.removeClass("btn-danger");
button.addClass("reactivate");
button.removeClass("deactivate");
button.text("Reactivate");
row.addClass("deactivated_user");
}
});
});
$(".admin_user_table, .admin_bot_table").on("click", ".reactivate", function (e) {
e.preventDefault();
e.stopPropagation();

View File

@@ -48,7 +48,7 @@
<div id="admin_page_users_loading_indicator"></div>
<h2>Bots</h2>
<table class="table table-condensed table-striped">
<tbody id="admin_bots_table" class="admin_user_table">
<tbody id="admin_bots_table" class="admin_bot_table">
<th>Name</th>
<th>Email</th>
<th>Owner</th>