Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sh-admin): alert the user while deleting users who are team owners #3937

Conversation

jamesgeorge007
Copy link
Member

@jamesgeorge007 jamesgeorge007 commented Mar 26, 2024

Description

Attempting to delete users who are owners of at least one team from the Admin dashboard is an action that would fail. There wasn't any feedback previously while attempting to delete users from the list view/a user via the profile view. This PR adds an error toast that will be shown during the scenarios mentioned above.

Changes

  • Show an error toast while attempting to delete users who are team owners from the list /users and profile /user/_id views.
  • Locale entry additions for the case with attempting team owner deletions.
  • Ensure the singular/plural form of the error toast message is displayed based on the no. of rows selected from the user management list view (/users page).
  • Abstract the user deletion business logic in a helper function handleUserDeletion() under helpers/userManagement.ts.
  • New getI18n() function exported from the i18n module for use outside components.
  • At least one Admin is enforced on an instance. Show a more specific error message while attempting to remove the Admin status that would lead to a scenario with no users with Admin privileges.

Closes HFE-462.

Checks

  • My pull request adheres to the code style of this project
  • All the tests have passed

Action leading to a scenario where there are no users with Admin privileges.
Copy link
Contributor

@amk-dev amk-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to show the success toast, when no user is deleted ? here we're showing a success toast "Number of deleted users 0".

Screenshare.-.2024-03-27.5_14_13.PM.mp4

- Implicitly infer the action type (bulk/individual) from the supplied deleted users list.
- Display toast messages one after the other by relying on the native toast APIs refraining from the need to maintain timeouts separately.
- Ensure the toast message about user deletion success/failure with the count is displayed only when above `0`.
- Cleanup.

Co-authored-by: amk-dev <akash.k.mohan98@gmail.com>
Co-authored-by: nivedin <nivedinp@gmail.com>
@AndrewBastin AndrewBastin merged commit 81f1e05 into hoppscotch:release/2024.3.0 Mar 28, 2024
1 check passed
@jamesgeorge007 jamesgeorge007 deleted the sh-admin-user-deletion-updates branch March 28, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants