From cd305313e42f168226ed10f933df77f58de3ea51 Mon Sep 17 00:00:00 2001 From: Tanun Turbo Chalermsinsuwan Date: Wed, 30 Sep 2026 20:40:42 +0700 Subject: [PATCH] fix(roles): Show only document-defined roles (#51087) ## Problem As part of having `None / No Access` available to customers, we need to start providing this role entry in `/platform/organization/:ref/roles` endpoint. However, when making it available, the role will show up prematurely on all the components that relies on `useOrganizationRolesV2Query` function. ## Solution This change is to allow us to test the behavior of the new role without having to turn the API on/off. The UI will show only the "predefined" entries and ignore the "extras" sent by API. After this is merged, we will do the following 1. Unhide the None role from the API https://github.com/supabase/platform/pull/39137 -- this will not have any effect on the frontend as we already ignore it in this PR 2. Work and continue testing on https://github.com/supabase/supabase/pull/50922 -- which will be easier to verify as we no longer need to change the API side ## Review instructions 1. Modify the items in the `FIXED_ROLE_ORDER` list, remove some roles from there 2. You will see that the role will disappear from the components like the invitation form or managed access form. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) ## Summary by CodeRabbit ## Summary by CodeRabbit * **Bug Fixes** * Organization role lists now show only supported roles, in the expected order. Roles outside the supported set are no longer displayed. This keeps the list consistent and focused on recognized roles, making available organization roles easier to review. --- .../data/organization-members/organization-roles-query.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/studio/data/organization-members/organization-roles-query.ts b/apps/studio/data/organization-members/organization-roles-query.ts index faa715e3451..826f3029eba 100644 --- a/apps/studio/data/organization-members/organization-roles-query.ts +++ b/apps/studio/data/organization-members/organization-roles-query.ts @@ -46,9 +46,11 @@ export const useOrganizationRolesV2Query = ( select: (data) => { return { ...data, - org_scoped_roles: [...data.org_scoped_roles].sort((a, b) => { - return FIXED_ROLE_ORDER.indexOf(a.name) - FIXED_ROLE_ORDER.indexOf(b.name) - }), + org_scoped_roles: [...data.org_scoped_roles] + .sort((a, b) => { + return FIXED_ROLE_ORDER.indexOf(a.name) - FIXED_ROLE_ORDER.indexOf(b.name) + }) + .filter((role) => FIXED_ROLE_ORDER.includes(role.name)), } as TData }, ...options,