discourse/app/assets/javascripts/admin/addon
Grayden 64ead3c3a1
FIX: Revoking admin or moderator status doesn't require refresh to delete/anonymize/merge user (#14073)
* FIX: Revoking admin or moderator status doesn't require refresh to delete/anonymize/merge user

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.

* Add detailed user response to spec for changed routes.

Add tests to verify that the revoke_moderation, grant_moderation, and revoke_admin routes return a response formatted according to the AdminDetailedUserSerializer.
2021-08-19 09:57:16 +08:00
..
adapters
components DEV: Use key over the deprecated keyCode (#13795) 2021-08-09 11:41:36 +02:00
controllers FEATURE: Add post edits count to user activity (#13495) 2021-08-02 10:15:53 -04:00
helpers DEV: prettier 2.2.1 (#11862) 2021-01-27 12:39:20 +01:00
mixins DEV: Use key over the deprecated keyCode (#13795) 2021-08-09 11:41:36 +02:00
models FIX: Revoking admin or moderator status doesn't require refresh to delete/anonymize/merge user (#14073) 2021-08-19 09:57:16 +08:00
routes FEATURE: Add option to grant badge multiple times to users using Bulk Award (#13571) 2021-07-15 05:53:26 +03:00
services FEATURE: Penalty history improvements (#13359) 2021-07-12 11:36:56 -07:00
templates FIX: do not show default locale option on site text customization (#14083) 2021-08-19 05:54:21 +05:30