account-settings: Disable deactivate account button when only owner.

Disables the deactivate account button in the user's account and
privacy settings tab if they are the only active organization owner.

Adds a tooltip when hovering on the deactivated button to let the
user know why the button is disabled.

The backend already returns an error for self account deactivation
requests if the user is the only organization owner.
This commit is contained in:
Lauryn Menard
2022-12-20 16:52:25 +01:00
committed by Tim Abbott
parent 7abf476443
commit 1a3b0edf4b
9 changed files with 83 additions and 3 deletions

View File

@@ -642,6 +642,7 @@ run_test("realm_domains", ({override}) => {
});
run_test("realm_user", ({override}) => {
override(settings_account, "maybe_update_deactivate_account_button", noop);
let event = event_fixtures.realm_user__add;
dispatch({...event});
const added_person = people.get_by_user_id(event.person.user_id);

View File

@@ -590,6 +590,20 @@ test_people("set_custom_profile_field_data", () => {
assert.equal(person.profile_data[field.id].rendered_value, "<p>Field value</p>");
});
test_people("is_current_user_only_owner", () => {
const person = people.get_by_email(me.email);
person.is_owner = false;
page_params.is_owner = false;
assert.ok(!people.is_current_user_only_owner());
person.is_owner = true;
page_params.is_owner = true;
assert.ok(people.is_current_user_only_owner());
people.add_active_user(realm_owner);
assert.ok(!people.is_current_user_only_owner());
});
test_people("recipient_counts", () => {
const user_id = 99;
assert.equal(people.get_recipient_count({user_id}), 0);