Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix project roles not showing which project (#29462)

Joshen Lim1f0f7cb2e47c
diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/MemberRow.tsx b/apps/studio/components/interfaces/Organization/TeamSettings/MemberRow.tsx
index 45332ef9e69..dca7324f717 100644
--- a/apps/studio/components/interfaces/Organization/TeamSettings/MemberRow.tsx
+++ b/apps/studio/components/interfaces/Organization/TeamSettings/MemberRow.tsx
@@ -36,6 +36,7 @@ export const MemberRow = ({ member }: MemberRowProps) => {
slug: selectedOrganization?.slug,
})
+ const hasProjectScopedRoles = (roles?.project_scoped_roles ?? []).length > 0
const memberIsUser = member.gotrue_id == profile?.gotrue_id
const isInvitedUser = Boolean(member.invited_id)
const isEmailUser = member.username === member.primary_email
@@ -148,7 +149,7 @@ export const MemberRow = ({ member }: MemberRowProps) => {
return (
<div key={`role-${id}`} className="flex items-center gap-x-2">
<p>{roleName}</p>
- {isOptedIntoProjectLevelPermissions && (
+ {hasProjectScopedRoles && (
<>
<span>•</span>
{projectsApplied.length === 1 ? (
diff --git a/apps/studio/data/organizations/organization-payment-methods-query.ts b/apps/studio/data/organizations/organization-payment-methods-query.ts
index 610142e4668..e6350c0ff45 100644
--- a/apps/studio/data/organizations/organization-payment-methods-query.ts
+++ b/apps/studio/data/organizations/organization-payment-methods-query.ts
@@ -1,8 +1,11 @@
+import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { organizationKeys } from './keys'
-import type { ResponseError } from 'types'
-import { get, handleError } from 'data/fetchers'
+
import { components } from 'api-types'
+import { get, handleError } from 'data/fetchers'
+import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
+import type { ResponseError } from 'types'
+import { organizationKeys } from './keys'
export type OrganizationPaymentMethodsVariables = { slug?: string }
export type OrganizationPaymentMethod = components['schemas']['Payment']
@@ -40,9 +43,14 @@ export const useOrganizationPaymentMethodsQuery = <TData = OrganizationPaymentMe
enabled = true,
...options
}: UseQueryOptions<OrganizationPaymentMethodsData, OrganizationPaymentMethodsError, TData> = {}
-) =>
- useQuery<OrganizationPaymentMethodsData, OrganizationPaymentMethodsError, TData>(
+) => {
+ const canReadSubscriptions = useCheckPermissions(
+ PermissionAction.BILLING_READ,
+ 'stripe.payment_methods'
+ )
+ return useQuery<OrganizationPaymentMethodsData, OrganizationPaymentMethodsError, TData>(
organizationKeys.paymentMethods(slug),
({ signal }) => getOrganizationPaymentMethods({ slug }, signal),
- { enabled: enabled, ...options }
+ { enabled: enabled && typeof slug !== 'undefined' && canReadSubscriptions, ...options }
)
+}
diff --git a/apps/studio/data/organizations/organization-tax-id-query.ts b/apps/studio/data/organizations/organization-tax-id-query.ts
index 233dc15da4a..6f47c864250 100644
--- a/apps/studio/data/organizations/organization-tax-id-query.ts
+++ b/apps/studio/data/organizations/organization-tax-id-query.ts
@@ -1,8 +1,11 @@
+import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+
+import { components } from 'api-types'
import { get, handleError } from 'data/fetchers'
-import { organizationKeys } from './keys'
+import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import type { ResponseError } from 'types'
-import { components } from 'api-types'
+import { organizationKeys } from './keys'
export type OrganizationTaxIdVariables = {
slug?: string
@@ -36,12 +39,14 @@ export const useOrganizationTaxIdQuery = <TData = OrganizationTaxIdData>(
enabled = true,
...options
}: UseQueryOptions<OrganizationTaxIdData, OrganizationTaxIdError, TData> = {}
-) =>
- useQuery<OrganizationTaxIdData, OrganizationTaxIdError, TData>(
+) => {
+ const canReadSubscriptions = useCheckPermissions(PermissionAction.BILLING_READ, 'stripe.tax_ids')
+ return useQuery<OrganizationTaxIdData, OrganizationTaxIdError, TData>(
organizationKeys.taxId(slug),
({ signal }) => getOrganizationTaxId({ slug }, signal),
{
- enabled: enabled && typeof slug !== 'undefined',
+ enabled: enabled && typeof slug !== 'undefined' && canReadSubscriptions,
...options,
}
)
+}
diff --git a/apps/studio/data/subscriptions/org-plans-query.ts b/apps/studio/data/subscriptions/org-plans-query.ts
index edc1343c78d..77c98d2c630 100644
--- a/apps/studio/data/subscriptions/org-plans-query.ts
+++ b/apps/studio/data/subscriptions/org-plans-query.ts
@@ -1,6 +1,8 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import { get, handleError } from 'data/fetchers'
import { subscriptionKeys } from './keys'
+import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
+import { PermissionAction } from '@supabase/shared-types/out/constants'
export type OrgPlansVariables = {
orgSlug?: string
@@ -23,12 +25,18 @@ export type OrgPlansError = unknown
export const useOrgPlansQuery = <TData = OrgPlansData>(
{ orgSlug }: OrgPlansVariables,
{ enabled = true, ...options }: UseQueryOptions<OrgPlansData, OrgPlansError, TData> = {}
-) =>
- useQuery<OrgPlansData, OrgPlansError, TData>(
+) => {
+ const canReadSubscriptions = useCheckPermissions(
+ PermissionAction.BILLING_READ,
+ 'stripe.subscriptions'
+ )
+
+ return useQuery<OrgPlansData, OrgPlansError, TData>(
subscriptionKeys.orgPlans(orgSlug),
({ signal }) => getOrgPlans({ orgSlug }, signal),
{
- enabled: enabled && typeof orgSlug !== 'undefined',
+ enabled: enabled && typeof orgSlug !== 'undefined' && canReadSubscriptions,
...options,
}
)
+}