The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore(studio): clarify partnered orgs and projects (#44328)
Danny White1ab725106061
diff --git a/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.test.tsx b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.test.tsxnew file mode 100644index 00000000000..e3cad739f63--- /dev/null+++ b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.test.tsx@@ -0,0 +1,98 @@+import { screen } from '@testing-library/react'+import { beforeEach, describe, expect, it, vi } from 'vitest'++import PaymentMethods from './PaymentMethods'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { createMockOrganization, render } from '@/tests/helpers'++const { mockSelectedOrganization, mockPaymentMethodsQuery, mockSubscription } = vi.hoisted(() => ({+ mockSelectedOrganization: vi.fn(),+ mockPaymentMethodsQuery: vi.fn(),+ mockSubscription: vi.fn(),+}))++vi.mock('common', async (importOriginal) => {+ const original = (await importOriginal()) as typeof import('common')+ return {+ ...original,+ useParams: () => ({ slug: 'stripe-org' }),+ }+})++vi.mock('@/hooks/misc/useSelectedOrganization', () => ({+ useSelectedOrganizationQuery: () => ({ data: mockSelectedOrganization() }),+}))++vi.mock('@/data/subscriptions/org-subscription-query', () => ({+ useOrgSubscriptionQuery: () => ({ data: mockSubscription() }),+}))++vi.mock('@/data/organizations/organization-payment-methods-query', () => ({+ useOrganizationPaymentMethodsQuery: () => mockPaymentMethodsQuery(),+}))++vi.mock('@/hooks/misc/useCheckPermissions', () => ({+ useAsyncCheckPermissions: () => ({ can: true, isSuccess: true }),+}))++vi.mock('@/components/ui/PartnerManagedResource', () => ({+ default: () => <div data-testid="partner-managed-resource" />,+}))++vi.mock('@/components/interfaces/Billing/Payment/AddNewPaymentMethodModal', () => ({+ default: () => null,+}))++vi.mock('./ChangePaymentMethodModal', () => ({+ default: () => null,+}))++vi.mock('./DeletePaymentMethodModal', () => ({+ default: () => null,+}))++describe('PaymentMethods', () => {+ beforeEach(() => {+ vi.clearAllMocks()+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'stripe-org',+ billing_partner: null,+ integration_source: 'stripe_projects',+ managed_by: MANAGED_BY.STRIPE_PROJECTS,+ })+ )+ mockSubscription.mockReturnValue({+ payment_method_type: 'card',+ plan: { id: 'pro', name: 'Pro' },+ })+ mockPaymentMethodsQuery.mockReturnValue({+ data: { data: [] },+ error: null,+ isPending: false,+ isError: false,+ isSuccess: true,+ })+ })++ it('does not treat Stripe-connected orgs as partner-billed', () => {+ render(<PaymentMethods />)++ expect(screen.queryByTestId('partner-managed-resource')).not.toBeInTheDocument()+ expect(screen.getByText('No payment methods')).toBeInTheDocument()+ })++ it('still shows the partner-managed fallback for billing partners', () => {+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'aws-org',+ billing_partner: 'aws_marketplace',+ managed_by: MANAGED_BY.AWS_MARKETPLACE,+ })+ )++ render(<PaymentMethods />)++ expect(screen.getByTestId('partner-managed-resource')).toBeInTheDocument()+ })+})diff --git a/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.tsx b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.tsxindex a4e9079ac14..a620da5c932 100644--- a/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.tsx+++ b/apps/studio/components/interfaces/Billing/Payment/PaymentMethods/PaymentMethods.tsx@@ -22,11 +22,11 @@ import { FormPanel } from '@/components/ui/Forms/FormPanel'import { FormSection, FormSectionContent } from '@/components/ui/Forms/FormSection'import NoPermission from '@/components/ui/NoPermission'import PartnerManagedResource from '@/components/ui/PartnerManagedResource'+import { isPartnerBillingOrganization } from '@/data/organizations/managed-by-utils'import { useOrganizationPaymentMethodsQuery } from '@/data/organizations/organization-payment-methods-query'import { useOrgSubscriptionQuery } from '@/data/subscriptions/org-subscription-query'import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'-import { MANAGED_BY } from '@/lib/constants/infrastructure'import { getURL } from '@/lib/helpers'const PaymentMethods = () => {@@ -53,6 +53,9 @@ const PaymentMethods = () => {PermissionAction.BILLING_WRITE,'stripe.payment_methods')+ const isPartnerBilledOrganization = isPartnerBillingOrganization(+ selectedOrganization?.billing_partner+ )return (<>@@ -66,8 +69,7 @@ const PaymentMethods = () => {</div></ScaffoldSectionDetail><ScaffoldSectionContent>- {selectedOrganization?.managed_by !== undefined &&- selectedOrganization?.managed_by !== MANAGED_BY.SUPABASE ? (+ {selectedOrganization && isPartnerBilledOrganization ? (<PartnerManagedResourcemanagedBy={selectedOrganization?.managed_by}resource="Payment Methods"diff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx b/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsxindex 9aac1a022f1..c998dd7677c 100644--- a/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectCard.tsx@@ -15,7 +15,9 @@ import { inferProjectStatus } from './ProjectCard.utils'import { ProjectCardStatus } from './ProjectCardStatus'import CardButton from '@/components/ui/CardButton'import { ComputeBadgeWrapper } from '@/components/ui/ComputeBadgeWrapper'+import PartnerIcon from '@/components/ui/PartnerIcon'import type { IntegrationProjectConnection } from '@/data/integrations/integrations.types'+import { getManagedByFromOrganizationPartner } from '@/data/organizations/managed-by-utils'import { ProjectIndexPageLink } from '@/data/prefetchers/project.$ref'import { getComputeSize, OrgProject } from '@/data/projects/org-projects-infinite-query'import type { ResourceWarning } from '@/data/usage/resource-warnings-query'@@ -58,6 +60,10 @@ export const ProjectCard = ({const isGithubIntegrated = githubIntegration !== undefinedconst isVercelIntegrated = vercelIntegration !== undefinedconst githubRepository = githubIntegration?.metadata.name ?? undefined+ const projectManagedBy = getManagedByFromOrganizationPartner(+ undefined,+ project.integration_source+ )const projectStatus = inferProjectStatus(project.status)return (@@ -134,6 +140,7 @@ export const ProjectCard = ({/></div>)}+ <PartnerIcon organization={{ managed_by: projectManagedBy }} />{isGithubIntegrated && (<div className="bg-surface-100 flex items-center gap-x-0.5 h-5 pr-1 border border-strong rounded-md min-w-0"><div className="w-5 h-5 p-1 flex items-center justify-center shrink-0">diff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectIntegrationBadges.test.tsx b/apps/studio/components/interfaces/Home/ProjectList/ProjectIntegrationBadges.test.tsxnew file mode 100644index 00000000000..a88fcec7ae8--- /dev/null+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectIntegrationBadges.test.tsx@@ -0,0 +1,118 @@+import { screen } from '@testing-library/react'+import type React from 'react'+import { describe, expect, it, vi } from 'vitest'++import { ProjectCard } from './ProjectCard'+import { ProjectTableRow } from './ProjectTableRow'+import type { OrgProject } from '@/data/projects/org-projects-infinite-query'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { render } from '@/tests/helpers'++vi.mock('next/router', () => ({+ useRouter: () => ({+ push: vi.fn(),+ }),+}))++vi.mock('react-inlinesvg', () => ({+ default: () => <div data-testid="inline-svg" />,+}))++vi.mock('./ProjectCardStatus', () => ({+ ProjectCardStatus: () => <div data-testid="project-status" />,+}))++vi.mock('@/components/ui/CardButton', () => ({+ default: ({ title, footer }: { title: React.ReactNode; footer: React.ReactNode }) => (+ <div>+ <div>{title}</div>+ <div>{footer}</div>+ </div>+ ),+}))++vi.mock('@/components/ui/ComputeBadgeWrapper', () => ({+ ComputeBadgeWrapper: () => <div data-testid="compute-badge" />,+}))++vi.mock('@/components/ui/PartnerIcon', () => ({+ default: ({ organization }: { organization: { managed_by: string } }) =>+ organization.managed_by === MANAGED_BY.SUPABASE ? null : (+ <div data-testid="partner-icon" data-managed-by={organization.managed_by} />+ ),+}))++vi.mock('@/data/prefetchers/project.$ref', () => ({+ ProjectIndexPageLink: () => null,+}))++vi.mock('@/hooks/custom-content/useCustomContent', () => ({+ useCustomContent: () => ({ infraAwsNimbusLabel: 'AWS Nimbus' }),+}))++vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({+ useIsFeatureEnabled: () => ({ projectHomepageShowInstanceSize: false }),+}))++vi.mock('@/lib/navigation', () => ({+ createNavigationHandler: () => vi.fn(),+}))++function createOrgProject(overrides: Partial<OrgProject> = {}): OrgProject {+ return {+ ref: 'proj_1',+ name: 'Hammer',+ status: 'ACTIVE_HEALTHY',+ cloud_provider: 'AWS',+ region: 'us-east-1',+ inserted_at: '2026-04-09T06:36:14.718416',+ is_branch: false,+ integration_source: null,+ databases: [],+ ...overrides,+ } as OrgProject+}++describe('project integration badges', () => {+ it('renders a Stripe badge on project cards from project integration_source', () => {+ render(<ProjectCard project={createOrgProject({ integration_source: 'stripe_projects' })} />)++ expect(screen.getByTestId('partner-icon')).toHaveAttribute(+ 'data-managed-by',+ MANAGED_BY.STRIPE_PROJECTS+ )+ })++ it('does not render a Stripe badge on project cards without project integration_source', () => {+ render(<ProjectCard project={createOrgProject()} />)++ expect(screen.queryByTestId('partner-icon')).toBeNull()+ })++ it('renders a Stripe badge on project table rows without requiring Vercel or GitHub integrations', () => {+ render(+ <table>+ <tbody>+ <ProjectTableRow project={createOrgProject({ integration_source: 'stripe_projects' })} />+ </tbody>+ </table>+ )++ expect(screen.getByTestId('partner-icon')).toHaveAttribute(+ 'data-managed-by',+ MANAGED_BY.STRIPE_PROJECTS+ )+ })++ it('does not render a Stripe badge on project table rows without project integration_source', () => {+ render(+ <table>+ <tbody>+ <ProjectTableRow project={createOrgProject()} />+ </tbody>+ </table>+ )++ expect(screen.queryByTestId('partner-icon')).toBeNull()+ })+})diff --git a/apps/studio/components/interfaces/Home/ProjectList/ProjectTableRow.tsx b/apps/studio/components/interfaces/Home/ProjectList/ProjectTableRow.tsxindex 7affa6b144d..47eedd01027 100644--- a/apps/studio/components/interfaces/Home/ProjectList/ProjectTableRow.tsx+++ b/apps/studio/components/interfaces/Home/ProjectList/ProjectTableRow.tsx@@ -18,10 +18,13 @@ import { TimestampInfo } from 'ui-patterns'import { inferProjectStatus } from './ProjectCard.utils'import { ProjectCardStatus } from './ProjectCardStatus'import { ComputeBadgeWrapper } from '@/components/ui/ComputeBadgeWrapper'+import PartnerIcon from '@/components/ui/PartnerIcon'import type { IntegrationProjectConnection } from '@/data/integrations/integrations.types'+import { getManagedByFromOrganizationPartner } from '@/data/organizations/managed-by-utils'import { getComputeSize, OrgProject } from '@/data/projects/org-projects-infinite-query'import type { ResourceWarning } from '@/data/usage/resource-warnings-query'import { BASE_PATH } from '@/lib/constants'+import { MANAGED_BY } from '@/lib/constants/infrastructure'import { createNavigationHandler } from '@/lib/navigation'import type { Organization } from '@/types'@@ -51,6 +54,11 @@ export const ProjectTableRow = ({const isGithubIntegrated = githubIntegration !== undefinedconst isVercelIntegrated = vercelIntegration !== undefinedconst githubRepository = githubIntegration?.metadata.name ?? undefined+ const projectManagedBy = getManagedByFromOrganizationPartner(+ undefined,+ project.integration_source+ )+ const hasPartnerIcon = projectManagedBy !== MANAGED_BY.SUPABASEconst handleNavigation = createNavigationHandler(url, router)const handleCopyProjectRef = (e: React.SyntheticEvent) => {@@ -97,7 +105,7 @@ export const ProjectTableRow = ({)}</button></div>- {(isGithubIntegrated || isVercelIntegrated) && (+ {(isGithubIntegrated || isVercelIntegrated || hasPartnerIcon) && (<div className="flex items-center gap-x-1.5">{isVercelIntegrated && (<div className="bg-surface-100 w-5 h-5 p-1 border border-strong rounded-md flex items-center text-black dark:text-white">@@ -108,6 +116,7 @@ export const ProjectTableRow = ({/></div>)}+ <PartnerIcon organization={{ managed_by: projectManagedBy }} />{isGithubIntegrated && (<div className="bg-surface-100 flex items-center gap-x-0.5 h-5 pr-1 border border-strong rounded-md"><div className="w-5 h-5 p-1 flex items-center">diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.test.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.test.tsxnew file mode 100644index 00000000000..6daad6986aa--- /dev/null+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.test.tsx@@ -0,0 +1,137 @@+import { screen } from '@testing-library/react'+import type { ReactNode } from 'react'+import { beforeEach, describe, expect, it, vi } from 'vitest'++import { BillingCustomerData } from './BillingCustomerData'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { createMockOrganization, render } from '@/tests/helpers'++const mockSelectedOrganization = vi.hoisted(() => vi.fn())++vi.mock('common', async (importOriginal) => {+ const original = (await importOriginal()) as typeof import('common')+ return {+ ...original,+ useParams: () => ({ slug: 'stripe-org' }),+ }+})++vi.mock('next-themes', () => ({+ useTheme: () => ({ resolvedTheme: 'dark' }),+}))++vi.mock('@stripe/react-stripe-js', () => ({+ Elements: ({ children }: { children: ReactNode }) => <div>{children}</div>,+}))++vi.mock('@stripe/stripe-js', () => ({+ loadStripe: vi.fn(() => Promise.resolve(null)),+}))++vi.mock('ui', async (importOriginal) => {+ const original = (await importOriginal()) as typeof import('ui')+ return {+ ...original,+ Form_Shadcn_: ({ children }: { children: ReactNode }) => <div>{children}</div>,+ }+})++vi.mock('@/hooks/misc/useSelectedOrganization', () => ({+ useSelectedOrganizationQuery: () => ({ data: mockSelectedOrganization() }),+}))++vi.mock('@/hooks/misc/useCheckPermissions', () => ({+ useAsyncCheckPermissions: () => ({ can: true, isSuccess: true }),+}))++vi.mock('@/data/organizations/organization-customer-profile-query', () => ({+ useOrganizationCustomerProfileQuery: () => ({+ data: {+ address: {+ line1: '',+ line2: '',+ city: '',+ state: '',+ postal_code: '',+ country: 'US',+ },+ billing_name: 'Toolshed',+ },+ error: null,+ isPending: false,+ isSuccess: true,+ }),+}))++vi.mock('@/data/organizations/organization-tax-id-query', () => ({+ useOrganizationTaxIdQuery: () => ({+ data: null,+ error: null,+ isPending: false,+ isSuccess: true,+ }),+}))++vi.mock('@/data/organizations/organization-customer-profile-update-mutation', () => ({+ useOrganizationCustomerProfileUpdateMutation: () => ({+ mutateAsync: vi.fn(),+ }),+}))++vi.mock('./useBillingCustomerDataForm', () => ({+ useBillingCustomerDataForm: () => ({+ form: {},+ handleSubmit: vi.fn(),+ handleReset: vi.fn(),+ isDirty: false,+ resetKey: 0,+ onAddressChange: vi.fn(),+ applyAddressElementValue: vi.fn(),+ markCurrentValuesAsSaved: vi.fn(),+ addressCountry: 'US',+ addressOptions: {},+ }),+}))++vi.mock('./BillingCustomerDataForm', () => ({+ BillingCustomerDataForm: () => <div data-testid="billing-customer-data-form" />,+}))++vi.mock('@/components/ui/PartnerManagedResource', () => ({+ default: () => <div data-testid="partner-managed-resource" />,+}))++describe('BillingCustomerData', () => {+ beforeEach(() => {+ vi.clearAllMocks()+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'stripe-org',+ billing_partner: null,+ integration_source: 'stripe_projects',+ managed_by: MANAGED_BY.STRIPE_PROJECTS,+ })+ )+ })++ it('keeps Stripe-connected orgs editable in Studio', () => {+ render(<BillingCustomerData />)++ expect(screen.queryByTestId('partner-managed-resource')).not.toBeInTheDocument()+ expect(screen.getByTestId('billing-customer-data-form')).toBeInTheDocument()+ })++ it('still blocks billing-partner orgs behind the partner-managed resource', () => {+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'vercel-org',+ billing_partner: 'vercel_marketplace',+ managed_by: MANAGED_BY.VERCEL_MARKETPLACE,+ })+ )++ render(<BillingCustomerData />)++ expect(screen.getByTestId('partner-managed-resource')).toBeInTheDocument()+ })+})diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.tsxindex 696139b4fb8..406defb7c40 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/BillingCustomerData/BillingCustomerData.tsx@@ -24,6 +24,7 @@ import AlertError from '@/components/ui/AlertError'import NoPermission from '@/components/ui/NoPermission'import PartnerManagedResource from '@/components/ui/PartnerManagedResource'import { organizationKeys } from '@/data/organizations/keys'+import { isPartnerBillingOrganization } from '@/data/organizations/managed-by-utils'import { useOrganizationCustomerProfileQuery } from '@/data/organizations/organization-customer-profile-query'import { useOrganizationCustomerProfileUpdateMutation } from '@/data/organizations/organization-customer-profile-update-mutation'import { useOrganizationTaxIdQuery } from '@/data/organizations/organization-tax-id-query'@@ -159,6 +160,9 @@ export const BillingCustomerData = () => {}) as any,[resolvedTheme])+ const isPartnerBilledOrganization = isPartnerBillingOrganization(+ selectedOrganization?.billing_partner+ )return (<ScaffoldSection>@@ -174,8 +178,7 @@ export const BillingCustomerData = () => {</div></ScaffoldSectionDetail><ScaffoldSectionContent>- {selectedOrganization?.managed_by !== undefined &&- selectedOrganization?.managed_by !== 'supabase' ? (+ {selectedOrganization && isPartnerBilledOrganization ? (<PartnerManagedResourcemanagedBy={selectedOrganization?.managed_by}resource="Billing Addresses"diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsxnew file mode 100644index 00000000000..aed47f6cc38--- /dev/null+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.test.tsx@@ -0,0 +1,149 @@+import { screen } from '@testing-library/react'+import { beforeEach, describe, expect, it, vi } from 'vitest'++import { PlanUpdateSidePanel } from './PlanUpdateSidePanel'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { createMockOrganization, render } from '@/tests/helpers'++const mockSelectedOrganization = vi.hoisted(() => vi.fn())+const mockPush = vi.hoisted(() => vi.fn())++vi.mock('common', async (importOriginal) => {+ const original = (await importOriginal()) as typeof import('common')+ return {+ ...original,+ useParams: () => ({ slug: 'stripe-org' }),+ }+})++vi.mock('next/router', () => ({+ useRouter: () => ({+ pathname: '/org/[slug]/billing',+ query: {},+ push: mockPush,+ }),+}))++vi.mock('shared-data/plans', () => ({+ plans: [+ { id: 'tier_free', planId: 'free', name: 'Free', costUnit: '/ month', features: [] },+ { id: 'tier_pro', planId: 'pro', name: 'Pro', costUnit: '/ month', features: [] },+ ],+}))++vi.mock('@/hooks/misc/useSelectedOrganization', () => ({+ useSelectedOrganizationQuery: () => ({ data: mockSelectedOrganization() }),+}))++vi.mock('@/data/telemetry/send-event-mutation', () => ({+ useSendEventMutation: () => ({ mutate: vi.fn() }),+}))++vi.mock('@/hooks/misc/useCheckPermissions', () => ({+ useAsyncCheckPermissions: () => ({ can: true }),+}))++vi.mock('@/state/organization-settings', () => ({+ useOrgSettingsPageStateSnapshot: () => ({+ panelKey: 'subscriptionPlan',+ setPanelKey: vi.fn(),+ }),+}))++vi.mock('@/data/projects/org-projects-infinite-query', () => ({+ useOrgProjectsInfiniteQuery: () => ({ data: undefined }),+}))++vi.mock('@/data/organizations/free-project-limit-check-query', () => ({+ useFreeProjectLimitCheckQuery: () => ({ data: [] }),+}))++vi.mock('@/data/organizations/organization-query', () => ({+ useOrganizationQuery: () => ({ data: { has_oriole_project: false } }),+}))++vi.mock('@/data/subscriptions/org-subscription-query', () => ({+ useOrgSubscriptionQuery: () => ({+ data: { plan: { id: 'free', name: 'Free' } },+ isSuccess: true,+ }),+}))++vi.mock('@/data/subscriptions/org-plans-query', () => ({+ useOrgPlansQuery: () => ({+ data: {+ plans: [+ { id: 'free', price: 0 },+ { id: 'pro', price: 25 },+ ],+ },+ isPending: false,+ }),+}))++vi.mock('@/data/organizations/organization-billing-subscription-preview', () => ({+ useOrganizationBillingSubscriptionPreview: () => ({}),+}))++vi.mock('@/components/ui/PartnerManagedResource', () => ({+ default: () => <div data-testid="partner-managed-resource" />,+}))++vi.mock('./EnterpriseCard', () => ({+ EnterpriseCard: () => <div>Enterprise</div>,+}))++vi.mock('./DowngradeModal', () => ({+ default: () => null,+}))++vi.mock('./ExitSurveyModal', () => ({+ ExitSurveyModal: () => null,+}))++vi.mock('./UpgradeModal', () => ({+ default: () => null,+}))++vi.mock('./MembersExceedLimitModal', () => ({+ default: () => null,+}))++vi.mock('./SubscriptionPlanUpdateDialog', () => ({+ SubscriptionPlanUpdateDialog: () => null,+}))++describe('PlanUpdateSidePanel', () => {+ beforeEach(() => {+ vi.clearAllMocks()+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'stripe-org',+ billing_partner: null,+ integration_source: 'stripe_projects',+ managed_by: MANAGED_BY.STRIPE_PROJECTS,+ })+ )+ })++ it('does not treat Stripe-connected orgs as partner-billed', () => {+ render(<PlanUpdateSidePanel />)++ expect(screen.queryByTestId('partner-managed-resource')).not.toBeInTheDocument()+ expect(screen.getByRole('button', { name: 'Upgrade to Pro' })).toBeInTheDocument()+ })++ it('still shows partner-managed messaging for billing-partner orgs', () => {+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'aws-org',+ billing_partner: 'aws_marketplace',+ managed_by: MANAGED_BY.AWS_MARKETPLACE,+ })+ )++ render(<PlanUpdateSidePanel />)++ expect(screen.getByTestId('partner-managed-resource')).toBeInTheDocument()+ })+})diff --git a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsxindex 9ff2d65d99f..95f4548f3aa 100644--- a/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx+++ b/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/PlanUpdateSidePanel.tsx@@ -21,6 +21,7 @@ import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import PartnerManagedResource from '@/components/ui/PartnerManagedResource'import { RequestUpgradeToBillingOwners } from '@/components/ui/RequestUpgradeToBillingOwners'import { useFreeProjectLimitCheckQuery } from '@/data/organizations/free-project-limit-check-query'+import { isPartnerBillingOrganization } from '@/data/organizations/managed-by-utils'import { useOrganizationBillingSubscriptionPreview } from '@/data/organizations/organization-billing-subscription-preview'import { useOrganizationQuery } from '@/data/organizations/organization-query'import type { CustomerAddress, CustomerTaxId } from '@/data/organizations/types'@@ -55,6 +56,9 @@ export const PlanUpdateSidePanel = () => {const router = useRouter()const { slug } = useParams()const { data: selectedOrganization } = useSelectedOrganizationQuery()+ const isPartnerBilledOrganization = isPartnerBillingOrganization(+ selectedOrganization?.billing_partner+ )const { mutate: sendEvent } = useSendEventMutation()const originalPlanRef = useRef<string>()@@ -204,7 +208,7 @@ export const PlanUpdateSidePanel = () => {</div>}>- {selectedOrganization && selectedOrganization.managed_by !== MANAGED_BY.SUPABASE && (+ {selectedOrganization && isPartnerBilledOrganization && (<PartnerManagedResourcemanagedBy={selectedOrganization.managed_by}resource="Organization plans"@@ -282,8 +286,7 @@ export const PlanUpdateSidePanel = () => {subscription?.plan?.id === 'enterprise' ||subscription?.plan?.id === 'platform' ||// Downgrades to free are still allowed through the dashboard given we have much better control about showing customers the impact + any possible issues with downgrading to free- (selectedOrganization?.managed_by !== MANAGED_BY.SUPABASE &&- plan.id !== 'tier_free') ||+ (isPartnerBilledOrganization && plan.id !== 'tier_free') ||// Orgs managed by AWS marketplace are not allowed to change the planselectedOrganization?.managed_by === MANAGED_BY.AWS_MARKETPLACE ||hasOrioleProjectsdiff --git a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.test.tsx b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.test.tsxnew file mode 100644index 00000000000..2c9d8d58344--- /dev/null+++ b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.test.tsx@@ -0,0 +1,78 @@+import { screen } from '@testing-library/react'+import { beforeEach, describe, expect, it, vi } from 'vitest'++import { InvoicesSettings } from './InvoicesSettings'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { createMockOrganization, render } from '@/tests/helpers'++const { mockSelectedOrganization, mockInvoicesQuery, mockInvoicesCountQuery } = vi.hoisted(() => ({+ mockSelectedOrganization: vi.fn(),+ mockInvoicesQuery: vi.fn(),+ mockInvoicesCountQuery: vi.fn(),+}))++vi.mock('@/hooks/misc/useSelectedOrganization', () => ({+ useSelectedOrganizationQuery: () => ({ data: mockSelectedOrganization() }),+}))++vi.mock('@/data/invoices/invoices-query', () => ({+ useInvoicesQuery: () => mockInvoicesQuery(),+}))++vi.mock('@/data/invoices/invoices-count-query', () => ({+ useInvoicesCountQuery: () => mockInvoicesCountQuery(),+}))++vi.mock('@/data/invoices/invoice-query', () => ({+ getInvoice: vi.fn(),+}))++vi.mock('@/data/invoices/invoice-receipt-query', () => ({+ getInvoiceReceipt: vi.fn(),+}))++vi.mock('@/components/ui/PartnerManagedResource', () => ({+ default: () => <div data-testid="partner-managed-resource" />,+}))++describe('InvoicesSettings', () => {+ beforeEach(() => {+ vi.clearAllMocks()+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'stripe-org',+ billing_partner: null,+ integration_source: 'stripe_projects',+ managed_by: MANAGED_BY.STRIPE_PROJECTS,+ })+ )+ mockInvoicesCountQuery.mockReturnValue({ data: 0, isError: false })+ mockInvoicesQuery.mockReturnValue({+ data: [],+ error: null,+ isPending: false,+ isError: false,+ })+ })++ it('shows invoices in Studio for Stripe-connected orgs', () => {+ render(<InvoicesSettings />)++ expect(screen.queryByTestId('partner-managed-resource')).not.toBeInTheDocument()+ expect(screen.getByText('No invoices for this organization yet')).toBeInTheDocument()+ })++ it('still routes billing-partner orgs to the partner-managed resource', () => {+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'aws-org',+ billing_partner: 'aws_marketplace',+ managed_by: MANAGED_BY.AWS_MARKETPLACE,+ })+ )++ render(<InvoicesSettings />)++ expect(screen.getByTestId('partner-managed-resource')).toBeInTheDocument()+ })+})diff --git a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsxindex 53c704ed012..d9fb42c249f 100644--- a/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx+++ b/apps/studio/components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx@@ -26,6 +26,7 @@ import { getInvoice } from '@/data/invoices/invoice-query'import { getInvoiceReceipt } from '@/data/invoices/invoice-receipt-query'import { useInvoicesCountQuery } from '@/data/invoices/invoices-count-query'import { useInvoicesQuery } from '@/data/invoices/invoices-query'+import { isPartnerBillingOrganization } from '@/data/organizations/managed-by-utils'import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'import { MANAGED_BY } from '@/lib/constants/infrastructure'import { formatCurrency } from '@/lib/helpers'@@ -52,13 +53,16 @@ export const InvoicesSettings = () => {const { data: selectedOrganization } = useSelectedOrganizationQuery()const slug = selectedOrganization?.slug+ const isPartnerBilledOrganization = isPartnerBillingOrganization(+ selectedOrganization?.billing_partner+ )const offset = (page - 1) * PAGE_LIMITconst { data: count, isError: isErrorCount } = useInvoicesCountQuery({slug,},- { enabled: selectedOrganization?.managed_by === 'supabase' }+ { enabled: !isPartnerBilledOrganization })const {data,@@ -71,7 +75,7 @@ export const InvoicesSettings = () => {offset,limit: PAGE_LIMIT,},- { enabled: selectedOrganization?.managed_by === 'supabase' }+ { enabled: !isPartnerBilledOrganization })const invoices = data || []@@ -99,10 +103,7 @@ export const InvoicesSettings = () => {}}- if (- selectedOrganization?.managed_by !== undefined &&- selectedOrganization?.managed_by !== 'supabase'- ) {+ if (selectedOrganization && isPartnerBilledOrganization) {return (<PartnerManagedResourcemanagedBy={selectedOrganization?.managed_by}diff --git a/apps/studio/components/layouts/AppLayout/OrganizationDropdown.test.tsx b/apps/studio/components/layouts/AppLayout/OrganizationDropdown.test.tsxnew file mode 100644index 00000000000..dbe0ed14b76--- /dev/null+++ b/apps/studio/components/layouts/AppLayout/OrganizationDropdown.test.tsx@@ -0,0 +1,75 @@+import { screen, within } from '@testing-library/react'+import { beforeEach, describe, expect, it, vi } from 'vitest'++import { OrganizationDropdown } from './OrganizationDropdown'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { createMockOrganization, render } from '@/tests/helpers'++const { mockUseIsFeatureEnabled, mockUseOrganizationsQuery, mockUseSelectedOrganizationQuery } =+ vi.hoisted(() => ({+ mockUseIsFeatureEnabled: vi.fn(),+ mockUseOrganizationsQuery: vi.fn(),+ mockUseSelectedOrganizationQuery: vi.fn(),+ }))++vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({+ useIsFeatureEnabled: mockUseIsFeatureEnabled,+}))++vi.mock('@/data/organizations/organizations-query', () => ({+ useOrganizationsQuery: mockUseOrganizationsQuery,+}))++vi.mock('@/hooks/misc/useSelectedOrganization', () => ({+ useSelectedOrganizationQuery: mockUseSelectedOrganizationQuery,+}))++vi.mock('@/components/ui/PartnerIcon', () => ({+ default: ({ organization }: { organization: { managed_by: string } }) =>+ organization.managed_by === MANAGED_BY.SUPABASE ? null : <div data-testid="partner-icon" />,+}))++describe('OrganizationDropdown', () => {+ beforeEach(() => {+ vi.clearAllMocks()+ mockUseIsFeatureEnabled.mockReturnValue(false)+ mockUseOrganizationsQuery.mockReturnValue({+ data: [+ createMockOrganization({ slug: 'org-one', name: 'Org One' }),+ createMockOrganization({ slug: 'org-two', name: 'Org Two' }),+ ],+ isPending: false,+ isError: false,+ })+ })++ it('renders partner icon in selected organization area for managed organizations', () => {+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ slug: 'org-one',+ name: 'Org One',+ managed_by: MANAGED_BY.AWS_MARKETPLACE,+ }),+ })++ render(<OrganizationDropdown />)++ const selectedLink = screen.getByRole('link', { name: /org one/i })+ expect(within(selectedLink).getByTestId('partner-icon')).toBeInTheDocument()+ })++ it('does not render partner icon in selected organization area for Supabase-managed orgs', () => {+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ slug: 'org-one',+ name: 'Org One',+ managed_by: MANAGED_BY.SUPABASE,+ }),+ })++ render(<OrganizationDropdown />)++ const selectedLink = screen.getByRole('link', { name: /org one/i })+ expect(within(selectedLink).queryByTestId('partner-icon')).toBeNull()+ })+})diff --git a/apps/studio/components/layouts/AppLayout/OrganizationDropdown.tsx b/apps/studio/components/layouts/AppLayout/OrganizationDropdown.tsxindex 3376b079bc4..834b95a6576 100644--- a/apps/studio/components/layouts/AppLayout/OrganizationDropdown.tsx+++ b/apps/studio/components/layouts/AppLayout/OrganizationDropdown.tsx@@ -8,6 +8,7 @@ import { GenericSkeletonLoader, ShimmeringLoader } from 'ui-patterns'import { AppLayoutDropdownError, AppLayoutDropdownWithPopover } from './AppLayoutDropdown'import { OrganizationDropdownCommandContent } from './OrganizationDropdownCommandContent'import { useEmbeddedCloseHandler } from './useEmbeddedCloseHandler'+import PartnerIcon from '@/components/ui/PartnerIcon'import { useOrganizationsQuery } from '@/data/organizations/organizations-query'import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'@@ -75,6 +76,7 @@ export const OrganizationDropdown = ({>{orgName ?? 'Select an organization'}</span>+ {!!selectedOrganization && <PartnerIcon organization={selectedOrganization} />}{!!selectedOrganization && (<Badge variant="default">{selectedOrganization?.plan.name}</Badge>)}diff --git a/apps/studio/components/layouts/AppLayout/ProjectDropdown.test.tsx b/apps/studio/components/layouts/AppLayout/ProjectDropdown.test.tsxnew file mode 100644index 00000000000..667e6ab3a20--- /dev/null+++ b/apps/studio/components/layouts/AppLayout/ProjectDropdown.test.tsx@@ -0,0 +1,169 @@+import { screen } from '@testing-library/react'+import { beforeEach, describe, expect, it, vi } from 'vitest'++import { ProjectDropdown } from './ProjectDropdown'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { createMockOrganization, render } from '@/tests/helpers'++const { mockSelectedOrganization, mockSelectedProject, mockSelectorProject } = vi.hoisted(() => ({+ mockSelectedOrganization: vi.fn(),+ mockSelectedProject: vi.fn(),+ mockSelectorProject: vi.fn(),+}))++const mockPush = vi.hoisted(() => vi.fn())++vi.mock('common', async (importOriginal) => {+ const original = (await importOriginal()) as typeof import('common')+ return {+ ...original,+ useParams: () => ({ ref: 'proj_1' }),+ }+})++vi.mock('next/router', () => ({+ useRouter: () => ({+ route: '/project/[ref]/settings',+ query: { ref: 'proj_1' },+ push: mockPush,+ }),+}))++vi.mock('@/lib/constants', async (importOriginal) => {+ const original = (await importOriginal()) as typeof import('@/lib/constants')+ return { ...original, IS_PLATFORM: true }+})++vi.mock('@/hooks/misc/useSelectedProject', () => ({+ useSelectedProjectQuery: () => ({+ data: mockSelectedProject(),+ isPending: false,+ }),+}))++vi.mock('@/data/projects/project-detail-query', () => ({+ useProjectDetailQuery: () => ({ data: undefined, isPending: false }),+}))++vi.mock('@/hooks/misc/useSelectedOrganization', () => ({+ useSelectedOrganizationQuery: () => ({ data: mockSelectedOrganization() }),+}))++vi.mock('@/hooks/misc/useIsFeatureEnabled', () => ({+ useIsFeatureEnabled: () => false,+}))++vi.mock('@/components/ui/OrganizationProjectSelector', () => ({+ OrganizationProjectSelector: ({ renderRow, renderTrigger }: any) => (+ <div>+ <div data-testid="project-selector-trigger">{renderTrigger?.({})}</div>+ <div data-testid="project-selector-row">{renderRow?.(mockSelectorProject())}</div>+ </div>+ ),+}))++vi.mock('@/components/ui/PartnerIcon', () => ({+ default: ({ organization }: { organization: { managed_by: string } }) =>+ organization.managed_by === MANAGED_BY.SUPABASE ? null : (+ <div data-testid="partner-icon" data-managed-by={organization.managed_by} />+ ),+}))++describe('ProjectDropdown', () => {+ beforeEach(() => {+ vi.clearAllMocks()+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'supabase-org',+ managed_by: MANAGED_BY.SUPABASE,+ })+ )+ mockSelectedProject.mockReturnValue({+ ref: 'proj_1',+ name: 'Hammer',+ parentRef: 'proj_1',+ parent_project_ref: undefined,+ integration_source: 'stripe_projects',+ })+ mockSelectorProject.mockReturnValue({+ ref: 'proj_1',+ name: 'Hammer',+ status: 'ACTIVE_HEALTHY',+ integration_source: 'stripe_projects',+ })+ })++ it('uses project detail integration_source for the selected pill and project row data for selector rows', () => {+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'stripe-org',+ billing_partner: null,+ integration_source: 'stripe_projects',+ managed_by: MANAGED_BY.STRIPE_PROJECTS,+ })+ )++ render(<ProjectDropdown />)++ expect(screen.getAllByTestId('partner-icon')).toHaveLength(2)+ })++ it('does not fall back to org-level integration state when matching project data is unavailable', () => {+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'stripe-org',+ billing_partner: null,+ integration_source: 'stripe_projects',+ managed_by: MANAGED_BY.STRIPE_PROJECTS,+ })+ )+ mockSelectedProject.mockReturnValue({+ ref: 'proj_2',+ name: 'Mallet',+ parentRef: 'proj_2',+ parent_project_ref: undefined,+ integration_source: null,+ })+ mockSelectorProject.mockReturnValue({+ ref: 'proj_2',+ name: 'Mallet',+ status: 'ACTIVE_HEALTHY',+ integration_source: null,+ })++ render(<ProjectDropdown />)++ expect(screen.queryAllByTestId('partner-icon')).toHaveLength(0)+ })++ it('falls back to the organization-level state for partner-billed orgs', () => {+ mockSelectedOrganization.mockReturnValue(+ createMockOrganization({+ slug: 'partner-org',+ billing_partner: 'vercel_marketplace',+ managed_by: MANAGED_BY.VERCEL_MARKETPLACE,+ })+ )+ mockSelectedProject.mockReturnValue({+ ref: 'proj_2',+ name: 'Mallet',+ parentRef: 'proj_2',+ parent_project_ref: undefined,+ integration_source: null,+ })+ mockSelectorProject.mockReturnValue({+ ref: 'proj_2',+ name: 'Mallet',+ status: 'ACTIVE_HEALTHY',+ integration_source: null,+ })++ render(<ProjectDropdown />)++ expect(screen.getAllByTestId('partner-icon')).toHaveLength(1)+ expect(screen.getByTestId('partner-icon')).toHaveAttribute(+ 'data-managed-by',+ MANAGED_BY.VERCEL_MARKETPLACE+ )+ })+})diff --git a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsxindex 51ef8a43ccd..097b9fe8c50 100644--- a/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx+++ b/apps/studio/components/layouts/AppLayout/ProjectDropdown.tsx@@ -12,11 +12,15 @@ import { sanitizeRoute } from './ProjectDropdown.utils'import { ProjectRowLink } from './ProjectRowLink'import { useEmbeddedCloseHandler } from './useEmbeddedCloseHandler'import { OrganizationProjectSelector } from '@/components/ui/OrganizationProjectSelector'+import PartnerIcon from '@/components/ui/PartnerIcon'+import { getManagedByFromOrganizationPartner } from '@/data/organizations/managed-by-utils'+import type { OrgProject } from '@/data/projects/org-projects-infinite-query'import { useProjectDetailQuery } from '@/data/projects/project-detail-query'import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'import { IS_PLATFORM } from '@/lib/constants'+import type { ManagedBy } from '@/lib/constants/infrastructure'// --- Sub-components ---@@ -79,6 +83,7 @@ function ProjectDropdownNonPlatformView({ projectName }: { projectName: string }interface ProjectDropdownPlatformViewProps {projectRef: string | undefinedprojectName: string+ projectManagedBy?: ManagedByselectorProps: Omit<ComponentProps<typeof OrganizationProjectSelector>,'renderTrigger' | 'embedded'@@ -88,6 +93,7 @@ interface ProjectDropdownPlatformViewProps {function ProjectDropdownPlatformView({projectRef,projectName,+ projectManagedBy,selectorProps,}: ProjectDropdownPlatformViewProps) {return (@@ -100,6 +106,7 @@ function ProjectDropdownPlatformView({<span title={projectName} className="text-foreground max-w-32 lg:max-w-64 truncate">{projectName}</span>+ {projectManagedBy && <PartnerIcon organization={{ managed_by: projectManagedBy }} />}</Link><OrganizationProjectSelector@@ -139,6 +146,11 @@ export const ProjectDropdown = ({const [open, setOpen] = useState(false)const close = useEmbeddedCloseHandler(embedded, onClose, setOpen)+ const selectedProjectManagedBy = selectedProject?.integration_source+ ? getManagedByFromOrganizationPartner(undefined, selectedProject.integration_source)+ : selectedOrganization?.billing_partner+ ? selectedOrganization.managed_by+ : undefinedif (isLoadingProject || (isBranch && isLoadingParentProject) || !selectedProject) {if (!embedded) return <ShimmeringLoader className="p-2 md:mr-2 md:w-[90px]" />@@ -156,7 +168,7 @@ export const ProjectDropdown = ({close()router.push(href)},- renderRow: (project: { ref: string; name: string; status?: string }) => (+ renderRow: (project: Pick<OrgProject, 'ref' | 'name' | 'status' | 'integration_source'>) => (<ProjectRowLinkproject={project}selectedRef={ref}@@ -184,6 +196,7 @@ export const ProjectDropdown = ({<ProjectDropdownPlatformViewprojectRef={project?.ref}projectName={selectedProject?.name ?? ''}+ projectManagedBy={selectedProjectManagedBy}selectorProps={selectorProps}/>) : (diff --git a/apps/studio/components/layouts/AppLayout/ProjectRowLink.tsx b/apps/studio/components/layouts/AppLayout/ProjectRowLink.tsxindex 8d6c8d78058..67d0fee67aa 100644--- a/apps/studio/components/layouts/AppLayout/ProjectRowLink.tsx+++ b/apps/studio/components/layouts/AppLayout/ProjectRowLink.tsx@@ -4,9 +4,16 @@ import Link from 'next/link'import { Badge, cn } from 'ui'import { sanitizeRoute } from './ProjectDropdown.utils'+import PartnerIcon from '@/components/ui/PartnerIcon'+import { getManagedByFromOrganizationPartner } from '@/data/organizations/managed-by-utils'export interface ProjectRowLinkProps {- project: { ref: string; name: string; status?: string }+ project: {+ ref: string+ name: string+ status?: string+ integration_source?: string | null+ }selectedRef: string | undefinedroute: stringrouterQueries: ParsedUrlQuery@@ -22,15 +29,22 @@ export function ProjectRowLink({const href = sanitizedRoute?.replace('[ref]', project.ref) ?? `/project/${project.ref}`const isSelected = project.ref === selectedRefconst isPaused = project.status === 'INACTIVE'+ const managedBy = getManagedByFromOrganizationPartner(undefined, project.integration_source)return (<Linkhref={href}className="w-full flex items-center justify-between p-0.5 md:p-0 text-sm md:text-xs">- <span className={cn('truncate', isSelected ? 'md:max-w-60' : 'md:max-w-64')}>- {project.name}+ <span+ className={cn(+ 'flex items-center gap-2 min-w-0',+ isSelected ? 'md:max-w-60' : 'md:max-w-64'+ )}+ >+ <span className="truncate">{project.name}</span>{isPaused && <Badge className="ml-2">Paused</Badge>}+ <PartnerIcon organization={{ managed_by: managedBy }} /></span>{isSelected && <Check size={16} />}</Link>diff --git a/apps/studio/components/layouts/OrganizationLayout.test.tsx b/apps/studio/components/layouts/OrganizationLayout.test.tsxnew file mode 100644index 00000000000..47efaf2c794--- /dev/null+++ b/apps/studio/components/layouts/OrganizationLayout.test.tsx@@ -0,0 +1,272 @@+import { fireEvent, screen } from '@testing-library/react'+import { LOCAL_STORAGE_KEYS } from 'common'+import { beforeEach, describe, expect, it, vi } from 'vitest'++import OrganizationLayout from './OrganizationLayout'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { createMockOrganization, render } from '@/tests/helpers'++const {+ mockUseAwsRedirectQuery,+ mockUseCustomContent,+ mockUseLocalStorageQuery,+ mockSetIsBannerDismissed,+ mockUseRegisterOrgMenu,+ mockUseSelectedOrganizationQuery,+ mockUseVercelRedirectQuery,+} = vi.hoisted(() => ({+ mockUseAwsRedirectQuery: vi.fn(),+ mockUseCustomContent: vi.fn(),+ mockUseLocalStorageQuery: vi.fn(),+ mockSetIsBannerDismissed: vi.fn(),+ mockUseRegisterOrgMenu: vi.fn(),+ mockUseSelectedOrganizationQuery: vi.fn(),+ mockUseVercelRedirectQuery: vi.fn(),+}))++vi.mock('@/hooks/misc/useSelectedOrganization', () => ({+ useSelectedOrganizationQuery: mockUseSelectedOrganizationQuery,+}))++vi.mock('@/data/integrations/vercel-redirect-query', () => ({+ useVercelRedirectQuery: mockUseVercelRedirectQuery,+}))++vi.mock('@/data/integrations/aws-redirect-query', () => ({+ useAwsRedirectQuery: mockUseAwsRedirectQuery,+}))++vi.mock('@/hooks/misc/useLocalStorage', () => ({+ useLocalStorageQuery: mockUseLocalStorageQuery,+}))++vi.mock('@/hooks/custom-content/useCustomContent', () => ({+ useCustomContent: mockUseCustomContent,+}))++vi.mock('@/hooks/misc/withAuth', () => ({+ withAuth: (Component: any) => Component,+}))++vi.mock('./OrganizationLayout/useRegisterOrgMenu', () => ({+ useRegisterOrgMenu: mockUseRegisterOrgMenu,+}))++vi.mock('@/components/ui/PartnerIcon', () => ({+ default: () => <div data-testid="partner-icon" />,+}))++const renderLayout = () =>+ render(+ <OrganizationLayout title="General">+ <div>Organization content</div>+ </OrganizationLayout>+ )++describe('OrganizationLayout', () => {+ beforeEach(() => {+ vi.clearAllMocks()++ mockUseLocalStorageQuery.mockReturnValue([+ false,+ mockSetIsBannerDismissed,+ { isSuccess: true, isLoading: false, isError: false, error: null },+ ])+ mockUseCustomContent.mockReturnValue({ appTitle: 'Supabase' })+ mockUseVercelRedirectQuery.mockReturnValue({ data: undefined, isSuccess: false })+ mockUseAwsRedirectQuery.mockReturnValue({ data: undefined, isSuccess: false })+ })++ it('renders the exact Vercel banner copy and manage URL', () => {+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ managed_by: MANAGED_BY.VERCEL_MARKETPLACE,+ partner_id: 'vercel-installation-id',+ }),+ })+ mockUseVercelRedirectQuery.mockReturnValue({+ data: { url: 'https://vercel.com/manage-org' },+ isSuccess: true,+ })++ renderLayout()++ expect(screen.getByText('This organization is managed via Vercel Marketplace')).toBeTruthy()+ expect(+ screen.getByText('Billing and some organization access settings are managed in Vercel.')+ ).toBeTruthy()+ expect(screen.getByRole('link', { name: 'Manage' }).getAttribute('href')).toBe(+ 'https://vercel.com/manage-org'+ )+ expect(mockUseVercelRedirectQuery).toHaveBeenCalledWith(+ { installationId: 'vercel-installation-id' },+ expect.objectContaining({ enabled: true })+ )+ expect(mockUseLocalStorageQuery).toHaveBeenCalledWith(+ LOCAL_STORAGE_KEYS.ORGANIZATION_MARKETPLACE_BANNER_DISMISSED(+ 'abcdefghijklmnopqrst',+ MANAGED_BY.VERCEL_MARKETPLACE+ ),+ false+ )+ expect(mockUseAwsRedirectQuery).toHaveBeenCalledWith(+ { organizationSlug: 'abcdefghijklmnopqrst' },+ expect.objectContaining({ enabled: false })+ )+ })++ it('renders the exact AWS banner copy and manage URL', () => {+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ managed_by: MANAGED_BY.AWS_MARKETPLACE,+ slug: 'aws-org',+ }),+ })+ mockUseAwsRedirectQuery.mockReturnValue({+ data: { url: 'https://console.aws.amazon.com/billing/home' },+ isSuccess: true,+ })++ renderLayout()++ expect(screen.getByText('This organization is billed via AWS Marketplace')).toBeTruthy()+ expect(+ screen.getByText('Changes to billing and payment details must be made in AWS.')+ ).toBeTruthy()+ expect(screen.getByRole('link', { name: 'Manage' }).getAttribute('href')).toBe(+ 'https://console.aws.amazon.com/billing/home'+ )+ expect(mockUseAwsRedirectQuery).toHaveBeenCalledWith(+ { organizationSlug: 'aws-org' },+ expect.objectContaining({ enabled: true })+ )+ expect(mockUseLocalStorageQuery).toHaveBeenCalledWith(+ LOCAL_STORAGE_KEYS.ORGANIZATION_MARKETPLACE_BANNER_DISMISSED(+ 'aws-org',+ MANAGED_BY.AWS_MARKETPLACE+ ),+ false+ )+ expect(mockUseVercelRedirectQuery).toHaveBeenCalledWith(+ { installationId: undefined },+ expect.objectContaining({ enabled: false })+ )+ })++ it('does not render Manage for Vercel when redirect URL is unavailable', () => {+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ managed_by: MANAGED_BY.VERCEL_MARKETPLACE,+ partner_id: 'vercel-installation-id',+ }),+ })+ mockUseVercelRedirectQuery.mockReturnValue({+ data: undefined,+ isSuccess: false,+ })++ renderLayout()++ expect(screen.getByText('This organization is managed via Vercel Marketplace')).toBeTruthy()+ expect(screen.queryByRole('link', { name: 'Manage' })).toBeNull()+ })++ it('does not render Manage for AWS when redirect URL is unavailable', () => {+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ managed_by: MANAGED_BY.AWS_MARKETPLACE,+ slug: 'aws-org',+ }),+ })+ mockUseAwsRedirectQuery.mockReturnValue({+ data: undefined,+ isSuccess: false,+ })++ renderLayout()++ expect(screen.getByText('This organization is billed via AWS Marketplace')).toBeTruthy()+ expect(screen.queryByRole('link', { name: 'Manage' })).toBeNull()+ })++ it('does not render a banner for Supabase-managed organizations', () => {+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ managed_by: MANAGED_BY.SUPABASE,+ }),+ })++ renderLayout()++ expect(screen.queryByRole('link', { name: 'Manage' })).toBeNull()+ expect(screen.queryByText('This organization is managed via Vercel Marketplace')).toBeNull()+ expect(screen.queryByText('This organization is billed via AWS Marketplace')).toBeNull()+ })++ it('renders Stripe connected copy with no Manage button', () => {+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ managed_by: MANAGED_BY.STRIPE_PROJECTS,+ }),+ })++ renderLayout()++ expect(screen.getByText('This organization is connected to Stripe')).toBeTruthy()+ expect(+ screen.getByText('Changes here will be reflected in your connected Stripe account.')+ ).toBeTruthy()+ expect(screen.queryByRole('link', { name: 'Manage' })).toBeNull()+ expect(mockUseVercelRedirectQuery).toHaveBeenCalledWith(+ { installationId: undefined },+ expect.objectContaining({ enabled: false })+ )+ expect(mockUseLocalStorageQuery).toHaveBeenCalledWith(+ LOCAL_STORAGE_KEYS.ORGANIZATION_MARKETPLACE_BANNER_DISMISSED(+ 'abcdefghijklmnopqrst',+ MANAGED_BY.STRIPE_PROJECTS+ ),+ false+ )+ expect(mockUseAwsRedirectQuery).toHaveBeenCalledWith(+ { organizationSlug: 'abcdefghijklmnopqrst' },+ expect.objectContaining({ enabled: false })+ )+ })++ it('hides banner when dismissal state is persisted', () => {+ mockUseLocalStorageQuery.mockReturnValue([+ true,+ mockSetIsBannerDismissed,+ { isSuccess: true, isLoading: false, isError: false, error: null },+ ])+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ managed_by: MANAGED_BY.VERCEL_MARKETPLACE,+ partner_id: 'vercel-installation-id',+ }),+ })++ renderLayout()++ expect(screen.queryByRole('link', { name: 'Manage' })).toBeNull()+ expect(screen.queryByText('This organization is managed via Vercel Marketplace')).toBeNull()+ })++ it('dismisses the banner and persists the state', () => {+ mockUseSelectedOrganizationQuery.mockReturnValue({+ data: createMockOrganization({+ managed_by: MANAGED_BY.AWS_MARKETPLACE,+ }),+ })+ mockUseAwsRedirectQuery.mockReturnValue({+ data: { url: 'https://console.aws.amazon.com/billing/home' },+ isSuccess: true,+ })++ renderLayout()++ fireEvent.click(screen.getByRole('button', { name: 'Dismiss banner' }))+ expect(mockSetIsBannerDismissed).toHaveBeenCalledWith(true)+ })+})diff --git a/apps/studio/components/layouts/OrganizationLayout.tsx b/apps/studio/components/layouts/OrganizationLayout.tsxindex d18a4542268..4bbe856227f 100644--- a/apps/studio/components/layouts/OrganizationLayout.tsx+++ b/apps/studio/components/layouts/OrganizationLayout.tsx@@ -1,15 +1,18 @@-import { ExternalLink } from 'lucide-react'+import { LOCAL_STORAGE_KEYS } from 'common'+import { ExternalLink, XIcon } from 'lucide-react'import Head from 'next/head'import { useRouter } from 'next/router'import type { PropsWithChildren } from 'react'-import { Alert_Shadcn_, AlertTitle_Shadcn_, Button, cn } from 'ui'+import { Alert_Shadcn_, AlertDescription_Shadcn_, AlertTitle_Shadcn_, Button, cn } from 'ui'import { useRegisterOrgMenu } from './OrganizationLayout/useRegisterOrgMenu'+import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import PartnerIcon from '@/components/ui/PartnerIcon'import { PARTNER_TO_NAME } from '@/components/ui/PartnerManagedResource'import { useAwsRedirectQuery } from '@/data/integrations/aws-redirect-query'import { useVercelRedirectQuery } from '@/data/integrations/vercel-redirect-query'import { useCustomContent } from '@/hooks/custom-content/useCustomContent'+import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'import { withAuth } from '@/hooks/misc/withAuth'import { MANAGED_BY } from '@/lib/constants/infrastructure'@@ -22,6 +25,64 @@ interface OrganizationLayoutProps {// [Joshen] Just for page title generation for org settings pagesconst settingsPages = ['general', 'security', 'sso', 'apps', 'audit', 'documents']+type MarketplaceBannerRedirectSource = 'vercel' | 'aws'++type MarketplaceBannerConfig = {+ title: string+ description: string+ redirectSource?: MarketplaceBannerRedirectSource+}++const MARKETPLACE_BANNER_CONFIG: Record<+ | typeof MANAGED_BY.VERCEL_MARKETPLACE+ | typeof MANAGED_BY.AWS_MARKETPLACE+ | typeof MANAGED_BY.STRIPE_PROJECTS,+ MarketplaceBannerConfig+> = {+ [MANAGED_BY.VERCEL_MARKETPLACE]: {+ title: 'This organization is managed via Vercel Marketplace',+ description: 'Billing and some organization access settings are managed in Vercel.',+ redirectSource: 'vercel',+ },+ [MANAGED_BY.AWS_MARKETPLACE]: {+ title: 'This organization is billed via AWS Marketplace',+ description: 'Changes to billing and payment details must be made in AWS.',+ redirectSource: 'aws',+ },+ [MANAGED_BY.STRIPE_PROJECTS]: {+ title: 'This organization is connected to Stripe',+ description: 'Changes here will be reflected in your connected Stripe account.',+ },+}++const DEFAULT_ORGANIZATION_MARKETPLACE_BANNER_DISMISS_KEY =+ LOCAL_STORAGE_KEYS.ORGANIZATION_MARKETPLACE_BANNER_DISMISSED('unknown', MANAGED_BY.SUPABASE)++function getMarketplaceBannerDismissKey({+ organizationSlug,+ managedBy,+}: {+ organizationSlug?: string+ managedBy?: string+}) {+ if (!organizationSlug || !managedBy) return DEFAULT_ORGANIZATION_MARKETPLACE_BANNER_DISMISS_KEY++ return LOCAL_STORAGE_KEYS.ORGANIZATION_MARKETPLACE_BANNER_DISMISSED(organizationSlug, managedBy)+}++function getMarketplaceBannerConfig(managedBy?: string): MarketplaceBannerConfig | undefined {+ switch (managedBy) {+ case MANAGED_BY.VERCEL_MARKETPLACE:+ return MARKETPLACE_BANNER_CONFIG[MANAGED_BY.VERCEL_MARKETPLACE]+ case MANAGED_BY.AWS_MARKETPLACE:+ return MARKETPLACE_BANNER_CONFIG[MANAGED_BY.AWS_MARKETPLACE]+ case MANAGED_BY.STRIPE_PROJECTS:+ return MARKETPLACE_BANNER_CONFIG[MANAGED_BY.STRIPE_PROJECTS]+ default:+ return undefined+ }+}+const OrganizationLayoutContent = ({children,title,@@ -29,6 +90,13 @@ const OrganizationLayoutContent = ({const router = useRouter()const { data: selectedOrganization } = useSelectedOrganizationQuery()const { appTitle } = useCustomContent(['app:title'])+ const [isBannerDismissed, setIsBannerDismissed] = useLocalStorageQuery<boolean>(+ getMarketplaceBannerDismissKey({+ organizationSlug: selectedOrganization?.slug,+ managedBy: selectedOrganization?.managed_by,+ }),+ false+ )// Keep title intent close to each page (getLayout) to avoid route-to-title drift in this layout.const isSettingsSurface = settingsPages.some((x) => router.pathname.endsWith(x))@@ -49,9 +117,20 @@ const OrganizationLayoutContent = ({{ enabled: selectedOrganization?.managed_by === MANAGED_BY.AWS_MARKETPLACE })- // Select the appropriate query based on partner- const { data, isSuccess } =- selectedOrganization?.managed_by === MANAGED_BY.AWS_MARKETPLACE ? awsQuery : vercelQuery+ const bannerConfig = getMarketplaceBannerConfig(selectedOrganization?.managed_by)++ const selectedRedirectQuery = (() => {+ if (!bannerConfig?.redirectSource) return undefined++ switch (bannerConfig.redirectSource) {+ case 'aws':+ return awsQuery+ case 'vercel':+ return vercelQuery+ default:+ return undefined+ }+ })()return (<div className={cn('h-full w-full flex flex-col overflow-hidden')}>@@ -61,20 +140,33 @@ const OrganizationLayoutContent = ({<meta name="description" content="Supabase Studio" /></Head>)}- {selectedOrganization && selectedOrganization?.managed_by !== 'supabase' && (+ {selectedOrganization && bannerConfig && !isBannerDismissed && (<Alert_Shadcn_variant="default"className="flex items-center gap-4 border-t-0 border-x-0 rounded-none"><PartnerIcon organization={selectedOrganization} showTooltip={false} size="medium" />- <AlertTitle_Shadcn_ className="flex-1">- This organization is managed by {PARTNER_TO_NAME[selectedOrganization.managed_by]}.- </AlertTitle_Shadcn_>- <Button asChild type="default" iconRight={<ExternalLink />} disabled={!isSuccess}>- <a href={data?.url} target="_blank" rel="noopener noreferrer">- Manage- </a>- </Button>+ <div className="flex-1">+ <AlertTitle_Shadcn_>{bannerConfig.title}</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>{bannerConfig.description}</AlertDescription_Shadcn_>+ </div>+ <div className="flex items-center gap-2">+ {selectedRedirectQuery?.data?.url && (+ <Button asChild type="default" iconRight={<ExternalLink />}>+ <a href={selectedRedirectQuery.data.url} target="_blank" rel="noopener noreferrer">+ Manage+ </a>+ </Button>+ )}+ <ButtonTooltip+ type="text"+ icon={<XIcon size={14} />}+ className="h-7 w-7 p-0"+ onClick={() => setIsBannerDismissed(true)}+ aria-label="Dismiss banner"+ tooltip={{ content: { text: 'Dismiss' } }}+ />+ </div></Alert_Shadcn_>)}<main className="h-full w-full overflow-y-auto flex flex-col">{children}</main>diff --git a/apps/studio/components/layouts/ProjectLayout/index.test.tsx b/apps/studio/components/layouts/ProjectLayout/index.test.tsxindex d65edfe1d73..c9405d79e0c 100644--- a/apps/studio/components/layouts/ProjectLayout/index.test.tsx+++ b/apps/studio/components/layouts/ProjectLayout/index.test.tsx@@ -1,4 +1,5 @@-import { render, waitFor } from '@testing-library/react'+import { render, screen, waitFor } from '@testing-library/react'+import { LOCAL_STORAGE_KEYS } from 'common'import type { ReactNode } from 'react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'@@ -23,6 +24,7 @@ const {mockProjectState,mockResourceWarningsState,mockBannerDismissedState,+ mockUseLocalStorageQuery,} = vi.hoisted(() => ({mockAddBanner: vi.fn(),mockDismissBanner: vi.fn(),@@ -33,10 +35,12 @@ const {status: 'ACTIVE_HEALTHY',postgrestStatus: 'ONLINE',infra_compute_size: undefined as string | undefined,+ integration_source: null as string | null,},},mockResourceWarningsState: { current: undefined as any[] | undefined },mockBannerDismissedState: { current: false },+ mockUseLocalStorageQuery: vi.fn(),}))vi.mock('next/router', () => ({@@ -73,6 +77,8 @@ vi.mock('common', () => ({LOCAL_STORAGE_KEYS: {FREE_MICRO_UPGRADE_BANNER_DISMISSED: (ref: string) =>`free-micro-upgrade-banner-dismissed-${ref}`,+ PROJECT_INTEGRATION_BANNER_DISMISSED: (ref: string, integrationSource: string) =>+ `project-integration-banner-dismissed-${ref}-${integrationSource}`,},isFeatureEnabled: () => false,}))@@ -87,6 +93,9 @@ vi.mock('framer-motion', () => ({vi.mock('ui', () => ({cn: (...classes: Array<string | false | null | undefined>) => classes.filter(Boolean).join(' '),+ Alert_Shadcn_: ({ children, ...props }: any) => <div {...props}>{children}</div>,+ AlertDescription_Shadcn_: ({ children, ...props }: any) => <div {...props}>{children}</div>,+ AlertTitle_Shadcn_: ({ children, ...props }: any) => <div {...props}>{children}</div>,CommandInput_Shadcn_: { displayName: 'CommandInput' },Command_Shadcn_: { displayName: 'Command' },CommandGroup_Shadcn_: { displayName: 'CommandGroup' },@@ -144,13 +153,19 @@ vi.mock('@/components/interfaces/ProjectAPIDocs/ProjectAPIDocs', () => ({vi.mock('@/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner', () => ({ResourceExhaustionWarningBanner: () => null,}))+vi.mock('@/components/ui/ButtonTooltip', () => ({+ ButtonTooltip: ({ children, ...props }: any) => <button {...props}>{children}</button>,+}))+vi.mock('@/components/ui/PartnerIcon', () => ({+ default: () => <div data-testid="partner-icon" />,+}))vi.mock('@/hooks/custom-content/useCustomContent', () => ({useCustomContent: () => ({ appTitle: 'Supabase' }),}))vi.mock('@/hooks/misc/useLocalStorage', () => ({- useLocalStorageQuery: () => [mockBannerDismissedState.current, vi.fn()],+ useLocalStorageQuery: (...args: unknown[]) => mockUseLocalStorageQuery(...args),}))vi.mock('@/components/ui/BannerStack/BannerStackProvider', () => ({@@ -216,6 +231,16 @@ describe('ProjectLayout title', () => {mockRouter.pathname = '/project/[ref]/observability/query-performance'mockRouter.asPath = '/project/default/observability/query-performance'document.title = ''+ mockProjectState.current = {+ ref: 'default',+ name: 'Project 1',+ status: 'ACTIVE_HEALTHY',+ postgrestStatus: 'ONLINE',+ infra_compute_size: undefined,+ integration_source: null,+ }+ mockBannerDismissedState.current = false+ mockUseLocalStorageQuery.mockImplementation(() => [mockBannerDismissedState.current, vi.fn()])})afterEach(() => {@@ -260,6 +285,35 @@ describe('ProjectLayout title', () => {)})})++ it('renders the Stripe project banner across project surfaces when the selected project is Stripe-connected', () => {+ mockProjectState.current = {+ ...mockProjectState.current,+ integration_source: 'stripe_projects',+ }++ renderLayout()++ expect(screen.getByText('This project is connected to Stripe')).toBeTruthy()+ expect(+ screen.getByText('Changes made here may affect your connected Stripe project.')+ ).toBeTruthy()+ expect(screen.getByTestId('partner-icon')).toBeTruthy()+ })++ it('uses a project-specific dismiss key for the Stripe project banner', () => {+ mockProjectState.current = {+ ...mockProjectState.current,+ integration_source: 'stripe_projects',+ }++ renderLayout()++ expect(mockUseLocalStorageQuery).toHaveBeenCalledWith(+ LOCAL_STORAGE_KEYS.PROJECT_INTEGRATION_BANNER_DISMISSED('default', 'stripe_projects'),+ false+ )+ })})describe('FREE_MICRO_UPGRADE banner', () => {@@ -272,6 +326,7 @@ describe('FREE_MICRO_UPGRADE banner', () => {status: 'ACTIVE_HEALTHY',postgrestStatus: 'ONLINE',infra_compute_size: 'nano',+ integration_source: null,}mockResourceWarningsState.current = [{@@ -294,6 +349,7 @@ describe('FREE_MICRO_UPGRADE banner', () => {status: 'ACTIVE_HEALTHY',postgrestStatus: 'ONLINE',infra_compute_size: undefined,+ integration_source: null,}mockResourceWarningsState.current = undefinedmockBannerDismissedState.current = falsediff --git a/apps/studio/components/layouts/ProjectLayout/index.tsx b/apps/studio/components/layouts/ProjectLayout/index.tsxindex 10f2ad0ced4..c9547a6ab8d 100644--- a/apps/studio/components/layouts/ProjectLayout/index.tsx+++ b/apps/studio/components/layouts/ProjectLayout/index.tsx@@ -1,5 +1,6 @@import { LOCAL_STORAGE_KEYS, mergeRefs, useParams } from 'common'import { AnimatePresence, motion } from 'framer-motion'+import { XIcon } from 'lucide-react'import Head from 'next/head'import { useRouter } from 'next/router'import {@@ -11,6 +12,9 @@ import {type ReactNode,} from 'react'import {+ Alert_Shadcn_,+ AlertDescription_Shadcn_,+ AlertTitle_Shadcn_,cn,LogoLoader,ResizableHandle,@@ -41,6 +45,8 @@ import { CreateBranchModal } from '@/components/interfaces/BranchManagement/Creaimport { ProjectAPIDocs } from '@/components/interfaces/ProjectAPIDocs/ProjectAPIDocs'import { BannerFreeMicroUpgrade } from '@/components/ui/BannerStack/Banners/BannerFreeMicroUpgrade'import { BANNER_ID, useBannerStack } from '@/components/ui/BannerStack/BannerStackProvider'+import { ButtonTooltip } from '@/components/ui/ButtonTooltip'+import PartnerIcon from '@/components/ui/PartnerIcon'import { ResourceExhaustionWarningBanner } from '@/components/ui/ResourceExhaustionWarningBanner/ResourceExhaustionWarningBanner'import { useResourceWarningsQuery } from '@/data/usage/resource-warnings-query'import { useCustomContent } from '@/hooks/custom-content/useCustomContent'@@ -49,6 +55,7 @@ import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganizatiimport { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'import { withAuth } from '@/hooks/misc/withAuth'import { PROJECT_STATUS } from '@/lib/constants'+import { MANAGED_BY } from '@/lib/constants/infrastructure'import { buildStudioPageTitle } from '@/lib/page-title'import { getPathnameWithoutQuery } from '@/lib/pathname.utils'import { useAppStateSnapshot } from '@/state/app-state'@@ -80,6 +87,21 @@ const routesToIgnorePostgrestConnection = ['/project/[ref]/reports',]+const DEFAULT_PROJECT_INTEGRATION_BANNER_DISMISS_KEY =+ LOCAL_STORAGE_KEYS.PROJECT_INTEGRATION_BANNER_DISMISSED('unknown', 'unknown')++function getProjectIntegrationBannerDismissKey({+ projectRef,+ integrationSource,+}: {+ projectRef?: string+ integrationSource?: string | null+}) {+ if (!projectRef || !integrationSource) return DEFAULT_PROJECT_INTEGRATION_BANNER_DISMISS_KEY++ return LOCAL_STORAGE_KEYS.PROJECT_INTEGRATION_BANNER_DISMISSED(projectRef, integrationSource)+}+export interface ProjectLayoutProps {isLoading?: booleanisBlocking?: boolean@@ -133,6 +155,14 @@ export const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<ProjecLOCAL_STORAGE_KEYS.FREE_MICRO_UPGRADE_BANNER_DISMISSED(selectedProject?.ref ?? ''),false)+ const [isProjectIntegrationBannerDismissed, setIsProjectIntegrationBannerDismissed] =+ useLocalStorageQuery(+ getProjectIntegrationBannerDismissKey({+ projectRef: selectedProject?.ref,+ integrationSource: selectedProject?.integration_source,+ }),+ false+ )const { showSidebar } = useAppStateSnapshot()const { setContent: setMobileSheetContent, registerOpenMenu } = useMobileSheet()@@ -175,6 +205,9 @@ export const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<Projecrouter.pathname.includes('/project/[ref]/functions') ||router.pathname.includes('/project/[ref]/logs')const showPausedState = isPaused && !ignorePausedState+ const showStripeProjectBanner =+ selectedProject?.integration_source === 'stripe_projects' &&+ !isProjectIntegrationBannerDismisseduseEffect(() => {if (!selectedProject?.ref) return@@ -265,6 +298,32 @@ export const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<ProjecclassName="h-full flex flex-col flex-1 w-full overflow-y-auto overflow-x-hidden @container"ref={combinedRef}>+ {showStripeProjectBanner && (+ <Alert_Shadcn_+ variant="default"+ className="flex items-center gap-4 border-t-0 border-x-0 rounded-none"+ >+ <PartnerIcon+ organization={{ managed_by: MANAGED_BY.STRIPE_PROJECTS }}+ showTooltip={false}+ size="medium"+ />+ <div className="flex-1">+ <AlertTitle_Shadcn_>This project is connected to Stripe</AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ Changes made here may affect your connected Stripe project.+ </AlertDescription_Shadcn_>+ </div>+ <ButtonTooltip+ type="text"+ icon={<XIcon size={14} />}+ className="h-7 w-7 p-0"+ onClick={() => setIsProjectIntegrationBannerDismissed(true)}+ aria-label="Dismiss project integration banner"+ tooltip={{ content: { text: 'Dismiss' } }}+ />+ </Alert_Shadcn_>+ )}{showPausedState ? (<div className="mx-auto my-16 w-full h-full max-w-7xl flex items-center px-4"><div className="w-full">diff --git a/apps/studio/components/ui/PartnerIcon.test.ts b/apps/studio/components/ui/PartnerIcon.test.tsnew file mode 100644index 00000000000..649e1af91b4--- /dev/null+++ b/apps/studio/components/ui/PartnerIcon.test.ts@@ -0,0 +1,50 @@+import { describe, expect, it } from 'vitest'++import PartnerIcon, { getDefaultPartnerTooltipText, getPartnerTooltipText } from './PartnerIcon'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { render } from '@/tests/helpers'+import type { Organization } from '@/types'++describe('PartnerIcon tooltip copy', () => {+ it('returns provider-specific default tooltip copy for AWS, Vercel, and Stripe', () => {+ expect(getDefaultPartnerTooltipText(MANAGED_BY.VERCEL_MARKETPLACE)).toBe(+ 'Managed via Vercel Marketplace'+ )+ expect(getDefaultPartnerTooltipText(MANAGED_BY.AWS_MARKETPLACE)).toBe(+ 'Billed via AWS Marketplace'+ )+ expect(getDefaultPartnerTooltipText(MANAGED_BY.STRIPE_PROJECTS)).toBe('Connected to Stripe')+ })++ it('uses custom tooltip text when provided', () => {+ expect(+ getPartnerTooltipText({+ managedBy: MANAGED_BY.VERCEL_MARKETPLACE,+ tooltipText: 'Managed by Vercel Marketplace.',+ })+ ).toBe('Managed by Vercel Marketplace.')+ })++ it('falls back to default tooltip text when custom tooltip is not provided', () => {+ expect(+ getPartnerTooltipText({+ managedBy: MANAGED_BY.AWS_MARKETPLACE,+ })+ ).toBe('Billed via AWS Marketplace')+ })++ it('renders an icon element for Stripe organizations', () => {+ const organization = {+ managed_by: MANAGED_BY.STRIPE_PROJECTS,+ } as Pick<Organization, 'managed_by'>++ const { container } = render(+ PartnerIcon({+ organization,+ showTooltip: false,+ })+ )++ expect(container.querySelector('svg')).toBeTruthy()+ })+})diff --git a/apps/studio/components/ui/PartnerIcon.tsx b/apps/studio/components/ui/PartnerIcon.tsxindex cbe9018a207..697ae4c2b3d 100644--- a/apps/studio/components/ui/PartnerIcon.tsx+++ b/apps/studio/components/ui/PartnerIcon.tsx@@ -11,6 +11,31 @@ interface PartnerIconProps {size?: 'small' | 'medium' | 'large'}+export function getDefaultPartnerTooltipText(+ managedBy: Pick<Organization, 'managed_by'>['managed_by']+) {+ switch (managedBy) {+ case MANAGED_BY.VERCEL_MARKETPLACE:+ return 'Managed via Vercel Marketplace'+ case MANAGED_BY.AWS_MARKETPLACE:+ return 'Billed via AWS Marketplace'+ case MANAGED_BY.STRIPE_PROJECTS:+ return 'Connected to Stripe'+ default:+ return `Managed by ${PARTNER_TO_NAME[managedBy]}`+ }+}++export function getPartnerTooltipText({+ managedBy,+ tooltipText,+}: {+ managedBy: Pick<Organization, 'managed_by'>['managed_by']+ tooltipText?: string+}) {+ return tooltipText ?? getDefaultPartnerTooltipText(managedBy)+}+function getPartnerIcon(organization: Pick<Organization, 'managed_by'>,size: 'small' | 'medium' | 'large'@@ -35,15 +60,15 @@ function getPartnerIcon(return (<svgclassName={cn(- size === 'small' && 'w-2.5 h-2.5',- size === 'medium' && 'w-3.5 h-3.5',- size === 'large' && 'w-5 h-5'+ size === 'small' && 'w-3.5 h-3.5',+ size === 'medium' && 'w-5 h-5',+ size === 'large' && 'w-6 h-6')}- viewBox="0 0 16 16"+ viewBox="0 0 20 20"fill="none"xmlns="http://www.w3.org/2000/svg">- <g fill="hsl(var(--foreground-default) / 1)">+ <g fill="hsl(var(--foreground-default) / 1)" transform="scale(1.25)"><path d="M4.51 7.687c0 .197.02.357.058.475.042.117.096.245.17.384a.233.233 0 01.037.123c0 .053-.032.107-.1.16l-.336.224a.255.255 0 01-.138.048c-.054 0-.107-.026-.16-.074a1.652 1.652 0 01-.192-.251 4.137 4.137 0 01-.164-.315c-.416.491-.937.737-1.565.737-.447 0-.804-.129-1.064-.385-.261-.256-.394-.598-.394-1.025 0-.454.16-.822.484-1.1.325-.278.756-.416 1.304-.416.18 0 .367.016.564.042.197.027.4.07.612.118v-.39c0-.406-.085-.689-.25-.854-.17-.166-.458-.246-.868-.246-.186 0-.377.022-.574.07a4.23 4.23 0 00-.575.181 1.525 1.525 0 01-.186.07.326.326 0 01-.085.016c-.075 0-.112-.054-.112-.166v-.262c0-.085.01-.15.037-.186a.399.399 0 01.15-.113c.185-.096.409-.176.67-.24.26-.07.537-.101.83-.101.633 0 1.096.144 1.394.432.293.288.442.726.442 1.314v1.73h.01zm-2.161.811c.175 0 .356-.032.548-.096.192-.064.362-.182.505-.342a.848.848 0 00.181-.341c.032-.129.054-.283.054-.465V7.03a4.43 4.43 0 00-.49-.09 3.996 3.996 0 00-.5-.033c-.357 0-.617.07-.793.214-.176.144-.26.347-.26.614 0 .25.063.437.196.566.128.133.314.197.559.197zm4.273.577c-.096 0-.16-.016-.202-.054-.043-.032-.08-.106-.112-.208l-1.25-4.127a.938.938 0 01-.048-.214c0-.085.042-.133.127-.133h.522c.1 0 .17.016.207.053.043.032.075.107.107.208l.894 3.535.83-3.535c.026-.106.058-.176.101-.208a.365.365 0 01.213-.053h.426c.1 0 .17.016.212.053.043.032.08.107.102.208l.84 3.578.92-3.578a.459.459 0 01.107-.208.347.347 0 01.208-.053h.495c.085 0 .133.043.133.133 0 .027-.006.054-.01.086a.768.768 0 01-.038.133l-1.283 4.127c-.031.107-.069.177-.111.209a.34.34 0 01-.203.053h-.457c-.101 0-.17-.016-.213-.053-.043-.038-.08-.107-.101-.214L8.213 5.37l-.82 3.439c-.026.107-.058.176-.1.213-.043.038-.118.054-.213.054h-.458zm6.838.144a3.51 3.51 0 01-.82-.096c-.266-.064-.473-.134-.612-.214-.085-.048-.143-.101-.165-.15a.38.38 0 01-.031-.149v-.272c0-.112.042-.166.122-.166a.3.3 0 01.096.016c.032.011.08.032.133.054.18.08.378.144.585.187.213.042.42.064.633.064.336 0 .596-.059.777-.176a.575.575 0 00.277-.508.52.52 0 00-.144-.373c-.095-.102-.276-.193-.537-.278l-.772-.24c-.388-.123-.676-.305-.851-.545a1.275 1.275 0 01-.266-.774c0-.224.048-.422.143-.593.096-.17.224-.32.384-.438.16-.122.34-.213.553-.277.213-.064.436-.091.67-.091.118 0 .24.005.357.021.122.016.234.038.346.06.106.026.208.052.303.085.096.032.17.064.224.096a.461.461 0 01.16.133.289.289 0 01.047.176v.251c0 .112-.042.171-.122.171a.552.552 0 01-.202-.064 2.428 2.428 0 00-1.022-.208c-.303 0-.543.048-.708.15-.165.1-.25.256-.25.475 0 .149.053.277.16.379.106.101.303.202.585.293l.756.24c.383.123.66.294.825.513.165.219.244.47.244.748 0 .23-.047.437-.138.619a1.435 1.435 0 01-.388.47c-.165.133-.362.23-.591.299-.24.075-.49.112-.761.112z" /><path@@ -60,6 +85,28 @@ function getPartnerIcon(</g></svg>)+ case MANAGED_BY.STRIPE_PROJECTS:+ return (+ <svg+ className={cn(+ size === 'small' && 'h-5 w-5',+ size === 'medium' && 'w-7 h-7',+ size === 'large' && 'w-10 h-10'+ )}+ viewBox="0 0 24 24"+ fill="none"+ xmlns="http://www.w3.org/2000/svg"+ >+ <rect width="24" height="24" fill="#533AFD" />+ <path+ fillRule="evenodd"+ clipRule="evenodd"+ d="M5.625 18.375L18.375 15.6711V5.625L5.625 8.36048V18.375Z"+ fill="white"+ transform="translate(12 12) scale(0.82) translate(-12 -12)"+ />+ </svg>+ )default:return null}@@ -73,7 +120,8 @@ function PartnerIcon({}: PartnerIconProps) {if (organization.managed_by === MANAGED_BY.VERCEL_MARKETPLACE ||- organization.managed_by === MANAGED_BY.AWS_MARKETPLACE+ organization.managed_by === MANAGED_BY.AWS_MARKETPLACE ||+ organization.managed_by === MANAGED_BY.STRIPE_PROJECTS) {const icon = getPartnerIcon(organization, size)@@ -81,7 +129,7 @@ function PartnerIcon({return (<divclassName={cn(- 'bg-surface-100 dark:bg-surface-200 border rounded flex items-center justify-center flex-shrink-0',+ 'bg-surface-100 dark:bg-surface-200 border rounded-md overflow-hidden flex items-center justify-center flex-shrink-0',size === 'small' && 'h-5 w-5',size === 'medium' && 'w-7 h-7',size === 'large' && 'w-10 h-10'@@ -92,14 +140,17 @@ function PartnerIcon({)}- const defaultTooltipText = `This organization is managed by ${PARTNER_TO_NAME[organization.managed_by]}`+ const defaultTooltipText = getPartnerTooltipText({+ managedBy: organization.managed_by,+ tooltipText,+ })return (<Tooltip><TooltipTrigger asChild><divclassName={cn(- 'bg-surface-100 dark:bg-surface-200 border rounded flex items-center justify-center hover:bg-surface-400 dark:hover:bg-surface-400 hover:border-stronger flex-shrink-0',+ 'bg-surface-100 dark:bg-surface-200 border rounded-md overflow-hidden flex items-center justify-center hover:bg-surface-400 dark:hover:bg-surface-400 hover:border-stronger flex-shrink-0',size === 'small' && 'h-5 w-5',size === 'medium' && 'w-7 h-7',size === 'large' && 'w-10 h-10'@@ -108,7 +159,7 @@ function PartnerIcon({{icon}</div></TooltipTrigger>- <TooltipContent>{tooltipText ?? defaultTooltipText}</TooltipContent>+ <TooltipContent>{defaultTooltipText}</TooltipContent></Tooltip>)}diff --git a/apps/studio/components/ui/PartnerManagedResource.test.tsx b/apps/studio/components/ui/PartnerManagedResource.test.tsxnew file mode 100644index 00000000000..3ec886e332b--- /dev/null+++ b/apps/studio/components/ui/PartnerManagedResource.test.tsx@@ -0,0 +1,104 @@+import { screen } from '@testing-library/react'+import { beforeEach, describe, expect, it, vi } from 'vitest'++import PartnerManagedResource from './PartnerManagedResource'+import { MANAGED_BY } from '@/lib/constants/infrastructure'+import { render } from '@/tests/helpers'++const { mockUseAwsRedirectQuery, mockUseVercelRedirectQuery } = vi.hoisted(() => ({+ mockUseAwsRedirectQuery: vi.fn(),+ mockUseVercelRedirectQuery: vi.fn(),+}))++vi.mock('@/data/integrations/vercel-redirect-query', () => ({+ useVercelRedirectQuery: mockUseVercelRedirectQuery,+}))++vi.mock('@/data/integrations/aws-redirect-query', () => ({+ useAwsRedirectQuery: mockUseAwsRedirectQuery,+}))++vi.mock('./PartnerIcon', () => ({+ default: () => <div data-testid="partner-icon" />,+}))++describe('PartnerManagedResource', () => {+ beforeEach(() => {+ vi.clearAllMocks()++ mockUseVercelRedirectQuery.mockReturnValue({+ data: undefined,+ isLoading: false,+ isError: false,+ })+ mockUseAwsRedirectQuery.mockReturnValue({+ data: undefined,+ isLoading: false,+ isError: false,+ })+ })++ it('renders Stripe connected copy and never shows CTA even when cta prop exists', () => {+ render(+ <PartnerManagedResource+ managedBy={MANAGED_BY.STRIPE_PROJECTS}+ resource="Payment Methods"+ cta={{ installationId: 'vercel-installation-id', organizationSlug: 'aws-org' }}+ />+ )++ expect(screen.getByText('Payment Methods are connected to Stripe.')).toBeInTheDocument()+ expect(screen.queryByRole('link')).toBeNull()+ expect(mockUseVercelRedirectQuery).toHaveBeenCalledWith(+ { installationId: 'vercel-installation-id' },+ expect.objectContaining({ enabled: false })+ )+ expect(mockUseAwsRedirectQuery).toHaveBeenCalledWith(+ { organizationSlug: 'aws-org' },+ expect.objectContaining({ enabled: false })+ )+ })++ it('renders AWS CTA only when a redirect URL is available', () => {+ mockUseAwsRedirectQuery.mockReturnValue({+ data: { url: 'https://console.aws.amazon.com/billing/home#/' },+ isLoading: false,+ isError: false,+ })++ render(+ <PartnerManagedResource+ managedBy={MANAGED_BY.AWS_MARKETPLACE}+ resource="Invoices"+ cta={{ organizationSlug: 'aws-org', path: 'bills' }}+ />+ )++ expect(screen.getByText('Invoices are managed by AWS Marketplace.')).toBeInTheDocument()+ expect(screen.getByRole('link', { name: 'View Invoices on AWS Marketplace' })).toHaveAttribute(+ 'href',+ 'https://console.aws.amazon.com/billing/home#/bills'+ )+ })++ it('does not render Vercel CTA when redirect URL is unavailable', () => {+ mockUseVercelRedirectQuery.mockReturnValue({+ data: undefined,+ isLoading: false,+ isError: false,+ })++ render(+ <PartnerManagedResource+ managedBy={MANAGED_BY.VERCEL_MARKETPLACE}+ resource="Organization plans"+ cta={{ installationId: 'vercel-installation-id', path: '/settings' }}+ />+ )++ expect(+ screen.getByText('Organization plans are managed by Vercel Marketplace.')+ ).toBeInTheDocument()+ expect(screen.queryByRole('link', { name: /view organization plans/i })).toBeNull()+ })+})diff --git a/apps/studio/components/ui/PartnerManagedResource.tsx b/apps/studio/components/ui/PartnerManagedResource.tsxindex e319fe99a64..55822ef0ace 100644--- a/apps/studio/components/ui/PartnerManagedResource.tsx+++ b/apps/studio/components/ui/PartnerManagedResource.tsx@@ -21,11 +21,14 @@ interface PartnerManagedResourceProps {export const PARTNER_TO_NAME = {[MANAGED_BY.VERCEL_MARKETPLACE]: 'Vercel Marketplace',[MANAGED_BY.AWS_MARKETPLACE]: 'AWS Marketplace',+ [MANAGED_BY.STRIPE_PROJECTS]: 'Stripe Projects',[MANAGED_BY.SUPABASE]: 'Supabase',} as constfunction PartnerManagedResource({ managedBy, resource, cta }: PartnerManagedResourceProps) {const ctaEnabled = cta !== undefined+ const supportsRedirectCta =+ managedBy === MANAGED_BY.VERCEL_MARKETPLACE || managedBy === MANAGED_BY.AWS_MARKETPLACE// Use appropriate redirect query based on partnerconst vercelQuery = useVercelRedirectQuery(@@ -33,7 +36,7 @@ function PartnerManagedResource({ managedBy, resource, cta }: PartnerManagedResoinstallationId: cta?.installationId,},{- enabled: ctaEnabled && managedBy === MANAGED_BY.VERCEL_MARKETPLACE,+ enabled: ctaEnabled && supportsRedirectCta && managedBy === MANAGED_BY.VERCEL_MARKETPLACE,})@@ -42,29 +45,38 @@ function PartnerManagedResource({ managedBy, resource, cta }: PartnerManagedResoorganizationSlug: cta?.organizationSlug,},{- enabled: ctaEnabled && managedBy === MANAGED_BY.AWS_MARKETPLACE,+ enabled: ctaEnabled && supportsRedirectCta && managedBy === MANAGED_BY.AWS_MARKETPLACE,})if (managedBy === MANAGED_BY.SUPABASE) return null- const { data, isLoading, isError } =- managedBy === MANAGED_BY.VERCEL_MARKETPLACE ? vercelQuery : awsQuery+ const selectedRedirectQuery =+ managedBy === MANAGED_BY.VERCEL_MARKETPLACE+ ? vercelQuery+ : managedBy === MANAGED_BY.AWS_MARKETPLACE+ ? awsQuery+ : undefined- const ctaUrl = (data?.url ?? '') + (cta?.path ?? '')+ const redirectBaseUrl = selectedRedirectQuery?.data?.url+ const ctaUrl =+ cta?.overrideUrl ?? (redirectBaseUrl ? `${redirectBaseUrl}${cta?.path ?? ''}` : undefined)+ const showCta = ctaEnabled && supportsRedirectCta && Boolean(ctaUrl)+ const partnerHeading =+ managedBy === MANAGED_BY.STRIPE_PROJECTS+ ? `${resource} are connected to Stripe.`+ : `${resource} are managed by ${PARTNER_TO_NAME[managedBy]}.`return (<Alert_Shadcn_ className="flex flex-col items-center gap-y-2 border-0 rounded-none"><PartnerIcon organization={{ managed_by: managedBy }} showTooltip={false} size="large" />- <AlertTitle_Shadcn_ className="text-sm">- {resource} are managed by {PARTNER_TO_NAME[managedBy]}.- </AlertTitle_Shadcn_>+ <AlertTitle_Shadcn_ className="text-sm">{partnerHeading}</AlertTitle_Shadcn_>- {ctaEnabled && (- <Button asChild type="default" iconRight={<ExternalLink />} disabled={isLoading || isError}>- <a href={cta.overrideUrl ?? ctaUrl} target="_blank" rel="noopener noreferrer">- {cta.message || `View ${resource} on ${PARTNER_TO_NAME[managedBy]}`}+ {showCta && (+ <Button asChild type="default" iconRight={<ExternalLink />}>+ <a href={ctaUrl} target="_blank" rel="noopener noreferrer">+ {cta?.message || `View ${resource} on ${PARTNER_TO_NAME[managedBy]}`}</a></Button>)}diff --git a/apps/studio/data/jit-db-access/jit-db-access-update-mutation.ts b/apps/studio/data/jit-db-access/jit-db-access-update-mutation.tsindex d61c0e7c4f4..9d638c18285 100644--- a/apps/studio/data/jit-db-access/jit-db-access-update-mutation.ts+++ b/apps/studio/data/jit-db-access/jit-db-access-update-mutation.ts@@ -7,7 +7,7 @@ import type { ResponseError, UseCustomMutationOptions } from '@/types'type JitDbAccessUpdateVariables = {projectRef: string- requestedConfig: { state: 'enabled' | 'disabled' | 'unavailable' }+ requestedConfig: { state: 'enabled' | 'disabled' }}async function updateJitDbAccess({ projectRef, requestedConfig }: JitDbAccessUpdateVariables) {diff --git a/apps/studio/data/organizations/managed-by-utils.test.ts b/apps/studio/data/organizations/managed-by-utils.test.tsnew file mode 100644index 00000000000..18d9219bb22--- /dev/null+++ b/apps/studio/data/organizations/managed-by-utils.test.ts@@ -0,0 +1,32 @@+import { describe, expect, it } from 'vitest'++import {+ getManagedByFromOrganizationPartner,+ isPartnerBillingOrganization,+} from './managed-by-utils'+import { MANAGED_BY } from '@/lib/constants/infrastructure'++describe('managed-by-utils', () => {+ it('prefers billing_partner over integration_source when both are present', () => {+ expect(getManagedByFromOrganizationPartner('aws_marketplace', 'stripe_projects')).toBe(+ MANAGED_BY.AWS_MARKETPLACE+ )+ })++ it('maps stripe integration_source to Stripe display state', () => {+ expect(getManagedByFromOrganizationPartner(null, 'stripe_projects')).toBe(+ MANAGED_BY.STRIPE_PROJECTS+ )+ })++ it('falls back to Supabase for unknown values', () => {+ expect(getManagedByFromOrganizationPartner('unknown_partner', 'unknown_source')).toBe(+ MANAGED_BY.SUPABASE+ )+ })++ it('treats billing_partner as the billing ownership signal', () => {+ expect(isPartnerBillingOrganization('vercel_marketplace')).toBe(true)+ expect(isPartnerBillingOrganization(null)).toBe(false)+ })+})diff --git a/apps/studio/data/organizations/managed-by-utils.ts b/apps/studio/data/organizations/managed-by-utils.tsnew file mode 100644index 00000000000..44e5d6a5daf--- /dev/null+++ b/apps/studio/data/organizations/managed-by-utils.ts@@ -0,0 +1,33 @@+import { MANAGED_BY, type ManagedBy } from '@/lib/constants/infrastructure'++type OrganizationPartner = string | null | undefined+type OrganizationIntegrationSource = string | null | undefined++export function getManagedByFromOrganizationPartner(+ partner: OrganizationPartner,+ integrationSource?: OrganizationIntegrationSource+): ManagedBy {+ if (partner) {+ switch (partner) {+ case 'vercel_marketplace':+ return MANAGED_BY.VERCEL_MARKETPLACE+ case 'aws_marketplace':+ return MANAGED_BY.AWS_MARKETPLACE+ case 'stripe_projects':+ return MANAGED_BY.STRIPE_PROJECTS+ default:+ return MANAGED_BY.SUPABASE+ }+ }++ switch (integrationSource) {+ case 'stripe_projects':+ return MANAGED_BY.STRIPE_PROJECTS+ default:+ return MANAGED_BY.SUPABASE+ }+}++export function isPartnerBillingOrganization(partner: OrganizationPartner): boolean {+ return Boolean(partner)+}diff --git a/apps/studio/data/organizations/organization-mappers.test.ts b/apps/studio/data/organizations/organization-mappers.test.tsnew file mode 100644index 00000000000..39afb494e18--- /dev/null+++ b/apps/studio/data/organizations/organization-mappers.test.ts@@ -0,0 +1,84 @@+import { beforeEach, describe, expect, it, vi } from 'vitest'++vi.mock('@/data/fetchers', () => ({+ get: vi.fn(),+ handleError: vi.fn(),+}))++const { castOrganizationSlugResponseToOrganization } = await import('./organization-query')+const { castOrganizationResponseToOrganization } = await import('./organizations-query')+const { MANAGED_BY } = await import('@/lib/constants/infrastructure')++const baseOrganizationResponse = {+ billing_email: '[email protected]',+ billing_partner: null,+ id: 1,+ integration_source: null,+ is_owner: true,+ name: 'Toolshed',+ opt_in_tags: [] as string[],+ organization_missing_address: false,+ organization_missing_tax_id: false,+ organization_requires_mfa: false,+ plan: { id: 'pro' as const, name: 'Pro' },+ restriction_data: null,+ restriction_status: null,+ slug: 'toolshed',+ stripe_customer_id: 'cus_123',+ subscription_id: 'sub_123',+ usage_billing_enabled: true,+}++const baseOrganizationSlugResponse = {+ billing_email: '[email protected]',+ billing_partner: null,+ has_oriole_project: false,+ id: 1,+ integration_source: null,+ name: 'Toolshed',+ opt_in_tags: [] as string[],+ plan: { id: 'pro' as const, name: 'Pro' },+ restriction_data: null,+ restriction_status: null,+ slug: 'toolshed',+ usage_billing_enabled: true,+}++describe('organization query mappers', () => {+ beforeEach(() => {+ vi.clearAllMocks()+ })++ it('keeps billing_partner unchanged while deriving Stripe display state from integration_source', () => {+ const organization = castOrganizationResponseToOrganization({+ ...baseOrganizationResponse,+ integration_source: 'stripe_projects',+ })++ expect(organization.billing_partner).toBeNull()+ expect(organization.integration_source).toBe('stripe_projects')+ expect(organization.managed_by).toBe(MANAGED_BY.STRIPE_PROJECTS)+ })++ it('lets billing_partner win over integration_source for organization list data', () => {+ const organization = castOrganizationResponseToOrganization({+ ...baseOrganizationResponse,+ billing_partner: 'aws_marketplace',+ integration_source: 'stripe_projects',+ })++ expect(organization.billing_partner).toBe('aws_marketplace')+ expect(organization.managed_by).toBe(MANAGED_BY.AWS_MARKETPLACE)+ })++ it('derives Stripe display state for organization detail data without rewriting billing_partner', () => {+ const organization = castOrganizationSlugResponseToOrganization({+ ...baseOrganizationSlugResponse,+ integration_source: 'stripe_projects',+ })++ expect(organization.billing_partner).toBeNull()+ expect(organization.integration_source).toBe('stripe_projects')+ expect(organization.managed_by).toBe(MANAGED_BY.STRIPE_PROJECTS)+ })+})diff --git a/apps/studio/data/organizations/organization-query.ts b/apps/studio/data/organizations/organization-query.tsindex c515a22a2e6..272a50acd6c 100644--- a/apps/studio/data/organizations/organization-query.ts+++ b/apps/studio/data/organizations/organization-query.ts@@ -1,7 +1,8 @@import { QueryClient, useQuery } from '@tanstack/react-query'-import { components } from 'api-types'+import { platformComponents as components } from 'api-types'import { organizationKeys } from './keys'+import { getManagedByFromOrganizationPartner } from './managed-by-utils'import { get, handleError } from '@/data/fetchers'import type { ResponseError, UseCustomQueryOptions } from '@/types'@@ -9,13 +10,11 @@ export type OrganizationVariables = { slug?: string }export type OrganizationDetail = components['schemas']['OrganizationSlugResponse']export type OrganizationPlanID = OrganizationDetail['plan']['id']-function castOrganizationSlugResponseToOrganization(- org: components['schemas']['OrganizationSlugResponse']-) {+export function castOrganizationSlugResponseToOrganization(org: OrganizationDetail) {return {...org,billing_email: org.billing_email ?? 'Unknown',- managed_by: org.slug.startsWith('vercel_icfg_') ? 'vercel-marketplace' : 'supabase',+ managed_by: getManagedByFromOrganizationPartner(org.billing_partner, org.integration_source),partner_id: org.slug.startsWith('vercel_') ? org.slug.replace('vercel_', '') : undefined,}}diff --git a/apps/studio/data/organizations/organizations-query.ts b/apps/studio/data/organizations/organizations-query.tsindex 0837935eb2d..47fb771ae2e 100644--- a/apps/studio/data/organizations/organizations-query.ts+++ b/apps/studio/data/organizations/organizations-query.ts@@ -1,9 +1,9 @@import { QueryClient, useQuery } from '@tanstack/react-query'-import { components } from 'api-types'+import { platformComponents as components } from 'api-types'import { organizationKeys } from './keys'+import { getManagedByFromOrganizationPartner } from './managed-by-utils'import { get, handleError } from '@/data/fetchers'-import { MANAGED_BY, ManagedBy } from '@/lib/constants/infrastructure'import { useProfile } from '@/lib/profile'import type { Organization, ResponseError, UseCustomQueryOptions } from '@/types'@@ -13,22 +13,11 @@ export function castOrganizationResponseToOrganization(org: OrganizationBase): Oreturn {...org,billing_email: org.billing_email ?? 'Unknown',- managed_by: getManagedBy(org),+ managed_by: getManagedByFromOrganizationPartner(org.billing_partner, org.integration_source),partner_id: org.slug.startsWith('vercel_') ? org.slug.replace('vercel_', '') : undefined,}}-function getManagedBy(org: OrganizationBase): ManagedBy {- switch (org.billing_partner) {- case 'vercel_marketplace':- return MANAGED_BY.VERCEL_MARKETPLACE- case 'aws_marketplace':- return MANAGED_BY.AWS_MARKETPLACE- default:- return MANAGED_BY.SUPABASE- }-}-export async function getOrganizations({signal,headers,diff --git a/apps/studio/data/projects/org-projects-infinite-query.ts b/apps/studio/data/projects/org-projects-infinite-query.tsindex 0fd14d17587..0dc957f7ba3 100644--- a/apps/studio/data/projects/org-projects-infinite-query.ts+++ b/apps/studio/data/projects/org-projects-infinite-query.ts@@ -1,5 +1,5 @@import { InfiniteData, useInfiniteQuery, useQueryClient } from '@tanstack/react-query'-import { components } from 'api-types'+import { platformComponents as components } from 'api-types'import { useCallback } from 'react'import { INFINITE_PROJECTS_KEY_PREFIX, projectKeys } from './keys'diff --git a/apps/studio/lib/constants/infrastructure.ts b/apps/studio/lib/constants/infrastructure.tsindex 0f6c03fa9b6..3ecb57d144e 100644--- a/apps/studio/lib/constants/infrastructure.ts+++ b/apps/studio/lib/constants/infrastructure.ts@@ -15,6 +15,7 @@ export const FLY_REGIONS_DEFAULT = FLY_REGIONS.SOUTHEAST_ASIAexport const MANAGED_BY = {VERCEL_MARKETPLACE: 'vercel-marketplace',AWS_MARKETPLACE: 'aws-marketplace',+ STRIPE_PROJECTS: 'stripe-projects',SUPABASE: 'supabase',}diff --git a/apps/studio/tests/helpers.tsx b/apps/studio/tests/helpers.tsxindex 6f32e9ab9f1..94f8dc74679 100644--- a/apps/studio/tests/helpers.tsx+++ b/apps/studio/tests/helpers.tsx@@ -55,6 +55,7 @@ export const createMockOrganization = (details: Partial<Organization>): Organizais_owner: true,billing_email: '[email protected]',billing_partner: null,+ integration_source: null,usage_billing_enabled: false,stripe_customer_id: 'stripe-1',subscription_id: 'subscription-1',diff --git a/apps/studio/tests/setup/polyfills.ts b/apps/studio/tests/setup/polyfills.tsindex ba913603e4c..4e2b52a209e 100644--- a/apps/studio/tests/setup/polyfills.ts+++ b/apps/studio/tests/setup/polyfills.ts@@ -36,4 +36,34 @@ Object.defineProperties(globalThis, {TransformStream: { value: TransformStream },})+if (typeof window.localStorage?.getItem !== 'function') {+ const storage = new Map<string, string>()+ const localStoragePolyfill = {+ getItem: vi.fn((key: string) => storage.get(key) ?? null),+ setItem: vi.fn((key: string, value: string) => {+ storage.set(key, value)+ }),+ removeItem: vi.fn((key: string) => {+ storage.delete(key)+ }),+ clear: vi.fn(() => {+ storage.clear()+ }),+ key: vi.fn((index: number) => Array.from(storage.keys())[index] ?? null),+ get length() {+ return storage.size+ },+ }++ Object.defineProperty(window, 'localStorage', {+ configurable: true,+ value: localStoragePolyfill,+ })++ Object.defineProperty(globalThis, 'localStorage', {+ configurable: true,+ value: localStoragePolyfill,+ })+}+window.HTMLElement.prototype.hasPointerCapture = vi.fn()diff --git a/apps/studio/vitest.config.ts b/apps/studio/vitest.config.tsindex 638d563a41d..4c64e6653ea 100644--- a/apps/studio/vitest.config.ts+++ b/apps/studio/vitest.config.ts@@ -25,8 +25,8 @@ export default defineConfig({globals: true,environment: 'jsdom', // TODO(kamil): This should be set per test via header in .tsx files onlysetupFiles: [- resolve(dirname, './tests/vitestSetup.ts'),resolve(dirname, './tests/setup/polyfills.ts'),+ resolve(dirname, './tests/vitestSetup.ts'),resolve(dirname, './tests/setup/radix.js'),],// Don't look for tests in the nextjs output directorydiff --git a/packages/api-types/index.ts b/packages/api-types/index.tsindex e3de6a16508..4870d902de6 100644--- a/packages/api-types/index.ts+++ b/packages/api-types/index.ts@@ -21,3 +21,5 @@ export interface components {headers: apiComponents['headers'] & platformComponents['headers']pathItems: apiComponents['pathItems'] & platformComponents['pathItems']}++export type { platformComponents, apiComponents }diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.tsindex 7ea9fdb448c..4f84a15c31c 100644--- a/packages/api-types/types/api.d.ts+++ b/packages/api-types/types/api.d.ts@@ -345,8 +345,6 @@ export interface paths {/*** List all projects* @description Returns a list of all projects you've previously created.- *- * Use `/v1/organizations/{slug}/projects` instead when possible to get more precise results and pagination support.*/get: operations['v1-list-all-projects']put?: never@@ -1564,9 +1562,9 @@ export interface paths {path?: nevercookie?: never}- /** [Beta] Get project's just-in-time access configuration. */+ /** [Beta] Get project's temporary access configuration. */get: operations['v1-get-jit-access-config']- /** [Beta] Update project's just-in-time access configuration. */+ /** [Beta] Update project's temporary access configuration. */put: operations['v1-update-jit-access-config']post?: neverdelete?: never@@ -3094,7 +3092,7 @@ export interface components {* } */JitAccessRequestRequest: {/** @enum {string} */- state: 'enabled' | 'disabled' | 'unavailable'+ state: 'enabled' | 'disabled'}JitAccessResponse: {/** Format: uuid */@@ -4951,54 +4949,6 @@ export interface components {name?: stringversion: string}[]- V1ListProjectsPaginatedResponse: {- pagination: {- /** @description Total number of projects. Use this to calculate the total number of pages. */- count: number- /** @description Maximum number of projects per page (actual number may be less) */- limit: number- /** @description Number of projects skipped in this response */- offset: number- }- projects: {- cloud_provider: string- disk_volume_size_gb?: number- id: number- /** @enum {string} */- infra_compute_size?:- | 'pico'- | 'nano'- | 'micro'- | 'small'- | 'medium'- | 'large'- | 'xlarge'- | '2xlarge'- | '4xlarge'- | '8xlarge'- | '12xlarge'- | '16xlarge'- | '24xlarge'- | '24xlarge_optimized_memory'- | '24xlarge_optimized_cpu'- | '24xlarge_high_memory'- | '48xlarge'- | '48xlarge_optimized_memory'- | '48xlarge_optimized_cpu'- | '48xlarge_high_memory'- inserted_at: string | null- is_branch_enabled: boolean- is_physical_backups_enabled: boolean | null- name: string- organization_id: number- organization_slug: string- preview_branch_refs: string[]- ref: string- region: string- status: string- subscription_id: string | null- }[]- }V1OrganizationMemberResponse: {email?: stringmfa_enabled: boolean@@ -11208,7 +11158,7 @@ export interface operations {}content?: never}- /** @description Failed to retrieve project's JIT access config */+ /** @description Failed to retrieve project's temporary access configuration. */500: {headers: {[name: string]: unknown@@ -11262,7 +11212,7 @@ export interface operations {}content?: never}- /** @description Failed to update project's just-in-time access configuration. */+ /** @description Failed to update project's temporary access configuration. */500: {headers: {[name: string]: unknowndiff --git a/packages/api-types/types/platform.d.ts b/packages/api-types/types/platform.d.tsindex e9be01f90f4..8961dec7e87 100644--- a/packages/api-types/types/platform.d.ts+++ b/packages/api-types/types/platform.d.ts@@ -5174,6 +5174,7 @@ export interface components {/** @enum {string|null} */billing_partner: 'fly' | 'aws_marketplace' | 'vercel_marketplace' | nullid: number+ integration_source: string | nullis_owner: booleanname: stringopt_in_tags: string[]@@ -7690,6 +7691,7 @@ export interface components {type: 'PRIMARY' | 'READ_REPLICA'}[]inserted_at: string+ integration_source: string | nullis_branch: booleanname: stringref: string@@ -7718,6 +7720,7 @@ export interface components {/** @enum {string|null} */billing_partner: 'fly' | 'aws_marketplace' | 'vercel_marketplace' | nullid: number+ integration_source: string | nullis_owner: booleanname: stringopt_in_tags: string[]@@ -7789,6 +7792,7 @@ export interface components {billing_partner: 'fly' | 'aws_marketplace' | 'vercel_marketplace' | nullhas_oriole_project: booleanid: number+ integration_source: string | nullname: stringopt_in_tags: string[]plan: {@@ -8644,6 +8648,7 @@ export interface components {| '48xlarge_optimized_cpu'| '48xlarge_high_memory'inserted_at: string+ integration_source?: string | nullis_branch_enabled: booleanis_physical_backups_enabled: booleanlastDatabaseResizeAt?: string@@ -18132,6 +18137,7 @@ export interface operations {| 'security.audit_logs_days'| 'security.questionnaire'| 'security.soc2_report'+ | 'security.iso27001_certificate'| 'security.private_link'| 'security.enforce_mfa'| 'log.retention_days'diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.tsindex 97ce0162cec..acd289ad04d 100644--- a/packages/common/constants/local-storage.ts+++ b/packages/common/constants/local-storage.ts@@ -99,6 +99,10 @@ export const LOCAL_STORAGE_KEYS = {// Observability banner dismissedOBSERVABILITY_BANNER_DISMISSED: (ref: string) => `observability-banner-dismissed-${ref}`,+ ORGANIZATION_MARKETPLACE_BANNER_DISMISSED: (orgSlug: string, managedBy: string) =>+ `organization-marketplace-banner-dismissed-${orgSlug}-${managedBy}`,+ PROJECT_INTEGRATION_BANNER_DISMISSED: (ref: string, integrationSource: string) =>+ `project-integration-banner-dismissed-${ref}-${integrationSource}`,// Tax ID banner dismissedTAX_ID_BANNER_DISMISSED: (slug: string) => `tax-id-banner-dismissed-${slug}`,