This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/controllers/admin
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
..
admin_controller.rb
api_controller.rb FIX: Allow plugins to correctly extend API key scopes. (#12113) 2021-02-17 14:42:44 -03:00
backups_controller.rb DEV: Upgrade Rails to 6.1.3.1 (#12688) 2021-04-21 12:36:32 +03:00
badges_controller.rb FEATURE: Add option to grant badge multiple times to users using Bulk Award (#13571) 2021-07-15 05:53:26 +03:00
color_schemes_controller.rb
dashboard_controller.rb UX: Changes to new features section in admin dashboard (#12029) 2021-02-10 13:12:04 -05:00
email_controller.rb FIX: Catch UndefinedConversionError for inbound emails (#13000) 2021-05-10 14:26:23 +10:00
email_styles_controller.rb
email_templates_controller.rb Add bad_destination_address template to email_templates_controller (#12102) 2021-02-17 09:57:38 +01:00
embeddable_hosts_controller.rb
embedding_controller.rb
emojis_controller.rb
groups_controller.rb DEV: Remove bulk group admin endpoints (#11949) 2021-02-03 18:12:22 +01:00
impersonate_controller.rb
permalinks_controller.rb
plugins_controller.rb
reports_controller.rb FIX: Only cache reports with exceptions for 1 minute (#11447) 2020-12-09 10:54:41 -06:00
robots_txt_controller.rb
screened_emails_controller.rb
screened_ip_addresses_controller.rb
screened_urls_controller.rb
search_logs_controller.rb
site_settings_controller.rb FEATURE: Treat site settings as plain text and add a new HTML type. (#12618) 2021-04-07 12:51:19 -03:00
site_texts_controller.rb FIX: I18n couldn't find translations. (#11774) 2021-01-20 17:43:00 -03:00
staff_action_logs_controller.rb
themes_controller.rb PERF: Remove N+1s from ThemeController#update and #show (#12842) 2021-04-27 12:30:29 +01:00
user_fields_controller.rb FEATURE: Add user custom fields to user directory (#13238) 2021-06-07 12:34:01 -05:00
users_controller.rb FIX: Revoking admin or moderator status doesn't require refresh to delete/anonymize/merge user (#14073) 2021-08-19 09:57:16 +08:00
versions_controller.rb
watched_words_controller.rb FEATURE: add staff action logs for watched words (#13574) 2021-06-30 11:22:46 +05:30
web_hooks_controller.rb