Home / Function/ formatMemberRoleToProjectRoleConfiguration() — supabase Function Reference

formatMemberRoleToProjectRoleConfiguration() — supabase Function Reference

Architecture documentation for the formatMemberRoleToProjectRoleConfiguration() function in UpdateRolesPanel.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  85313509_9893_a7f1_0325_abddf0cf38b3["formatMemberRoleToProjectRoleConfiguration()"]
  08b3c701_2442_915a_319d_41013f9dc8ec["UpdateRolesConfirmationModal()"]
  08b3c701_2442_915a_319d_41013f9dc8ec -->|calls| 85313509_9893_a7f1_0325_abddf0cf38b3
  26567e94_e158_8cd1_b1e4_49300baf745f["UpdateRolesPanel()"]
  26567e94_e158_8cd1_b1e4_49300baf745f -->|calls| 85313509_9893_a7f1_0325_abddf0cf38b3
  style 85313509_9893_a7f1_0325_abddf0cf38b3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.utils.ts lines 16–56

export const formatMemberRoleToProjectRoleConfiguration = (
  member: OrganizationMember,
  allRoles: OrganizationRolesResponse
) => {
  const { org_scoped_roles, project_scoped_roles } = allRoles

  const roleConfiguration = member.role_ids
    .map((id) => {
      const orgRole = org_scoped_roles.find((role) => role.id === id)
      if (orgRole !== undefined) {
        return { ref: undefined, name: undefined, roleId: orgRole.id }
      }

      const projectRole = project_scoped_roles.find((role) => role.id === id)
      if (projectRole !== undefined) {
        return projectRole.projects.map((x) => ({
          ref: x.ref,
          name: x.name,
          roleId: projectRole.id,
          baseRoleId: projectRole.base_role_id,
        }))
      }

      return undefined
    })
    .filter(Boolean)
    .flat()
    .filter((p) => {
      // [Joshen] Validate only for project scoped roles
      // This filters out project scoped roles for projects that the user doesn't have access to
      // (e.g if the project was deleted)
      if ('baseRoleId' in p!) {
        return p.ref !== undefined
      } else {
        return p
      }
    })
    .sort((a, b) => (a?.name ?? '').localeCompare(b?.name ?? '')) as ProjectRoleConfiguration[]

  return roleConfiguration
}

Subdomains

Frequently Asked Questions

What does formatMemberRoleToProjectRoleConfiguration() do?
formatMemberRoleToProjectRoleConfiguration() is a function in the supabase codebase.
What calls formatMemberRoleToProjectRoleConfiguration()?
formatMemberRoleToProjectRoleConfiguration() is called by 2 function(s): UpdateRolesConfirmationModal, UpdateRolesPanel.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free