Skip to content

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

fix(studio): show support inline and honour AlertError layouts (#51377)

Danny White78dc7399011e
diff --git a/apps/studio/components/interfaces/Account/TOTPFactors/GenerateRecoveryCodesModal.test.tsx b/apps/studio/components/interfaces/Account/TOTPFactors/GenerateRecoveryCodesModal.test.tsx
index bc0c051ec70..df4407c497f 100644
--- a/apps/studio/components/interfaces/Account/TOTPFactors/GenerateRecoveryCodesModal.test.tsx
+++ b/apps/studio/components/interfaces/Account/TOTPFactors/GenerateRecoveryCodesModal.test.tsx
@@ -85,8 +85,8 @@ describe('GenerateRecoveryCodesModal', () => {
customRender(<GenerateRecoveryCodesModal />)
fireEvent.click(await screen.findByRole('button', { name: 'Generate recovery codes' }))
await screen.findByText('Unable to generate recovery codes')
- await screen.findByText(
- 'Try refreshing your browser, but if the issue persists for more than a few minutes, please reach out to us via support.'
+ expect(await screen.findByText(/Try refreshing your browser/)).toHaveTextContent(
+ 'Try refreshing your browser, but if the issue persists for more than a few minutes, contact support.'
)
fireEvent.click(await screen.findByRole('button', { name: 'Close' }))
diff --git a/apps/studio/components/interfaces/Account/TOTPFactors/RegenerateRecoveryCodesModal.test.tsx b/apps/studio/components/interfaces/Account/TOTPFactors/RegenerateRecoveryCodesModal.test.tsx
index 375ac080355..2ba4b3098b8 100644
--- a/apps/studio/components/interfaces/Account/TOTPFactors/RegenerateRecoveryCodesModal.test.tsx
+++ b/apps/studio/components/interfaces/Account/TOTPFactors/RegenerateRecoveryCodesModal.test.tsx
@@ -109,8 +109,8 @@ describe('RegenerateRecoveryCodesModal', () => {
await within(await screen.findByRole('dialog')).findByRole('button', { name: 'Regenerate' })
)
await screen.findByText('Unable to generate recovery codes')
- await screen.findByText(
- 'Try refreshing your browser, but if the issue persists for more than a few minutes, please reach out to us via support.'
+ expect(await screen.findByText(/Try refreshing your browser/)).toHaveTextContent(
+ 'Try refreshing your browser, but if the issue persists for more than a few minutes, contact support.'
)
fireEvent.click(await screen.findByRole('button', { name: 'Close' }))
diff --git a/apps/studio/components/interfaces/Database/Migrations/Migrations.tsx b/apps/studio/components/interfaces/Database/Migrations/Migrations.tsx
index f5b627e7449..63c47158f3d 100644
--- a/apps/studio/components/interfaces/Database/Migrations/Migrations.tsx
+++ b/apps/studio/components/interfaces/Database/Migrations/Migrations.tsx
@@ -1,4 +1,3 @@
-import { SupportCategories } from '@supabase/shared-types/out/constants'
import { Search } from 'lucide-react'
import { useRef, useState } from 'react'
import {
@@ -16,13 +15,12 @@ import {
TooltipContent,
TooltipTrigger,
} from 'ui'
-import { Admonition } from 'ui-patterns/Admonition'
import { Input } from 'ui-patterns/DataInputs/Input'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
import { TimestampInfo } from 'ui-patterns/TimestampInfo'
import { MigrationsEmptyState } from './MigrationsEmptyState'
-import { SupportLink } from '@/components/interfaces/Support/SupportLink'
+import { AlertError } from '@/components/ui/AlertError'
import { CodeEditor } from '@/components/ui/CodeEditor/CodeEditor'
import { InlineLink } from '@/components/ui/InlineLink'
import { TableRowNoResults } from '@/components/ui/TableRowNoResults'
@@ -79,31 +77,11 @@ export const Migrations = () => {
<div>
{isError && (
- <Admonition
- type="warning"
- title="Failed to retrieve migration history for database"
- description={
- <>
- <p className="mb-1">
- Try refreshing your browser, but if the issue persists for more than a few
- minutes, please reach out to us via support.
- </p>
- <p className="mb-4">Error: {error?.message ?? 'Unknown'}</p>
- </>
- }
- >
- <Button key="contact-support" asChild>
- <SupportLink
- queryParams={{
- projectRef: project?.ref,
- category: SupportCategories.DASHBOARD_BUG,
- subject: 'Unable to view database migrations',
- }}
- >
- Contact support
- </SupportLink>
- </Button>
- </Admonition>
+ <AlertError
+ projectRef={project?.ref}
+ subject="Failed to retrieve migration history for database"
+ error={error}
+ />
)}
{isSuccess && (
<div>
@@ -202,7 +180,7 @@ export const Migrations = () => {
header={`Migration: ${selectedMigration?.version}`}
onCancel={() => setSelectedMigration(undefined)}
customFooter={
- <div className="flex items-center justify-end p-4 border-t border-overlay-border">
+ <div className="flex items-center justify-end p-4 border-t">
<Button onClick={() => setSelectedMigration(undefined)}>Close</Button>
</div>
}
diff --git a/apps/studio/components/interfaces/Database/Replication/Destinations.tsx b/apps/studio/components/interfaces/Database/Replication/Destinations.tsx
index 22038b3d706..8ff5afa97d7 100644
--- a/apps/studio/components/interfaces/Database/Replication/Destinations.tsx
+++ b/apps/studio/components/interfaces/Database/Replication/Destinations.tsx
@@ -381,9 +381,11 @@ export const Destinations = () => {
{isSourcesError && (
<AlertError
+ layout="responsive"
projectRef={projectRef}
error={sourcesError}
subject={sourceErrorTitle}
+ hideContactSupport={checkLocalETLNotSetUp(sourcesError)}
description={
checkLocalETLNotSetUp(sourcesError)
? 'Configure the replication API to manage pipelines in local development.'
diff --git a/apps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsx b/apps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsx
index 4f3426c3761..1c8537c37ef 100644
--- a/apps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsx
+++ b/apps/studio/components/interfaces/Database/Replication/ErroredTableDetails.tsx
@@ -30,7 +30,7 @@ export const ErroredTableDetails = ({ table }: ErroredTableDetailsProps) => {
Needs{' '}
<InlineLink
className="text-foreground-lighter hover:text-foreground"
- href={`/support?projectRef=${projectRef}&category=dashboard_bug&subject=Database%20replication%20error&error=${encodeURIComponent(state.reason ?? '')}`}
+ href={`/support?projectRef=${projectRef}&category=dashboard_bug&subject=Database%20replication%20error&errorMessage=${encodeURIComponent(state.reason ?? '')}`}
>
support
</InlineLink>
diff --git a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationError.tsx b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationError.tsx
index 5f0bb202a2f..465925e138b 100644
--- a/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationError.tsx
+++ b/apps/studio/components/interfaces/Integrations/templates/StripeSyncEngine/InstallationError.tsx
@@ -25,7 +25,7 @@ export const InstallationError = ({
if (error === 'uninstall') {
return (
<AlertError
- layout="horizontal"
+ layout="responsive"
subject="Failed to uninstall Stripe Sync Engine"
error={errorMessage ? { message: errorMessage } : undefined}
description="There was an error during the uninstallation of the Stripe Sync Engine, please try again. If the problem persists, contact support."
diff --git a/apps/studio/components/interfaces/Settings/Database/BannedIPs.test.tsx b/apps/studio/components/interfaces/Settings/Database/BannedIPs.test.tsx
index 5026bb02d25..71a7a3b7507 100644
--- a/apps/studio/components/interfaces/Settings/Database/BannedIPs.test.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/BannedIPs.test.tsx
@@ -47,7 +47,7 @@ test('shows a project-details error instead of leaving Network bans loading', as
expect(await screen.findByText('Failed to retrieve project details')).toBeVisible()
expect(screen.getByText('Error: Project unavailable')).toBeVisible()
- expect(screen.getByRole('link', { name: 'Contact support' })).toHaveAttribute(
+ expect(screen.getByRole('link', { name: /contact support/i })).toHaveAttribute(
'href',
expect.stringContaining('projectRef=default')
)
diff --git a/apps/studio/components/interfaces/Settings/SuspensionNotice.tsx b/apps/studio/components/interfaces/Settings/SuspensionNotice.tsx
index 5510c82943d..d825e0631a1 100644
--- a/apps/studio/components/interfaces/Settings/SuspensionNotice.tsx
+++ b/apps/studio/components/interfaces/Settings/SuspensionNotice.tsx
@@ -1,8 +1,10 @@
+import { SupportCategories } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
+import { Button } from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { TimestampInfo } from 'ui-patterns/TimestampInfo'
-import { ContactSupportButton } from '@/components/ui/AlertError'
+import { SupportLink } from '../Support/SupportLink'
export const SuspensionNotice = ({ suspendedAt }: { suspendedAt?: string | null }) => {
const { ref } = useParams()
@@ -26,10 +28,17 @@ export const SuspensionNotice = ({ suspendedAt }: { suspendedAt?: string | null
</>
}
actions={
- <ContactSupportButton
- projectRef={ref}
- subject="Enquiry on realtime suspension for project"
- />
+ <Button asChild className="w-min">
+ <SupportLink
+ queryParams={{
+ category: SupportCategories.DASHBOARD_BUG,
+ projectRef: ref,
+ subject: 'Enquiry on realtime suspension for project',
+ }}
+ >
+ Contact support
+ </SupportLink>
+ </Button>
}
/>
)
diff --git a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketsErrorState.test.tsx b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketsErrorState.test.tsx
index 296c90edbfd..26dd93dfad6 100644
--- a/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketsErrorState.test.tsx
+++ b/apps/studio/components/interfaces/Storage/VectorBuckets/VectorBucketsErrorState.test.tsx
@@ -37,7 +37,7 @@ describe('VectorBucketsErrorState', () => {
expect(screen.getByText('Vector buckets are not enabled')).toBeInTheDocument()
expect(screen.getByText('supabase/config.toml')).toBeInTheDocument()
- expect(screen.queryByText('Contact support')).not.toBeInTheDocument()
+ expect(screen.queryByRole('link', { name: /contact support/i })).not.toBeInTheDocument()
})
test('platform: shows the generic support error', () => {
@@ -46,7 +46,7 @@ describe('VectorBucketsErrorState', () => {
customRender(<VectorBucketsErrorState error={new ResponseError('boom')} />)
expect(screen.getByText('Failed to retrieve vector buckets')).toBeInTheDocument()
- expect(screen.getByText('Contact support')).toBeInTheDocument()
+ expect(screen.getByRole('link', { name: /contact support/i })).toBeInTheDocument()
expect(screen.queryByText('Vector buckets are not enabled')).not.toBeInTheDocument()
})
})
diff --git a/apps/studio/components/interfaces/Support/SupportForm.utils.tsx b/apps/studio/components/interfaces/Support/SupportForm.utils.tsx
index cd9ee44b348..7bc5fe26737 100644
--- a/apps/studio/components/interfaces/Support/SupportForm.utils.tsx
+++ b/apps/studio/components/interfaces/Support/SupportForm.utils.tsx
@@ -149,7 +149,8 @@ const supportFormUrlState = {
category: parseAsCategoryOption,
subject: parseAsString.withDefault(''),
message: parseAsString.withDefault(''),
- error: parseAsString,
+ // Not `error`: auth-js treats `?error=` in any URL as a failed auth redirect
+ errorMessage: parseAsString,
/** Sentry event ID */
sid: parseAsString,
} satisfies UseQueryStatesKeysMap
diff --git a/apps/studio/components/interfaces/Support/__tests__/SupportFormPage.test.tsx b/apps/studio/components/interfaces/Support/__tests__/SupportFormPage.test.tsx
index 1ecaf94a24c..0894961cffd 100644
--- a/apps/studio/components/interfaces/Support/__tests__/SupportFormPage.test.tsx
+++ b/apps/studio/components/interfaces/Support/__tests__/SupportFormPage.test.tsx
@@ -928,7 +928,7 @@ describe('SupportFormPage', () => {
})
Object.defineProperty(window, 'location', {
- value: createMockLocation(`?error=${encodeURIComponent(initialError)}`),
+ value: createMockLocation(`?errorMessage=${encodeURIComponent(initialError)}`),
writable: true,
})
@@ -1191,7 +1191,7 @@ describe('SupportFormPage', () => {
})
Object.defineProperty(window, 'location', {
- value: createMockLocation('?projectRef=project-3&error=Connection timeout detected'),
+ value: createMockLocation('?projectRef=project-3&errorMessage=Connection timeout detected'),
writable: true,
})
diff --git a/apps/studio/components/interfaces/Support/useSupportForm.ts b/apps/studio/components/interfaces/Support/useSupportForm.ts
index db4e654c803..8f44c841b73 100644
--- a/apps/studio/components/interfaces/Support/useSupportForm.ts
+++ b/apps/studio/components/interfaces/Support/useSupportForm.ts
@@ -61,7 +61,7 @@ export function useSupportForm(
? loadSupportFormInitialParamsFromObject(providedInitialParamsRef.current)
: loadSupportFormInitialParams(window.location.search)
urlParamsRef.current = params
- setInitialError(params.error ?? null)
+ setInitialError(params.errorMessage ?? null)
if (params.category && !form.getFieldState('category').isDirty) {
form.setValue('category', params.category, { shouldDirty: false })
diff --git a/apps/studio/components/ui/AlertError.test.tsx b/apps/studio/components/ui/AlertError.test.tsx
new file mode 100644
index 00000000000..f3349f47f77
--- /dev/null
+++ b/apps/studio/components/ui/AlertError.test.tsx
@@ -0,0 +1,67 @@
+import { SupportCategories } from '@supabase/shared-types/out/constants'
+import { screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { Button } from 'ui'
+import { expect, test, vi } from 'vitest'
+
+import { AlertError } from './AlertError'
+import { createSupportFormUrl } from '@/components/interfaces/Support/SupportForm.utils'
+import { takeBreadcrumbSnapshot } from '@/lib/breadcrumbs'
+import { customRender } from '@/tests/lib/custom-render'
+
+vi.mock('@/lib/telemetry/track', () => ({ useTrack: () => vi.fn() }))
+vi.mock('@/lib/breadcrumbs', () => ({ takeBreadcrumbSnapshot: vi.fn() }))
+
+test('explicit responsive layout survives additional actions', () => {
+ customRender(<AlertError layout="responsive" additionalActions={<Button>Retry</Button>} />)
+ expect(screen.getByRole('alert')).toHaveClass('@container')
+ expect(screen.getByRole('button', { name: 'Retry' })).toBeInTheDocument()
+})
+
+test('hiding support removes its wording from the default instructions', () => {
+ customRender(<AlertError hideContactSupport />)
+ expect(screen.getByText('Try refreshing your browser.')).toBeInTheDocument()
+ expect(screen.queryByText(/contact support/i)).not.toBeInTheDocument()
+})
+
+test('support is an inline link with the error context, not an action button', async () => {
+ const user = userEvent.setup()
+ customRender(
+ <AlertError projectRef="default" subject="Failed to load" error={{ message: 'Test error' }} />
+ )
+ expect(screen.getByRole('link', { name: 'contact support' })).toHaveAttribute(
+ 'href',
+ createSupportFormUrl({
+ category: SupportCategories.DASHBOARD_BUG,
+ projectRef: 'default',
+ subject: 'Failed to load',
+ errorMessage: 'Test error',
+ })
+ )
+ expect(screen.queryByRole('button', { name: /contact support/i })).not.toBeInTheDocument()
+ await user.click(screen.getByRole('link', { name: 'contact support' }))
+ expect(takeBreadcrumbSnapshot).toHaveBeenCalledOnce()
+})
+test('custom support prose links unless support is hidden', () => {
+ const { rerender } = customRender(
+ <AlertError description="Please contact support for assistance." />
+ )
+ expect(screen.getByRole('link', { name: 'contact support' })).toBeInTheDocument()
+ rerender(<AlertError description="Please contact support for assistance." hideContactSupport />)
+ expect(screen.queryByRole('link', { name: 'contact support' })).not.toBeInTheDocument()
+ expect(screen.getByText('Please contact support for assistance.')).toBeInTheDocument()
+})
+
+test.each([false, true])(
+ 'keeps support available with custom instructions (hidden: %s)',
+ (hidden) => {
+ const { rerender } = customRender(
+ <AlertError description="Refresh the page." showInstructions={!hidden} />
+ )
+ expect(screen.getByRole('link', { name: 'Contact support' })).toBeInTheDocument()
+ rerender(
+ <AlertError description="Refresh the page." showInstructions={!hidden} hideContactSupport />
+ )
+ expect(screen.queryByRole('link', { name: /contact support/i })).not.toBeInTheDocument()
+ }
+)
diff --git a/apps/studio/components/ui/AlertError.tsx b/apps/studio/components/ui/AlertError.tsx
index 93ea7429567..61a312d2e6b 100644
--- a/apps/studio/components/ui/AlertError.tsx
+++ b/apps/studio/components/ui/AlertError.tsx
@@ -1,9 +1,9 @@
import { SupportCategories } from '@supabase/shared-types/out/constants'
import { PropsWithChildren, useEffect, useRef } from 'react'
-import { Button } from 'ui'
import { Admonition } from 'ui-patterns/Admonition'
import { SupportLink } from '@/components/interfaces/Support/SupportLink'
+import { InlineLinkClassName } from '@/components/ui/InlineLink'
import { isDashboardErrorSampled } from '@/lib/telemetry/error-sampling'
import { useTrack } from '@/lib/telemetry/track'
@@ -22,49 +22,25 @@ export interface AlertErrorProps {
hideContactSupport?: boolean
}
-export const ContactSupportButton = ({
- projectRef,
- orgSlug,
- subject,
- error,
-}: {
- projectRef?: string
- orgSlug?: string
- subject?: string
- error?: { message: string } | null
-}) => {
- return (
- <Button asChild className="w-min">
- <SupportLink
- queryParams={{
- category: SupportCategories.DASHBOARD_BUG,
- projectRef,
- orgSlug,
- subject,
- error: error?.message,
- }}
- >
- Contact support
- </SupportLink>
- </Button>
- )
-}
+const SUPPORT_PHRASE_REGEX = /(contact support)/i
// [Joshen] To standardize the language for all error UIs
export const AlertError = ({
projectRef,
orgSlug,
subject,
- description = 'Try refreshing your browser, but if the issue persists for more than a few minutes, please reach out to us via support.',
+ hideContactSupport = false,
+ description = hideContactSupport
+ ? 'Try refreshing your browser.'
+ : 'Try refreshing your browser, but if the issue persists for more than a few minutes, contact support.',
error,
className,
showIcon = true,
- layout = 'responsive',
+ layout,
showInstructions = true,
showErrorPrefix = true,
children,
additionalActions,
- hideContactSupport = false,
}: PropsWithChildren<AlertErrorProps>) => {
const track = useTrack()
const hasTrackedRef = useRef(false)
@@ -73,6 +49,34 @@ export const AlertError = ({
? '503 Service Temporarily Unavailable'
: error?.message
+ const hasInlineSupportLink =
+ showInstructions && !hideContactSupport && SUPPORT_PHRASE_REGEX.test(description)
+ const canShowSupportFallback = !hideContactSupport && !hasInlineSupportLink
+
+ const renderSupportLink = (text: string, key?: number) => (
+ <SupportLink
+ key={key}
+ className={InlineLinkClassName}
+ queryParams={{
+ category: SupportCategories.DASHBOARD_BUG,
+ projectRef,
+ orgSlug,
+ subject,
+ errorMessage: error?.message,
+ }}
+ >
+ {text}
+ </SupportLink>
+ )
+
+ // Splitting with a capture group keeps the matched text, so it can be swapped for a link
+ const renderDescriptionWithSupportLink = (text: string) =>
+ text
+ .split(SUPPORT_PHRASE_REGEX)
+ .map((part, index) =>
+ SUPPORT_PHRASE_REGEX.test(part) ? renderSupportLink(part, index) : part
+ )
+
useEffect(() => {
if (!hasTrackedRef.current) {
hasTrackedRef.current = true
@@ -87,7 +91,7 @@ export const AlertError = ({
return (
<Admonition
type="warning"
- layout={additionalActions ? 'vertical' : layout}
+ layout={layout ?? (additionalActions ? 'vertical' : 'responsive')}
showIcon={showIcon}
title={subject}
description={
@@ -98,25 +102,16 @@ export const AlertError = ({
{formattedErrorMessage}
</p>
)}
- {showInstructions && <p>{description}</p>}
+ {showInstructions && (
+ <p>
+ {hasInlineSupportLink ? renderDescriptionWithSupportLink(description) : description}
+ </p>
+ )}
+ {canShowSupportFallback && <p>{renderSupportLink('Contact support')}</p>}
{children}
</>
}
- actions={
- additionalActions || !hideContactSupport ? (
- <>
- {additionalActions}
- {!hideContactSupport && (
- <ContactSupportButton
- projectRef={projectRef}
- orgSlug={orgSlug}
- subject={subject}
- error={error}
- />
- )}
- </>
- ) : null
- }
+ actions={additionalActions}
className={className}
/>
)
diff --git a/apps/studio/components/ui/ErrorBoundary/ClientSideExceptionHandler.tsx b/apps/studio/components/ui/ErrorBoundary/ClientSideExceptionHandler.tsx
index 314c79f6075..62a27d1b0ed 100644
--- a/apps/studio/components/ui/ErrorBoundary/ClientSideExceptionHandler.tsx
+++ b/apps/studio/components/ui/ErrorBoundary/ClientSideExceptionHandler.tsx
@@ -86,7 +86,7 @@ export const ClientSideExceptionHandler = ({
category: SupportCategories.DASHBOARD_BUG,
subject: 'Client side exception occurred on dashboard',
sid: sentryIssueId,
- error: urlMessage,
+ errorMessage: urlMessage,
}}
>
Contact support
diff --git a/apps/studio/components/ui/ErrorBoundary/InsertBeforeRemoveChildErrorHandler.tsx b/apps/studio/components/ui/ErrorBoundary/InsertBeforeRemoveChildErrorHandler.tsx
index e960c0b6c7b..b7131872bb3 100644
--- a/apps/studio/components/ui/ErrorBoundary/InsertBeforeRemoveChildErrorHandler.tsx
+++ b/apps/studio/components/ui/ErrorBoundary/InsertBeforeRemoveChildErrorHandler.tsx
@@ -79,7 +79,7 @@ export const InsertBeforeRemoveChildErrorHandler = ({
category: SupportCategories.DASHBOARD_BUG,
subject: `Client error: Failed to execute '${isRemoveChildError ? 'removeChild' : 'insertBefore'}' on 'Node'`,
sid: sentryIssueId,
- error: urlMessage,
+ errorMessage: urlMessage,
}}
>
Still stuck?