FIX: Revoking admin or moderator status doesn't require refresh to delete/anonymize/merge user (PR #14073)

On the/admin/users/<id>/<username> page, there are action buttons that are either visible or hidden depending on a few fields from the AdminDetailsSerializer: can_be_deleted, can_be_anonymized, can_be_merged, can_delete_all_posts.

These fields are updated when granting/revoking admin or moderator status. However, those updates were not being reflected on the page. E.g. if a user is granted moderation privileges, the ‘anonymize user’ and ‘merge’ buttons still appear on the page, which is inconsistent with the backend state of the user. It requires refreshing the page to update the state.

This commit fixes that issue, by syncing the client model state with the server state when handling a successful response from the server. Now, when revoking privileges, the buttons automatically appear without refreshing the page. Similarly, when granting moderator privileges, the buttons automatically disappear without refreshing the page.


PR looks good to me :+1: Before merging, can we update the server side tests to reflect the change in response body?

Thanks @tgxworld, I’ve updated the server side tests to reflect the changes to the response body.

I was following the lead of the other tests in the file, please let me know if it all looks okay.

@graydenshand Changes look good to me :+1: Thank you!