settings_account: Fix error message while deactivating account.

We were showing the incorrect error message when the user who
is trying to deactivate himself is the last owner. This commit
fixes this to show "Cannot deactivate the last organization owner"
instead of "Cannot deactivate the last organization administrator".

We had already removed the restriction for deactivating last admin
and added it for last owner, while adding the new owner role.
This commit is contained in:
sahil839 2020-08-22 03:58:49 +05:30 committed by Tim Abbott
parent fbae1685d6
commit 38eac64d91
1 changed files with 4 additions and 4 deletions

View File

@ -590,16 +590,16 @@ exports.set_up = function () {
window.location.href = "/login/";
},
error(xhr) {
const error_last_admin = i18n.t(
"Error: Cannot deactivate the only organization administrator.",
const error_last_owner = i18n.t(
"Error: Cannot deactivate the only organization owner.",
);
const error_last_user = i18n.t(
'Error: Cannot deactivate the only user. You can deactivate the whole organization though in your <a target="_blank" href="/#organization/organization-profile">Organization profile settings</a>.',
);
let rendered_error_msg;
if (xhr.responseJSON.code === "CANNOT_DEACTIVATE_LAST_USER") {
if (xhr.responseJSON.is_last_admin) {
rendered_error_msg = error_last_admin;
if (xhr.responseJSON.is_last_owner) {
rendered_error_msg = error_last_owner;
} else {
rendered_error_msg = error_last_user;
}