Skip to content

Conversation

maria-aluko
Copy link
Contributor

This pull request introduces a new "Add User" flow to the admin panel, allowing tenant_admins to search for users by name or email and assign them roles within their organization. It adds backend API integration for lightweight user search, updates state management in the users slice, and enhances the UI with a modal for searching and assigning users. The translations are also updated to support the new UI elements.

Add User Flow and UI Enhancements:

  • Added a modal in UsersList.tsx for admins to search for users by name/email, select a user, choose a role, and assign them to the organization. The modal includes search, role selection, assign, and close actions. [1] [2]
  • Integrated new translation keys for all add-user modal UI elements, supporting both Finnish and English.

Backend Integration and State Management:

  • Implemented getAllOrderedUsersList API method in usersApi for lightweight user search (returns only id, full_name, email) and added the corresponding thunk fetchAllOrderedUsersList in the users slice. [1] [2]
  • Extended the UserState type and users slice to store and manage the lightweight users list, including actions and selectors for clearing and accessing search results. [1] [2] [3] [4] [5]

Role Assignment Logic:

  • Added logic to resolve role IDs from the available roles catalog and assign the selected role to the chosen user, with error handling and state refresh after assignment.

Note:
This most likely needs to be changed into a separate page instead of a modal, based on the customer feedback wanting a "Request a role in an Org". Once done, it would make sense to add these requests to notifications which would lead to this page (instead of the modal). This is just a basic version of adding a user to an org created before the customer feedback.

Copy link

supabase bot commented Sep 8, 2025

This pull request has been ignored for the connected project rcbddkhvysexkvgqpcud because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@Ermegilius
Copy link
Contributor

Ermegilius commented Sep 8, 2025

There’s a mismatch with the "one role per org" logic.
As a tenant admin, I can add myself to the same org again with the "requester" role. This creates an extra entry in the table, leaving me with two active roles in the org.
At the same time, the frontend only shows the latest role (requester) on the Users tab, while on the Roles tab I can see both roles.

Things to discuss together:
Should the backend filter out users who already have any role in this org? But then it’s no longer truly a “Get All Ordered Users” list.
Should we forbid adding/replacing roles within "Add New User" feature?

@stabjana stabjana self-assigned this Sep 9, 2025
@stabjana stabjana removed their assignment Sep 9, 2025
@maria-aluko
Copy link
Contributor Author

Now we are checking whether a searched user already has any role in the currently selected organization (in frontend). Those users are rendered disabled/unselectable and visually marked with "Member" label.

@maria-aluko
Copy link
Contributor Author

I've updated the frontend with a Load More button. I've also update the user.service because the endpoint called getPaginationMeta(data.length, page, limit). Because the Supabase query did not ask for an exact count, [data.length] was just the rows returned for the current page, so [totalPages] was computed as 1 (or otherwise wrong).
So now the query is [select(..., { count: "exact" })] and used [result.count] (when available) as the total passed to getPaginationMeta. Now the true totalPages are passed and front can see that there are more pages to display (and Load More button will show).

@Ermegilius Ermegilius merged commit b650c50 into develop Sep 9, 2025
5 checks passed
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.

3 participants