The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Support form sidebar (#45203)
Saxon Fletcher4452e0ac2e97
diff --git a/apps/studio/components/interfaces/Support/AIAssistantOption.tsx b/apps/studio/components/interfaces/Support/AIAssistantOption.tsxindex ca547a25988..a8b11ed3fc6 100644--- a/apps/studio/components/interfaces/Support/AIAssistantOption.tsx+++ b/apps/studio/components/interfaces/Support/AIAssistantOption.tsx@@ -10,9 +10,14 @@ import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'interface AIAssistantOptionProps {projectRef?: string | nullorganizationSlug?: string | null+ onClick?: () => void}-export const AIAssistantOption = ({ projectRef, organizationSlug }: AIAssistantOptionProps) => {+export const AIAssistantOption = ({+ projectRef,+ organizationSlug,+ onClick,+}: AIAssistantOptionProps) => {const { mutate: sendEvent } = useSendEventMutation()const [isVisible, setIsVisible] = useState(false)@@ -32,7 +37,9 @@ export const AIAssistantOption = ({ projectRef, organizationSlug }: AIAssistantO: organizationSlug,},})- }, [projectRef, organizationSlug, sendEvent])++ onClick?.()+ }, [onClick, projectRef, organizationSlug, sendEvent])// If no specific project selected, use the wildcard routeconst aiLink = `/project/${projectRef !== NO_PROJECT_MARKER ? projectRef : '_'}?sidebar=ai-assistant&slug=${organizationSlug}`@@ -57,11 +64,22 @@ export const AIAssistantOption = ({ projectRef, organizationSlug }: AIAssistantO</p></div><div>- <Link href={aiLink} onClick={onAiAssistantClicked}>- <Button size="tiny" type="default" icon={<AiIconAnimation size={14} />}>+ {onClick ? (+ <Button+ size="tiny"+ type="default"+ icon={<AiIconAnimation size={14} />}+ onClick={onAiAssistantClicked}+ >Ask the Assistant</Button>- </Link>+ ) : (+ <Link href={aiLink} onClick={onAiAssistantClicked}>+ <Button size="tiny" type="default" icon={<AiIconAnimation size={14} />}>+ Ask the Assistant+ </Button>+ </Link>+ )}</div></div>{/* Decorative background */}diff --git a/apps/studio/components/interfaces/Support/AttachmentUpload.tsx b/apps/studio/components/interfaces/Support/AttachmentUpload.tsxindex 50d8f04e000..35680f0c8c0 100644--- a/apps/studio/components/interfaces/Support/AttachmentUpload.tsx+++ b/apps/studio/components/interfaces/Support/AttachmentUpload.tsx@@ -112,9 +112,14 @@ export function useAttachmentUpload() {if (uploadedFiles.length === 0) return- const filenames = await uploadAttachments({ userId: profile.gotrue_id, files: uploadedFiles })- const urls = await generateAttachmentURLs({ bucket: 'support-attachments', filenames })- return urls+ try {+ const filenames = await uploadAttachments({ userId: profile.gotrue_id, files: uploadedFiles })+ const urls = await generateAttachmentURLs({ bucket: 'support-attachments', filenames })+ return urls+ } catch {+ // Ignore attachments upload errors, images are additional context and support can ask for more if needed+ return+ }// eslint-disable-next-line react-hooks/exhaustive-deps}, [profile, uploadedFiles])diff --git a/apps/studio/components/interfaces/Support/DashboardLogsToggle.tsx b/apps/studio/components/interfaces/Support/DashboardLogsToggle.tsxindex 5144716dbc5..764384b269c 100644--- a/apps/studio/components/interfaces/Support/DashboardLogsToggle.tsx+++ b/apps/studio/components/interfaces/Support/DashboardLogsToggle.tsx@@ -16,9 +16,16 @@ import type { SupportFormValues } from './SupportForm.schema'interface DashboardLogsToggleProps {form: UseFormReturn<SupportFormValues>sanitizedLog: unknown[]+ align?: 'left' | 'right'+ className?: string}-export function DashboardLogsToggle({ form, sanitizedLog }: DashboardLogsToggleProps) {+export function DashboardLogsToggle({+ form,+ sanitizedLog,+ align = 'left',+ className,+}: DashboardLogsToggleProps) {const sanitizedLogJson = useMemo(() => JSON.stringify(sanitizedLog, null, 2), [sanitizedLog])const [isPreviewOpen, setIsPreviewOpen] = useState(false)@@ -33,25 +40,34 @@ export function DashboardLogsToggle({ form, sanitizedLog }: DashboardLogsToggleP<FormItemLayouthideMessagename="attachDashboardLogs"- className="px-6"+ className={className}layout="flex"+ align={align}label={<div className="flex items-center gap-x-2"><span className="text-foreground">Include dashboard activity log</span></div>}description={- <div className="flex flex-col gap-y-2">+ <div className="flex flex-col"><span className="text-foreground-light">Share sanitized logs of recent dashboard actions to help reproduce the issue.</span>- <Collapsible_Shadcn_ open={isPreviewOpen} onOpenChange={setIsPreviewOpen}>- <CollapsibleTrigger_Shadcn_ className="group flex items-center gap-x-1 text-sm text-foreground-lighter hover:text-foreground transition">+ <Collapsible_Shadcn_+ className="mt-2"+ open={isPreviewOpen}+ onOpenChange={setIsPreviewOpen}+ >+ <CollapsibleTrigger_Shadcn_+ className={+ 'group flex items-center gap-x-1 group-data-open:text-foreground hover:text-foreground transition'+ }+ ><ChevronRightsize={14}- className="transition-transform group-data-open:rotate-90"+ className="transition-all group-data-open:rotate-90 text-foreground-muted -ml-1"/>- <span>Preview log</span>+ <span className="text-sm">Preview log</span></CollapsibleTrigger_Shadcn_><CollapsibleContent_Shadcn_ className="mt-2"><pre className="bg-background-surface-200 border border-strong rounded-lg p-3 max-h-60 overflow-y-auto overflow-x-auto text-xs text-foreground-light whitespace-pre-wrap">diff --git a/apps/studio/components/interfaces/Support/IncidentAdmonition.tsx b/apps/studio/components/interfaces/Support/IncidentAdmonition.tsxindex 247f924a602..a5e88c04735 100644--- a/apps/studio/components/interfaces/Support/IncidentAdmonition.tsx+++ b/apps/studio/components/interfaces/Support/IncidentAdmonition.tsx@@ -9,6 +9,7 @@ import { processIncidentData } from '@/data/platform/incident-status-utils'interface IncidentAdmonitionProps {isActive: boolean+ className?: string}const STATUS_DESCRIPTION_SIGN_OFF = 'Follow the status page for updates.'@@ -53,7 +54,7 @@ const getStatusDescription = (}}-export function IncidentAdmonition({ isActive }: IncidentAdmonitionProps) {+export function IncidentAdmonition({ isActive, className }: IncidentAdmonitionProps) {const { data: allStatusPageEvents, isLoading, isError } = useIncidentStatusQuery()const { incidents = [] } = allStatusPageEvents ?? {}@@ -83,6 +84,7 @@ export function IncidentAdmonition({ isActive }: IncidentAdmonitionProps) {<Admonitiontype="warning"layout="horizontal"+ className={className}title={statusTitle}description={getStatusDescription(overallStatus, hasMultipleIncidents, allSameStatus)}actions={diff --git a/apps/studio/components/interfaces/Support/LinkSupportTicketForm.tsx b/apps/studio/components/interfaces/Support/LinkSupportTicketForm.tsxindex 39e81c3cf37..0ee0cb3525e 100644--- a/apps/studio/components/interfaces/Support/LinkSupportTicketForm.tsx+++ b/apps/studio/components/interfaces/Support/LinkSupportTicketForm.tsx@@ -131,7 +131,6 @@ export const LinkSupportTicketForm = ({projectRef={selectedProjectRef}subscriptionPlanId={subscriptionPlanId}category={category}- showPlanExpectationInfo={false}/>)}diff --git a/apps/studio/components/interfaces/Support/ProjectAndPlanInfo.tsx b/apps/studio/components/interfaces/Support/ProjectAndPlanInfo.tsxindex cd1799e1bd6..5afc2f7a769 100644--- a/apps/studio/components/interfaces/Support/ProjectAndPlanInfo.tsx+++ b/apps/studio/components/interfaces/Support/ProjectAndPlanInfo.tsx@@ -24,16 +24,14 @@ interface ProjectAndPlanProps {projectRef: string | nullcategory: ExtendedSupportCategoriessubscriptionPlanId: string | undefined- showPlanExpectationInfo?: boolean}export function ProjectAndPlanInfo({form,orgSlug,projectRef,- category,- subscriptionPlanId,- showPlanExpectationInfo = true,+ category: _category,+ subscriptionPlanId: _subscriptionPlanId,}: ProjectAndPlanProps) {const hasProjectSelected = projectRef && projectRef !== NO_PROJECT_MARKER@@ -43,14 +41,6 @@ export function ProjectAndPlanInfo({<ProjectRefHighlighted projectRef={projectRef} />{!hasProjectSelected && <Admonition type="default" title="No project has been selected" />}-- {showPlanExpectationInfo &&- orgSlug &&- subscriptionPlanId !== 'enterprise' &&- subscriptionPlanId !== 'platform' &&- category !== 'Login_issues' && (- <PlanExpectationInfoBox orgSlug={orgSlug} planId={subscriptionPlanId} />- )}</div>)}@@ -163,66 +153,60 @@ function ProjectRefHighlighted({ projectRef }: ProjectRefHighlightedProps) {)}-interface PlanExpectationInfoBoxProps {+interface PlanExpectationInfoContentProps {orgSlug: stringplanId?: string}-const PlanExpectationInfoBox = ({ orgSlug, planId }: PlanExpectationInfoBoxProps) => {+export const PlanExpectationInfoContent = ({+ orgSlug,+ planId,+}: PlanExpectationInfoContentProps) => {const { billingAll } = useIsFeatureEnabled(['billing:all'])const shouldShowUpgradeActions = billingAll && planId !== 'enterprise'return (- <Admonition- type="default"- title="Expected response times are based on your organization’s plan"- description={- <>- {planId === 'free' && (- <p>- Support on the Free plan is provided through the community and by the team on a- best-effort basis. For a guaranteed response time, we recommend upgrading to the Pro- plan. Enhanced support SLAs are available on the Enterprise plan.- </p>- )}-- {planId === 'pro' && (- <p>- The Pro plan includes email support. In most cases, you can expect a response within 1- business day for all severities. For prioritized ticketing on all issues and- prioritized escalation to product engineering, we recommend upgrading to the Team- plan. Enhanced support SLAs are available on the Enterprise plan.- </p>- )}-- {planId === 'team' && (- <p>- The Team plan includes email support with prioritized ticketing and escalation to- product engineering. Low, normal, and high-severity tickets are typically handled- within 1 business day. Urgent issues are handled within 1 day, 365 days a year.- Enhanced support SLAs are available on the Enterprise plan.- </p>- )}- </>- }- actions={- shouldShowUpgradeActions && (- <>- <Button asChild>- <Link- href={`/org/${orgSlug}/billing?panel=subscriptionPlan&source=planSupportExpectationInfoBox`}- >- Upgrade plan- </Link>- </Button>- <Button asChild type="default" icon={<ExternalLink />}>- <Link href="https://supabase.com/contact/enterprise" target="_blank" rel="noreferrer">- Enquire about Enterprise- </Link>- </Button>- </>- )- }- />+ <div className="flex flex-col gap-y-3 text-sm text-foreground-light">+ {planId === 'free' && (+ <p>+ Support on the Free plan is provided through the community and by the team on a+ best-effort basis. For a guaranteed response time, we recommend upgrading to the Pro plan.+ Enhanced support SLAs are available on the Enterprise plan.+ </p>+ )}++ {planId === 'pro' && (+ <p>+ Pro includes email support with typical 1-business-day responses; upgrade to Team for+ prioritized ticketing and engineering escalation, or Enterprise for enhanced SLAs.+ </p>+ )}++ {planId === 'team' && (+ <p>+ The Team plan includes email support with prioritized ticketing and escalation to product+ engineering. Low, normal, and high-severity tickets are typically handled within 1+ business day. Urgent issues are handled within 1 day, 365 days a year. Enhanced support+ SLAs are available on the Enterprise plan.+ </p>+ )}++ {shouldShowUpgradeActions && (+ <div className="flex flex-wrap gap-2 pt-1">+ <Button asChild size="tiny">+ <Link+ href={`/org/${orgSlug}/billing?panel=subscriptionPlan&source=planSupportExpectationInfoBox`}+ >+ Upgrade plan+ </Link>+ </Button>+ <Button asChild type="default" size="tiny" icon={<ExternalLink />}>+ <Link href="https://supabase.com/contact/enterprise" target="_blank" rel="noreferrer">+ Enquire about Enterprise+ </Link>+ </Button>+ </div>+ )}+ </div>)}diff --git a/apps/studio/components/interfaces/Support/SubmitButton.tsx b/apps/studio/components/interfaces/Support/SubmitButton.tsxindex f7d654be9bc..5dfb36923dd 100644--- a/apps/studio/components/interfaces/Support/SubmitButton.tsx+++ b/apps/studio/components/interfaces/Support/SubmitButton.tsx@@ -1,17 +1,25 @@import type { MouseEventHandler } from 'react'// End of third-party imports-import { Button } from 'ui'+import { Button, cn } from 'ui'interface SubmitButtonProps {isSubmitting: booleanuserEmail: stringonClick?: MouseEventHandler<HTMLButtonElement>+ className?: string+ descriptionClassName?: string}-export function SubmitButton({ isSubmitting, userEmail, onClick }: SubmitButtonProps) {+export function SubmitButton({+ isSubmitting,+ userEmail,+ onClick,+ className,+ descriptionClassName,+}: SubmitButtonProps) {return (- <div className="flex flex-col gap-3">+ <div className={cn('flex flex-col gap-3', className)}><ButtonhtmlType="submit"size="small"@@ -22,7 +30,7 @@ export function SubmitButton({ isSubmitting, userEmail, onClick }: SubmitButtonP>Send support request</Button>- <p className="text-xs text-foreground-lighter text-balance pr-4">+ <p className={cn('text-xs text-foreground-lighter text-balance pr-4', descriptionClassName)}>We will contact you at <span className="text-foreground font-medium">{userEmail}</span>.Please ensure emails from supabase.com are allowed.</p>diff --git a/apps/studio/components/interfaces/Support/Success.test.tsx b/apps/studio/components/interfaces/Support/Success.test.tsxnew file mode 100644index 00000000000..9fca65cc8a9--- /dev/null+++ b/apps/studio/components/interfaces/Support/Success.test.tsx@@ -0,0 +1,20 @@+import { screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { describe, expect, it, vi } from 'vitest'++import { Success } from './Success'+import { customRender } from '@/tests/lib/custom-render'++describe('Success', () => {+ it('renders a local finish action when provided', async () => {+ const onFinish = vi.fn()++ customRender(<Success onFinish={onFinish} finishLabel="Done" />)++ expect(screen.queryByRole('link', { name: 'Done' })).not.toBeInTheDocument()++ await userEvent.click(screen.getByRole('button', { name: 'Done' }))++ expect(onFinish).toHaveBeenCalledTimes(1)+ })+})diff --git a/apps/studio/components/interfaces/Support/Success.tsx b/apps/studio/components/interfaces/Support/Success.tsxindex b00e83e320b..2ee26a9ef13 100644--- a/apps/studio/components/interfaces/Support/Success.tsx+++ b/apps/studio/components/interfaces/Support/Success.tsx@@ -9,11 +9,15 @@ import { useProfile } from '@/lib/profile'interface SuccessProps {sentCategory?: stringselectedProject?: string+ onFinish?: () => void+ finishLabel?: string}export const Success = ({sentCategory = '',selectedProject = NO_PROJECT_MARKER,+ onFinish,+ finishLabel = 'Finish',}: SuccessProps) => {const { profile } = useProfile()const respondToEmail = profile?.primary_email ?? 'your email'@@ -29,8 +33,8 @@ export const Success = ({return (<div className="mt-10 max-w-[620px] flex flex-col items-center space-y-4"><div className="relative">- <Mail strokeWidth={1.5} size={60} className="text-brand" />- <div className="h-6 w-6 rounded-full bg-brand absolute bottom-1 -right-1.5 flex items-center justify-center">+ <Mail strokeWidth={1.5} size={32} className="text-brand" />+ <div className="absolute -bottom-1 -right-1.5 flex h-4 w-4 items-center justify-center rounded-full bg-brand"><Check strokeWidth={4} size={16} className="text-contrast" /></div></div>@@ -76,9 +80,15 @@ export const Success = ({<Separator /></div><div className="w-full pb-4 px-4 flex items-center justify-end">- <Button asChild type="default">- <Link href="/">Finish</Link>- </Button>+ {onFinish ? (+ <Button type="default" onClick={onFinish}>+ {finishLabel}+ </Button>+ ) : (+ <Button asChild type="default">+ <Link href="/">{finishLabel}</Link>+ </Button>+ )}</div></div>)diff --git a/apps/studio/components/interfaces/Support/SupportAccessToggle.tsx b/apps/studio/components/interfaces/Support/SupportAccessToggle.tsxindex 535aeb70d3e..a809814a211 100644--- a/apps/studio/components/interfaces/Support/SupportAccessToggle.tsx+++ b/apps/studio/components/interfaces/Support/SupportAccessToggle.tsx@@ -25,9 +25,11 @@ export const DISABLE_SUPPORT_ACCESS_CATEGORIES: ExtendedSupportCategories[] = [interface SupportAccessToggleProps {form: UseFormReturn<SupportFormValues>+ align?: 'left' | 'right'+ className?: string}-export function SupportAccessToggle({ form }: SupportAccessToggleProps) {+export function SupportAccessToggle({ form, align = 'left', className }: SupportAccessToggleProps) {return (<FormFieldname="allowSupportAccess"@@ -37,8 +39,9 @@ export function SupportAccessToggle({ form }: SupportAccessToggleProps) {<FormItemLayouthideMessagename="allowSupportAccess"- className="px-6"+ className={className}layout="flex"+ align={align}label={<div className="flex items-center gap-x-2"><span className="text-foreground">Allow support access to your project</span>diff --git a/apps/studio/components/interfaces/Support/SupportForm.utils.tsx b/apps/studio/components/interfaces/Support/SupportForm.utils.tsxindex 9db7dd67cc2..d88874ffb46 100644--- a/apps/studio/components/interfaces/Support/SupportForm.utils.tsx+++ b/apps/studio/components/interfaces/Support/SupportForm.utils.tsx@@ -139,6 +139,18 @@ export type SupportFormUrlKeys = inferParserType<typeof supportFormUrlState>export const loadSupportFormInitialParams = createLoader(supportFormUrlState)+export function loadSupportFormInitialParamsFromObject(+ initialParams: Partial<SupportFormUrlKeys>+): SupportFormUrlKeys {+ const normalizedParams = Object.fromEntries(+ Object.entries(initialParams).flatMap(([key, value]) =>+ value == null ? [] : [[key, String(value)]]+ )+ )++ return loadSupportFormInitialParams(normalizedParams)+}+const serializeSupportFormInitialParams = createSerializer(supportFormUrlState)export function createSupportFormUrl(initialParams: Partial<SupportFormUrlKeys>) {diff --git a/apps/studio/components/interfaces/Support/SupportFormDirectEmailInfo.tsx b/apps/studio/components/interfaces/Support/SupportFormDirectEmailInfo.tsxnew file mode 100644index 00000000000..e6f9d8d4eee--- /dev/null+++ b/apps/studio/components/interfaces/Support/SupportFormDirectEmailInfo.tsx@@ -0,0 +1,52 @@+import { toast } from 'sonner'++import { NO_PROJECT_MARKER } from './SupportForm.utils'+import CopyButton from '@/components/ui/CopyButton'++interface SupportFormDirectEmailContentProps {+ projectRef: string | null+}++export function SupportFormDirectEmailContent({ projectRef }: SupportFormDirectEmailContentProps) {+ const hasProjectRef = projectRef && projectRef !== NO_PROJECT_MARKER++ return (+ <div className="text-sm text-foreground-light">+ <p className="flex items-center gap-x-1.5 flex-wrap">+ Please email us directly at+ <span className="inline-flex items-center gap-x-1">+ <a+ href={`mailto:[email protected]?subject=${encodeURIComponent('Support Request')}${hasProjectRef ? `${encodeURIComponent(' for Project ID: ')}${encodeURIComponent(projectRef)}` : ''}&body=${encodeURIComponent('Here is a detailed description of the problem I am experiencing and any other information that might be helpful...')}`}+ className="hover:text-foreground transition-colors duration-100"+ >+ <code className="text-code-inline !text-foreground-light underline decoration-foreground-lighter/50 hover:decoration-foreground-lighter/80 transition-colors duration-100">+ </code>+ </a>+ <CopyButton+ type="text"+ text="[email protected]"+ iconOnly+ onClick={() => toast.success('Copied email address to clipboard')}+ />+ </span>{' '}+ and include as much information as possible+ {hasProjectRef && (+ <>+ , along with project ID+ <span className="inline-flex items-center gap-x-1">+ <code className="text-code-inline !text-foreground-light">{projectRef}</code>+ <CopyButton+ iconOnly+ type="text"+ text={projectRef}+ onClick={() => toast.success('Copied project ID to clipboard')}+ />+ </span>+ </>+ )}+ .+ </p>+ </div>+ )+}diff --git a/apps/studio/components/interfaces/Support/SupportFormPage.tsx b/apps/studio/components/interfaces/Support/SupportFormPage.tsxindex 8c66fe3de72..0606331122d 100644--- a/apps/studio/components/interfaces/Support/SupportFormPage.tsx+++ b/apps/studio/components/interfaces/Support/SupportFormPage.tsx@@ -29,6 +29,8 @@ import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'import { useStateTransition } from '@/hooks/misc/useStateTransition'import { BASE_PATH, DOCS_URL } from '@/lib/constants'+export { SupportForm, SupportFormStatusButton } from './SupportSidebarForm'+function useSupportFormTelemetry() {const { mutate: sendEvent } = useSendEventMutation()@@ -97,7 +99,6 @@ function SupportFormPageContent() {<IncidentAdmonition isActive={hasActiveIncidents} />- {/* Only show AI Assistant and Discord CTAs if there are no active incidents and the user is still filling out the support form*/}{!isSuccess && !hasActiveIncidents && (<div className="flex flex-col gap-y-4"><AIAssistantOption projectRef={projectRef} organizationSlug={orgSlug} />@@ -134,7 +135,7 @@ function SupportFormHeader() {const isIncident = incidents.length > 0return (- <div className="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-y-2">+ <div className="flex flex-col items-start justify-between gap-y-2 sm:flex-row sm:items-center"><div className="flex items-center space-x-3"><SVG src={`${BASE_PATH}/img/supabase-logo.svg`} className="h-4 w-4" /><h3 className="m-0 text-lg">Supabase support</h3>diff --git a/apps/studio/components/interfaces/Support/SupportFormV2.tsx b/apps/studio/components/interfaces/Support/SupportFormV2.tsxindex a0c9d60b1f0..a81cd52d0c4 100644--- a/apps/studio/components/interfaces/Support/SupportFormV2.tsx+++ b/apps/studio/components/interfaces/Support/SupportFormV2.tsx@@ -236,14 +236,14 @@ export const SupportFormV2 = ({ form, initialError, state, dispatch }: SupportFo{DASHBOARD_LOG_CATEGORIES.includes(category) && (<>- <DashboardLogsToggle form={form} sanitizedLog={sanitizedLogSnapshot} />+ <DashboardLogsToggle form={form} sanitizedLog={sanitizedLogSnapshot} className="px-6" /><DialogSectionSeparator /></>)}{!!category && !DISABLE_SUPPORT_ACCESS_CATEGORIES.includes(category) && (<>- <SupportAccessToggle form={form} />+ <SupportAccessToggle form={form} className="px-6" /><DialogSectionSeparator /></>)}diff --git a/apps/studio/components/interfaces/Support/SupportFormV3.tsx b/apps/studio/components/interfaces/Support/SupportFormV3.tsxnew file mode 100644index 00000000000..095f2fe2933--- /dev/null+++ b/apps/studio/components/interfaces/Support/SupportFormV3.tsx@@ -0,0 +1,316 @@+// End of third-party imports+import { SupportCategories } from '@supabase/shared-types/out/constants'+import { useConstant, useFlag } from 'common'+import { CLIENT_LIBRARIES } from 'common/constants'+import { type Dispatch, type MouseEventHandler } from 'react'+import type { SubmitHandler, UseFormReturn } from 'react-hook-form'+import { Form, Separator } from 'ui'++import {+ AffectedServicesSelector,+ CATEGORIES_WITHOUT_AFFECTED_SERVICES,+} from './AffectedServicesSelector'+import { AttachmentUploadDisplay, useAttachmentUpload } from './AttachmentUpload'+import { CategoryAndSeverityInfo } from './CategoryAndSeverityInfo'+import { ClientLibraryInfo } from './ClientLibraryInfo'+import {+ DASHBOARD_LOG_CATEGORIES,+ getSanitizedBreadcrumbs,+ uploadDashboardLog,+} from './dashboard-logs'+import { DashboardLogsToggle } from './DashboardLogsToggle'+import { MessageField } from './MessageField'+import { OrganizationSelector } from './OrganizationSelector'+import { PlanExpectationInfoContent, ProjectAndPlanInfo } from './ProjectAndPlanInfo'+import { SubjectAndSuggestionsInfo } from './SubjectAndSuggestionsInfo'+import { SubmitButton } from './SubmitButton'+import { DISABLE_SUPPORT_ACCESS_CATEGORIES, SupportAccessToggle } from './SupportAccessToggle'+import type { SupportFormValues } from './SupportForm.schema'+import type { SupportFormActions, SupportFormState } from './SupportForm.state'+import {+ formatMessage,+ formatStudioVersion,+ getOrgSubscriptionPlan,+ NO_ORG_MARKER,+ NO_PROJECT_MARKER,+} from './SupportForm.utils'+import { SupportFormDirectEmailContent } from './SupportFormDirectEmailInfo'+import { getProjectAuthConfig } from '@/data/auth/auth-config-query'+import { useSendSupportTicketMutation } from '@/data/feedback/support-ticket-send'+import { type OrganizationPlanID } from '@/data/organizations/organization-query'+import { useOrganizationsQuery } from '@/data/organizations/organizations-query'+import { useGenerateAttachmentURLsMutation } from '@/data/support/generate-attachment-urls-mutation'+import { useDeploymentCommitQuery } from '@/data/utils/deployment-commit-query'+import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'+import { detectBrowser } from '@/lib/helpers'+import { useProfile } from '@/lib/profile'++const useIsSimplifiedForm = (slug: string, subscriptionPlanId?: OrganizationPlanID) => {+ const simplifiedSupportForm = useFlag('simplifiedSupportForm')++ if (subscriptionPlanId === 'platform') {+ return true+ }++ if (typeof simplifiedSupportForm === 'string') {+ const slugs = (simplifiedSupportForm as string).split(',').map((x) => x.trim())+ return slugs.includes(slug)+ }++ return false+}++interface SupportFormV3Props {+ form: UseFormReturn<SupportFormValues>+ initialError: string | null+ state: SupportFormState+ dispatch: Dispatch<SupportFormActions>+ selectedProjectRef?: string | null+}++export const SupportFormV3 = ({+ form,+ initialError,+ state,+ dispatch,+ selectedProjectRef,+}: SupportFormV3Props) => {+ const { profile } = useProfile()+ const respondToEmail = profile?.primary_email ?? 'your email'++ const { organizationSlug, projectRef, category, severity, subject, library } = form.watch()++ const selectedOrgSlug = organizationSlug === NO_ORG_MARKER ? null : organizationSlug+ const currentProjectRef = projectRef === NO_PROJECT_MARKER ? null : projectRef++ const { data: organizations } = useOrganizationsQuery()+ const subscriptionPlanId = getOrgSubscriptionPlan(organizations, selectedOrgSlug)+ const simplifiedSupportForm = useIsSimplifiedForm(organizationSlug, subscriptionPlanId)+ const showClientLibraries = useIsFeatureEnabled('support:show_client_libraries')++ const attachmentUpload = useAttachmentUpload()+ const { mutateAsync: uploadDashboardLogFn } = useGenerateAttachmentURLsMutation()++ const sanitizedLogSnapshot = useConstant(getSanitizedBreadcrumbs)++ const { data: commit } = useDeploymentCommitQuery({+ staleTime: 1000 * 60 * 10,+ })++ const { mutate: submitSupportTicket } = useSendSupportTicketMutation({+ onSuccess: (_, variables) => {+ dispatch({+ type: 'SUCCESS',+ sentProjectRef: variables.projectRef,+ sentOrgSlug: variables.organizationSlug,+ sentCategory: variables.category,+ })+ },+ onError: (error) => {+ dispatch({+ type: 'ERROR',+ message: error.message,+ })+ },+ })++ const onSubmit: SubmitHandler<SupportFormValues> = async (formValues) => {+ if (+ !simplifiedSupportForm &&+ showClientLibraries &&+ formValues.category === SupportCategories.PROBLEM &&+ !formValues.library+ ) {+ form.setError('library', {+ type: 'manual',+ message: "Please select the library that you're facing issues with",+ })+ return+ }++ dispatch({ type: 'SUBMIT' })++ const { attachDashboardLogs: formAttachDashboardLogs, ...values } = formValues+ const attachDashboardLogs =+ formAttachDashboardLogs && DASHBOARD_LOG_CATEGORIES.includes(values.category)++ const [attachments, dashboardLogUrl] = await Promise.all([+ attachmentUpload.createAttachments(),+ attachDashboardLogs+ ? uploadDashboardLog({+ userId: profile?.gotrue_id,+ sanitizedLogs: sanitizedLogSnapshot,+ uploadDashboardLogFn,+ })+ : undefined,+ ])++ const selectedLibrary = values.library+ ? CLIENT_LIBRARIES.find((library) => library.language === values.library)+ : undefined++ const payload = {+ ...values,+ organizationSlug: values.organizationSlug ?? NO_ORG_MARKER,+ projectRef: values.projectRef ?? NO_PROJECT_MARKER,+ allowSupportAccess:+ values.category && !DISABLE_SUPPORT_ACCESS_CATEGORIES.includes(values.category)+ ? values.allowSupportAccess+ : false,+ library:+ values.category === SupportCategories.PROBLEM && selectedLibrary !== undefined+ ? selectedLibrary.key+ : '',+ message: formatMessage({+ message: values.message,+ attachments,+ error: initialError,+ }),+ verified: true,+ tags: ['dashboard-support-form'],+ siteUrl: '',+ additionalRedirectUrls: '',+ affectedServices: CATEGORIES_WITHOUT_AFFECTED_SERVICES.includes(values.category)+ ? ''+ : values.affectedServices+ .split(',')+ .map((x) => x.trim().replace(/ /g, '_').toLowerCase())+ .join(';'),+ browserInformation: detectBrowser(),+ dashboardLogs: dashboardLogUrl?.[0],+ dashboardStudioVersion: commit ? formatStudioVersion(commit) : undefined,+ }++ if (values.projectRef !== NO_PROJECT_MARKER) {+ try {+ const authConfig = await getProjectAuthConfig({+ projectRef: values.projectRef,+ })+ payload.siteUrl = authConfig.SITE_URL+ payload.additionalRedirectUrls = authConfig.URI_ALLOW_LIST+ } catch {+ // Nice-to-have only+ }+ }++ submitSupportTicket(payload)+ }++ const handleFormSubmit = form.handleSubmit(onSubmit)++ const handleSubmitButtonClick: MouseEventHandler<HTMLButtonElement> = (event) => {+ handleFormSubmit(event)+ }++ const showPlanExpectationInfo =+ !!selectedOrgSlug &&+ subscriptionPlanId !== 'enterprise' &&+ subscriptionPlanId !== 'platform' &&+ category !== 'Login_issues'+ const showDirectEmailInfo = state.type !== 'success' && selectedProjectRef !== undefined++ return (+ <Form {...form}>+ <form id="support-form" className="flex min-h-full flex-col">+ <div className="flex flex-col gap-y-6">+ <OrganizationSelector form={form} orgSlug={organizationSlug} />+ <ProjectAndPlanInfo+ form={form}+ orgSlug={selectedOrgSlug}+ projectRef={currentProjectRef}+ subscriptionPlanId={subscriptionPlanId}+ category={category}+ />+ <CategoryAndSeverityInfo+ form={form}+ category={category}+ severity={severity}+ projectRef={projectRef}+ />+ </div>++ <div className="flex flex-col gap-y-6 py-6">+ <SubjectAndSuggestionsInfo form={form} subject={subject} category={category} />+ {!simplifiedSupportForm && (+ <>+ <ClientLibraryInfo form={form} library={library} category={category} />+ <AffectedServicesSelector form={form} category={category} />+ </>+ )}+ <MessageField form={form} originalError={initialError} />+ <AttachmentUploadDisplay {...attachmentUpload} />+ </div>++ {(DASHBOARD_LOG_CATEGORIES.includes(category) ||+ (!!category && !DISABLE_SUPPORT_ACCESS_CATEGORIES.includes(category)) ||+ showPlanExpectationInfo ||+ showDirectEmailInfo) && (+ <div className="flex flex-col gap-y-6">+ <Separator />++ {DASHBOARD_LOG_CATEGORIES.includes(category) && (+ <DashboardLogsToggle form={form} sanitizedLog={sanitizedLogSnapshot} align="right" />+ )}++ {!!category && !DISABLE_SUPPORT_ACCESS_CATEGORIES.includes(category) && (+ <SupportAccessToggle form={form} align="right" />+ )}++ {(showPlanExpectationInfo || showDirectEmailInfo) && (+ <SupportFormV3AdditionalInfoSection+ orgSlug={selectedOrgSlug}+ subscriptionPlanId={subscriptionPlanId}+ projectRef={currentProjectRef}+ showPlanExpectationInfo={showPlanExpectationInfo}+ showDirectEmailInfo={showDirectEmailInfo}+ />+ )}+ </div>+ )}++ <div className="sticky bottom-0 z-10 -mx-5 mt-6 border-t bg-panel-footer-light px-5 py-4">+ <SubmitButton+ isSubmitting={state.type === 'submitting'}+ userEmail={respondToEmail}+ onClick={handleSubmitButtonClick}+ descriptionClassName="pr-0"+ />+ </div>+ </form>+ </Form>+ )+}++interface SupportFormV3AdditionalInfoSectionProps {+ orgSlug: string | null+ subscriptionPlanId?: OrganizationPlanID+ projectRef: string | null+ showPlanExpectationInfo: boolean+ showDirectEmailInfo: boolean+}++function SupportFormV3AdditionalInfoSection({+ orgSlug,+ subscriptionPlanId,+ projectRef,+ showPlanExpectationInfo,+ showDirectEmailInfo,+}: SupportFormV3AdditionalInfoSectionProps) {+ return (+ <div className="flex flex-col gap-y-5">+ {showPlanExpectationInfo && orgSlug && (+ <div className="flex flex-col gap-y-2">+ <h5 className="text-foreground">Support varies by plan</h5>+ <PlanExpectationInfoContent orgSlug={orgSlug} planId={subscriptionPlanId} />+ </div>+ )}++ {showDirectEmailInfo && (+ <div className="flex flex-col gap-y-2">+ <h5 className="text-foreground">Having trouble submitting the form?</h5>+ <SupportFormDirectEmailContent projectRef={projectRef} />+ </div>+ )}+ </div>+ )+}diff --git a/apps/studio/components/interfaces/Support/SupportSidebarForm.tsx b/apps/studio/components/interfaces/Support/SupportSidebarForm.tsxnew file mode 100644index 00000000000..4d45bc006b2--- /dev/null+++ b/apps/studio/components/interfaces/Support/SupportSidebarForm.tsx@@ -0,0 +1,153 @@+import * as Sentry from '@sentry/nextjs'+import { Loader2 } from 'lucide-react'+import Link from 'next/link'+import { useCallback, useReducer } from 'react'+import { toast } from 'sonner'+import { Button, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'++import { IncidentAdmonition } from './IncidentAdmonition'+import { Success } from './Success'+import type { ExtendedSupportCategories } from './Support.constants'+import { createInitialSupportFormState, supportFormReducer } from './SupportForm.state'+import type { SupportFormUrlKeys } from './SupportForm.utils'+import { SupportFormV3 } from './SupportFormV3'+import { useSupportForm } from './useSupportForm'+import { useIncidentStatusQuery } from '@/data/platform/incident-status-query'+import { useSendEventMutation } from '@/data/telemetry/send-event-mutation'+import { useStateTransition } from '@/hooks/misc/useStateTransition'++function useSupportFormTelemetry() {+ const { mutate: sendEvent } = useSendEventMutation()++ return useCallback(+ ({+ projectRef,+ orgSlug,+ category,+ }: {+ projectRef: string | undefined+ orgSlug: string | undefined+ category: ExtendedSupportCategories+ }) =>+ sendEvent({+ action: 'support_ticket_submitted',+ properties: {+ ticketCategory: category,+ },+ groups: {+ project: projectRef,+ organization: orgSlug,+ },+ }),+ [sendEvent]+ )+}++interface SupportFormProps {+ initialParams?: Partial<SupportFormUrlKeys>+ onFinish?: () => void+}++export function SupportForm({ initialParams, onFinish }: SupportFormProps) {+ const [state, dispatch] = useReducer(supportFormReducer, undefined, createInitialSupportFormState)+ const { form, initialError, projectRef } = useSupportForm(dispatch, initialParams)++ const {+ data: allStatusPageEvents,+ isPending: isIncidentsPending,+ isError: isIncidentsError,+ } = useIncidentStatusQuery()+ const { incidents = [] } = allStatusPageEvents ?? {}+ const hasActiveIncidents =+ !isIncidentsPending && !isIncidentsError && incidents && incidents.length > 0++ const sendTelemetry = useSupportFormTelemetry()+ useStateTransition(state, 'submitting', 'success', (_, curr) => {+ toast.success('Support request sent. Thank you!')+ sendTelemetry({+ projectRef: curr.sentProjectRef,+ orgSlug: curr.sentOrgSlug,+ category: curr.sentCategory,+ })+ })++ useStateTransition(state, 'submitting', 'error', (_, curr) => {+ toast.error(`Failed to submit support ticket: ${curr.message}`)+ Sentry.captureMessage(`Failed to submit Support Form: ${curr.message}`)+ dispatch({ type: 'RETURN_TO_EDITING' })+ })++ const isSuccess = state.type === 'success'++ return (+ <div className="relative h-full overflow-y-auto overflow-x-hidden">+ <IncidentAdmonition+ isActive={hasActiveIncidents}+ className="rounded-none border-x-0 shadow-none"+ />+ <div className="min-h-full px-5 pt-5">+ <div className="flex flex-col gap-y-8">+ {isSuccess ? (+ <div className="pt-2">+ <Success+ selectedProject={projectRef ?? undefined}+ sentCategory={state.sentCategory}+ onFinish={onFinish}+ finishLabel={onFinish ? 'Done' : undefined}+ />+ </div>+ ) : (+ <SupportFormV3+ form={form}+ initialError={initialError}+ state={state}+ dispatch={dispatch}+ selectedProjectRef={projectRef}+ />+ )}+ </div>+ </div>+ </div>+ )+}++export function SupportFormStatusButton() {+ const { data: allStatusPageEvents, isPending: isLoading, isError } = useIncidentStatusQuery()+ const { incidents = [], maintenanceEvents = [] } = allStatusPageEvents ?? {}+ const isMaintenance = maintenanceEvents.length > 0+ const isIncident = incidents.length > 0++ return (+ <Tooltip>+ <TooltipTrigger asChild>+ <Button+ asChild+ type="default"+ size="tiny"+ icon={+ isLoading ? (+ <Loader2 className="animate-spin" />+ ) : (+ <div className={cn('h-2 w-2 rounded-full', isIncident ? 'bg-warning' : 'bg-brand')} />+ )+ }+ >+ <Link href="https://status.supabase.com/" target="_blank" rel="noreferrer">+ {isLoading+ ? 'Checking status'+ : isError+ ? 'Failed to check status'+ : isIncident+ ? 'Active incident ongoing'+ : isMaintenance+ ? 'Scheduled maintenance'+ : 'All systems operational'}+ </Link>+ </Button>+ </TooltipTrigger>+ <TooltipContent side="bottom" align="center">+ Check the Supabase status page+ </TooltipContent>+ </Tooltip>+ )+}diff --git a/apps/studio/components/interfaces/Support/__tests__/SupportFormPage.test.tsx b/apps/studio/components/interfaces/Support/__tests__/SupportFormPage.test.tsxindex 7f23f15cedc..a76533ad5af 100644--- a/apps/studio/components/interfaces/Support/__tests__/SupportFormPage.test.tsx+++ b/apps/studio/components/interfaces/Support/__tests__/SupportFormPage.test.tsx@@ -5,7 +5,7 @@ import { http, HttpResponse } from 'msw'import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'import { NO_ORG_MARKER, NO_PROJECT_MARKER } from '../SupportForm.utils'-import { SupportFormPage } from '../SupportFormPage'+import { SupportForm, SupportFormPage, SupportFormStatusButton } from '../SupportFormPage'// End of third-party importsimport { API_URL, BASE_PATH } from '@/lib/constants'@@ -188,6 +188,21 @@ const renderSupportFormPage = (options?: Parameters<typeof customRender>[1]) =>...options,})+const renderSupportForm = (+ props?: Parameters<typeof SupportForm>[0],+ options?: Parameters<typeof customRender>[1]+) =>+ customRender(<SupportForm {...props} />, {+ profileContext: createMockProfileContext(),+ ...options,+ })++const renderSupportFormStatusButton = (options?: Parameters<typeof customRender>[1]) =>+ customRender(<SupportFormStatusButton />, {+ profileContext: createMockProfileContext(),+ ...options,+ })+const getStatusLink = (screen: Screen) => {const statusLink = screen.getAllByRole('link')@@ -458,7 +473,7 @@ describe('SupportFormPage', () => {})test('shows system status: healthy', async () => {- renderSupportFormPage()+ renderSupportFormStatusButton()await waitFor(() => {expect(getStatusLink(screen)).toHaveTextContent('All systems operational')@@ -483,7 +498,7 @@ describe('SupportFormPage', () => {))- renderSupportFormPage()+ renderSupportFormStatusButton()await waitFor(() => {expect(getStatusLink(screen)).toHaveTextContent('Active incident ongoing')@@ -497,13 +512,24 @@ describe('SupportFormPage', () => {))- renderSupportFormPage()+ renderSupportFormStatusButton()await waitFor(() => {expect(getStatusLink(screen)).toHaveTextContent('Failed to check status')})})+ test('loading with initial params prefills the organization and project', async () => {+ renderSupportForm({ initialParams: { projectRef: 'project-3' } })++ await waitFor(() => {+ expect(getOrganizationSelector(screen)).toHaveTextContent('Organization 1')+ expect(screen.getByRole('combobox', { name: 'Select a project' })).toHaveTextContent(+ 'Project 3'+ )+ })+ })+test('loading a URL with a valid project slug prefills the organization and project', async () => {Object.defineProperty(window, 'location', {value: createMockLocation('?projectRef=project-3'),diff --git a/apps/studio/components/interfaces/Support/useSupportForm.ts b/apps/studio/components/interfaces/Support/useSupportForm.tsindex e224d02956f..a821910b250 100644--- a/apps/studio/components/interfaces/Support/useSupportForm.ts+++ b/apps/studio/components/interfaces/Support/useSupportForm.ts@@ -6,6 +6,7 @@ import { SupportFormSchema, type SupportFormValues } from './SupportForm.schema'import type { SupportFormActions } from './SupportForm.state'import {loadSupportFormInitialParams,+ loadSupportFormInitialParamsFromObject,NO_ORG_MARKER,NO_PROJECT_MARKER,selectInitialOrgAndProject,@@ -36,7 +37,10 @@ interface UseSupportFormResult {orgSlug: string | null}-export function useSupportForm(dispatch: Dispatch<SupportFormActions>): UseSupportFormResult {+export function useSupportForm(+ dispatch: Dispatch<SupportFormActions>,+ initialParams?: Partial<SupportFormUrlKeys>+): UseSupportFormResult {const form = useForm<SupportFormValues>({mode: 'onBlur',reValidateMode: 'onBlur',@@ -45,11 +49,15 @@ export function useSupportForm(dispatch: Dispatch<SupportFormActions>): UseSuppo})const urlParamsRef = useRef<SupportFormUrlKeys | null>(null)+ const providedInitialParamsRef = useRef(initialParams)const [initialError, setInitialError] = useState<string | null>(null)// Load initial values from URL paramsuseEffect(() => {- const params = loadSupportFormInitialParams(window.location.search)+ const params =+ providedInitialParamsRef.current !== undefined+ ? loadSupportFormInitialParamsFromObject(providedInitialParamsRef.current)+ : loadSupportFormInitialParams(window.location.search)urlParamsRef.current = paramssetInitialError(params.error ?? null)diff --git a/apps/studio/components/ui/HelpPanel/HelpOptionsList.test.tsx b/apps/studio/components/ui/HelpPanel/HelpOptionsList.test.tsxnew file mode 100644index 00000000000..e7ca56ec3c3--- /dev/null+++ b/apps/studio/components/ui/HelpPanel/HelpOptionsList.test.tsx@@ -0,0 +1,80 @@+import { screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { beforeEach, describe, expect, it, vi } from 'vitest'++import { HelpOptionsList } from './HelpOptionsList'+import { DOCS_URL } from '@/lib/constants'+import { customRender } from '@/tests/lib/custom-render'+import { routerMock } from '@/tests/lib/route-mock'++const { takeBreadcrumbSnapshotMock } = vi.hoisted(() => ({+ takeBreadcrumbSnapshotMock: vi.fn(),+}))++vi.mock('react-inlinesvg', () => ({+ __esModule: true,+ default: () => null,+}))++vi.mock('@/lib/breadcrumbs', () => ({+ takeBreadcrumbSnapshot: takeBreadcrumbSnapshotMock,+}))++describe('HelpOptionsList', () => {+ beforeEach(() => {+ routerMock.setCurrentUrl('/')+ takeBreadcrumbSnapshotMock.mockReset()+ vi.restoreAllMocks()+ })++ it('navigates to support after invoking the click callback by default', async () => {+ const onSupportClick = vi.fn()++ customRender(+ <HelpOptionsList+ isPlatform+ projectRef="project-1"+ supportLinkQueryParams={{ projectRef: 'project-1' }}+ onSupportClick={onSupportClick}+ />+ )++ await userEvent.click(screen.getByRole('button', { name: /contact support/i }))++ expect(onSupportClick).toHaveBeenCalledTimes(1)+ expect(takeBreadcrumbSnapshotMock).toHaveBeenCalledTimes(1)+ expect(routerMock.asPath).toBe('/support/new?projectRef=project-1')+ })++ it('allows the support callback to suppress navigation', async () => {+ customRender(+ <HelpOptionsList+ isPlatform+ projectRef="project-1"+ supportLinkQueryParams={{ projectRef: 'project-1' }}+ onSupportClick={() => false}+ />+ )++ await userEvent.click(screen.getByRole('button', { name: /contact support/i }))++ expect(takeBreadcrumbSnapshotMock).not.toHaveBeenCalled()+ expect(routerMock.asPath).toBe('/')+ })++ it('renders docs as an external link', () => {+ customRender(+ <HelpOptionsList+ isPlatform+ projectRef="project-1"+ supportLinkQueryParams={{ projectRef: 'project-1' }}+ />+ )++ const docsOption = screen.getByRole('link', { name: /docs/i })++ expect(docsOption).toHaveAttribute('href', `${DOCS_URL}/`)+ expect(docsOption).toHaveAttribute('target', '_blank')+ expect(docsOption).toHaveAttribute('rel', 'noreferrer noopener')+ })+})diff --git a/apps/studio/components/ui/HelpPanel/HelpOptionsList.tsx b/apps/studio/components/ui/HelpPanel/HelpOptionsList.tsxindex 3e8bab6ec1b..cdf9d48dfaa 100644--- a/apps/studio/components/ui/HelpPanel/HelpOptionsList.tsx+++ b/apps/studio/components/ui/HelpPanel/HelpOptionsList.tsx@@ -1,12 +1,16 @@-import { Activity, BookOpen, Mail, Wrench } from 'lucide-react'+import { Activity, BookOpen, ChevronRight, Mail, Wrench } from 'lucide-react'import { useRouter } from 'next/router'+import type { ReactNode } from 'react'import SVG from 'react-inlinesvg'-import { AiIconAnimation, ButtonGroup, ButtonGroupItem } from 'ui'+import { AiIconAnimation } from 'ui'import type { HelpOptionId } from './HelpPanel.constants'import { HELP_OPTION_IDS } from './HelpPanel.constants'import type { SupportFormUrlKeys } from '@/components/interfaces/Support/SupportForm.utils'-import { SupportLink } from '@/components/interfaces/Support/SupportLink'+import { createSupportFormUrl } from '@/components/interfaces/Support/SupportForm.utils'+import { ResourceItem } from '@/components/ui/Resource/ResourceItem'+import { ResourceList } from '@/components/ui/Resource/ResourceList'+import { takeBreadcrumbSnapshot } from '@/lib/breadcrumbs'import { DOCS_URL } from '@/lib/constants'const DISCORD_URL = 'https://discord.supabase.com'@@ -18,8 +22,15 @@ type HelpOptionsListProps = {projectRef: string | undefinedsupportLinkQueryParams: Partial<SupportFormUrlKeys> | undefinedonAssistantClick?: () => void- onSupportClick?: () => void- size?: 'tiny' | 'small'+ onSupportClick?: () => boolean | void+}++type HelpOption = {+ media: ReactNode+ title: string+ description: string+ href?: string+ onClick?: () => void}export const HelpOptionsList = ({@@ -29,7 +40,6 @@ export const HelpOptionsList = ({supportLinkQueryParams,onAssistantClick,onSupportClick,- size = 'tiny',}: HelpOptionsListProps) => {const router = useRouter()const basePath = router.basePath ?? ''@@ -44,96 +54,94 @@ export const HelpOptionsList = ({const filteredIds = ids.filter(include)+ const handleSupportClick = () => {+ const shouldNavigate = onSupportClick?.()+ if (shouldNavigate === false) {+ return+ }++ takeBreadcrumbSnapshot()+ router.push(createSupportFormUrl(supportLinkQueryParams ?? {}))+ }++ const renderOption = (title: string, description: string) => (+ <div className="flex flex-col gap-0.5">+ <p className="text-sm text-foreground">{title}</p>+ <p className="text-xs text-foreground-lighter">{description}</p>+ </div>+ )++ const options: Record<HelpOptionId, HelpOption> = {+ assistant: {+ media: <AiIconAnimation allowHoverEffect size={14} />,+ title: 'Supabase Assistant',+ description: 'Get guided help with your project directly in Studio.',+ onClick: onAssistantClick,+ },+ docs: {+ media: <BookOpen strokeWidth={1.5} size={14} />,+ title: 'Docs',+ description: 'Browse guides, references, and product documentation.',+ href: `${DOCS_URL}/`,+ },+ troubleshooting: {+ media: <Wrench strokeWidth={1.5} size={14} />,+ title: 'Troubleshooting',+ description: 'Find fixes for common platform issues and errors.',+ href: `${DOCS_URL}/guides/troubleshooting?products=platform`,+ },+ discord: {+ media: <SVG src={`${basePath}/img/discord-icon.svg`} className="h-4 w-4" />,+ title: 'Ask on Discord',+ description: 'Get help from the community on code-related questions.',+ href: DISCORD_URL,+ },+ status: {+ media: <Activity strokeWidth={1.5} size={14} />,+ title: 'Supabase status',+ description: 'Check incidents, maintenance, and uptime updates.',+ href: STATUS_URL,+ },+ support: {+ media: <Mail strokeWidth={1.5} size={14} />,+ title: 'Contact support',+ description: 'Reach support for account and platform issues.',+ onClick: handleSupportClick,+ },+ }+return (- <ButtonGroup className="w-full">+ <ResourceList className="rounded-none border-0 bg-transparent shadow-none">{filteredIds.map((id) => {- switch (id) {- case 'assistant':- return (- <ButtonGroupItem- key={id}- size={size}- icon={<AiIconAnimation allowHoverEffect size={14} />}- onClick={onAssistantClick}- >- Supabase Assistant- </ButtonGroupItem>- )- case 'docs':- return (- <ButtonGroupItem- key={id}- size={size}- icon={<BookOpen strokeWidth={1.5} size={14} />}- asChild- >- <a href={`${DOCS_URL}/`} target="_blank" rel="noreferrer">- Docs- </a>- </ButtonGroupItem>- )- case 'troubleshooting':- return (- <ButtonGroupItem- key={id}- size={size}- icon={<Wrench strokeWidth={1.5} size={14} />}- asChild- >- <a- href={`${DOCS_URL}/guides/troubleshooting?products=platform`}- target="_blank"- rel="noreferrer"- >- Troubleshooting- </a>- </ButtonGroupItem>- )- case 'discord':- return (- <ButtonGroupItem- key={id}- size={size}- icon={<SVG src={`${basePath}/img/discord-icon.svg`} className="h-4 w-4" />}- asChild- >- <a href={DISCORD_URL} target="_blank" rel="noreferrer">- Ask on Discord- </a>- </ButtonGroupItem>- )- case 'status':- return (- <ButtonGroupItem- key={id}- size={size}- icon={<Activity strokeWidth={1.5} size={14} />}- asChild- >- <a href={STATUS_URL} target="_blank" rel="noreferrer">- Supabase status- </a>- </ButtonGroupItem>- )- case 'support':- return (- <ButtonGroupItem- key={id}- size={size}- icon={<Mail strokeWidth={1.5} size={14} />}- asChild- >- <SupportLink queryParams={supportLinkQueryParams} onClick={onSupportClick}>- Contact support- </SupportLink>- </ButtonGroupItem>- )- default: {- void (id as never)- return null- }+ const option = options[id]++ if (option.href) {+ return (+ <ResourceItem+ key={id}+ className="!border-b"+ media={option.media}+ meta={<ChevronRight strokeWidth={1.5} size={16} />}+ href={option.href}+ target="_blank"+ rel="noreferrer noopener"+ >+ {renderOption(option.title, option.description)}+ </ResourceItem>+ )}++ return (+ <ResourceItem+ key={id}+ className="!border-b"+ media={option.media}+ onClick={option.onClick}+ >+ {renderOption(option.title, option.description)}+ </ResourceItem>+ )})}- </ButtonGroup>+ </ResourceList>)}diff --git a/apps/studio/components/ui/HelpPanel/HelpPanel.tsx b/apps/studio/components/ui/HelpPanel/HelpPanel.tsxindex b38bedef22a..3da35806c1e 100644--- a/apps/studio/components/ui/HelpPanel/HelpPanel.tsx+++ b/apps/studio/components/ui/HelpPanel/HelpPanel.tsx@@ -1,14 +1,18 @@import { IS_PLATFORM } from 'common'-import { X } from 'lucide-react'+import { ChevronLeft, X } from 'lucide-react'import Image from 'next/image'import { useRouter } from 'next/router'+import { useState } from 'react'import SVG from 'react-inlinesvg'-import { Button, cn, Separator } from 'ui'-import styleHandler from 'ui/src/lib/theme/styleHandler'+import { Button } from 'ui'import { ASSISTANT_SUGGESTIONS } from './HelpPanel.constants'import { HelpSection } from './HelpSection'import type { SupportFormUrlKeys } from '@/components/interfaces/Support/SupportForm.utils'+import {+ SupportForm,+ SupportFormStatusButton,+} from '@/components/interfaces/Support/SupportSidebarForm'import { SIDEBAR_KEYS } from '@/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import { useAiAssistantStateSnapshot } from '@/state/ai-assistant-state'@@ -26,72 +30,103 @@ export const HelpPanel = ({const snap = useAiAssistantStateSnapshot()const { openSidebar, closeSidebar } = useSidebarManagerSnapshot()const router = useRouter()-- const __styles = styleHandler('popover')+ const [view, setView] = useState<'home' | 'support'>('home')+ const isSupportView = view === 'support'+ const openAssistant = () => {+ onClose()+ openSidebar(SIDEBAR_KEYS.AI_ASSISTANT)+ snap.newChat(ASSISTANT_SUGGESTIONS)+ }return (- <div className="space-y-4">- <div className="flex text-xs items-center justify-between pl-4 pr-3 h-(--header-height) border-b">- <span>Help & Support</span>- <ButtonTooltip- type="text"- className="w-7 h-7"- onClick={() => closeSidebar(SIDEBAR_KEYS.HELP_PANEL)}- icon={<X strokeWidth={1.5} />}- tooltip={{ content: { side: 'bottom', text: 'Close' } }}- />- </div>- <HelpSection- className="px-4"- excludeIds={['discord']}- isPlatform={IS_PLATFORM}- projectRef={projectRef}- supportLinkQueryParams={supportLinkQueryParams}- onAssistantClick={() => {- onClose()- openSidebar(SIDEBAR_KEYS.AI_ASSISTANT)- snap.newChat(ASSISTANT_SUGGESTIONS)- }}- onSupportClick={onClose}- />- <Separator className={cn(__styles.separator, 'my-4')} />- <div className="flex flex-col gap-4">- <div className="px-4 flex flex-col gap-0.5">- <h5 className="text-foreground">Community support</h5>- <p className="text-xs text-foreground-lighter text-balance">- Our Discord community can help with code-related issues. Many questions are answered in- minutes.- </p>+ <div className="flex h-full flex-col overflow-hidden">+ <div className="flex h-(--header-height) items-center justify-between gap-2 border-b pl-4 pr-3">+ <div className="flex min-w-0 items-center gap-1.5 text-xs">+ {isSupportView && (+ <ButtonTooltip+ type="text"+ className="h-7 w-7"+ onClick={() => setView('home')}+ icon={<ChevronLeft strokeWidth={1.5} />}+ tooltip={{ content: { side: 'bottom', text: 'Back' } }}+ />+ )}+ <span className="truncate">{isSupportView ? 'Contact support' : 'Help & Support'}</span></div>- <div className="px-4">- <div- className="relative space-y-2 overflow-hidden rounded-sm px-4 py-4 pb-12 shadow-md"- style={{ background: '#404EED' }}- >- <a- href="https://discord.supabase.com"- target="_blank"- rel="noreferrer"- className="group dark block cursor-pointer"- >- <Image- className="absolute left-0 top-0 opacity-50 transition-opacity group-hover:opacity-40"- src={`${router.basePath}/img/support/discord-bg-small.jpg`}- layout="fill"- objectFit="cover"- alt="Discord illustration"- />- <Button- type="secondary"- size="tiny"- icon={<SVG src={`${router.basePath}/img/discord-icon.svg`} className="h-4 w-4" />}- >- <span style={{ color: '#404EED' }}>Join us on Discord</span>- </Button>- </a>- </div>+ <div className="flex items-center gap-2">+ <SupportFormStatusButton />+ <ButtonTooltip+ type="text"+ className="w-7 h-7"+ onClick={() => closeSidebar(SIDEBAR_KEYS.HELP_PANEL)}+ icon={<X strokeWidth={1.5} />}+ tooltip={{ content: { side: 'bottom', text: 'Close' } }}+ /></div></div>+ <div className="flex-1 overflow-hidden">+ {isSupportView ? (+ <SupportForm+ initialParams={supportLinkQueryParams}+ onFinish={() => {+ setView('home')+ }}+ />+ ) : (+ <div className="flex h-full flex-col overflow-y-auto pb-5">+ <HelpSection+ excludeIds={['discord']}+ isPlatform={IS_PLATFORM}+ projectRef={projectRef}+ supportLinkQueryParams={supportLinkQueryParams}+ onAssistantClick={openAssistant}+ onSupportClick={() => {+ setView('support')+ return false+ }}+ />+ <div className="flex flex-col gap-4 border-t pt-5">+ <div className="px-5 flex flex-col gap-0.5">+ <h5 className="text-foreground">Community support</h5>+ <p className="text-xs text-foreground-lighter text-balance">+ Our Discord community can help with code-related issues. Many questions are+ answered in minutes.+ </p>+ </div>+ <div className="px-5">+ <div+ className="relative space-y-2 overflow-hidden rounded-sm px-4 py-4 pb-12 shadow-md"+ style={{ background: '#404EED' }}+ >+ <a+ href="https://discord.supabase.com"+ target="_blank"+ rel="noreferrer"+ className="group dark block cursor-pointer"+ >+ <Image+ className="absolute left-0 top-0 opacity-50 transition-opacity group-hover:opacity-40"+ src={`${router.basePath}/img/support/discord-bg-small.jpg`}+ layout="fill"+ objectFit="cover"+ alt="Discord illustration"+ />+ <Button+ type="secondary"+ size="tiny"+ icon={+ <SVG src={`${router.basePath}/img/discord-icon.svg`} className="h-4 w-4" />+ }+ >+ <span style={{ color: '#404EED' }}>Join us on Discord</span>+ </Button>+ </a>+ </div>+ </div>+ </div>+ </div>+ )}+ </div></div>)}diff --git a/apps/studio/components/ui/HelpPanel/HelpSection.tsx b/apps/studio/components/ui/HelpPanel/HelpSection.tsxindex 7aff02ec049..26a762c88c1 100644--- a/apps/studio/components/ui/HelpPanel/HelpSection.tsx+++ b/apps/studio/components/ui/HelpPanel/HelpSection.tsx@@ -10,7 +10,7 @@ type HelpSectionProps = {projectRef: string | undefinedsupportLinkQueryParams: Partial<SupportFormUrlKeys> | undefinedonAssistantClick?: () => void- onSupportClick?: () => void+ onSupportClick?: () => boolean | voidclassName?: string}@@ -23,16 +23,8 @@ export const HelpSection = ({onSupportClick,className,}: HelpSectionProps) => {- const description = projectRef- ? 'Start with our Assistant, docs, or community.'- : 'Start with our docs or community.'-return (- <div className={cn('flex flex-col gap-4', className)}>- <div className="flex flex-col gap-0.5">- <h5 className="text-foreground">Need help with your project?</h5>- <p className="text-xs text-foreground-lighter text-balance">{description}</p>- </div>+ <div className={cn('flex flex-col', className)}><HelpOptionsListexcludeIds={excludeIds}isPlatform={isPlatform}@@ -40,7 +32,6 @@ export const HelpSection = ({supportLinkQueryParams={supportLinkQueryParams}onAssistantClick={onAssistantClick}onSupportClick={onSupportClick}- size="tiny"/></div>)diff --git a/apps/studio/components/ui/Resource/ResourceItem.tsx b/apps/studio/components/ui/Resource/ResourceItem.tsxindex 73bddce051d..0f7b76a315a 100644--- a/apps/studio/components/ui/Resource/ResourceItem.tsx+++ b/apps/studio/components/ui/Resource/ResourceItem.tsx@@ -1,5 +1,6 @@import { ChevronRight, MoreVertical } from 'lucide-react'-import { forwardRef, HTMLAttributes, ReactNode } from 'react'+import Link from 'next/link'+import { forwardRef, HTMLAttributes, KeyboardEvent, ReactNode } from 'react'import {Button,CardContent,@@ -21,22 +22,43 @@ export interface ResourceItemProps extends HTMLAttributes<HTMLDivElement> {onClick?: () => voidchildren?: ReactNodeactions?: ResourceAction[]+ href?: string+ target?: string+ rel?: string}export const ResourceItem = forwardRef<HTMLDivElement, ResourceItemProps>(- ({ media, meta, onClick, children, className, actions, ...props }, ref) => {- return (- <CardContent- ref={ref}- className={cn(- 'flex items-center justify-between text-sm gap-4',- 'border-b-0!',- onClick && 'cursor-pointer transition-colors duration-150 hover:bg-surface-200',- className- )}- onClick={onClick}- {...props}- >+ (+ {+ media,+ meta,+ onClick,+ children,+ className,+ actions,+ href,+ target,+ rel,+ onKeyDown,+ role,+ tabIndex,+ ...props+ },+ ref+ ) => {+ const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {+ onKeyDown?.(event)++ if (event.defaultPrevented || !onClick || event.target !== event.currentTarget) return++ if (event.key === 'Enter' || event.key === ' ') {+ event.preventDefault()+ onClick()+ }+ }++ const content = (+ <>{media && (<div className="text-foreground-light flex items-center justify-center">{media}</div>)}@@ -71,6 +93,40 @@ export const ResourceItem = forwardRef<HTMLDivElement, ResourceItemProps>() : (onClick && <ChevronRight strokeWidth={1.5} size={16} />)}+ </>+ )++ const rootClassName = cn(+ 'flex items-center justify-between text-sm gap-4',+ 'border-b-0!',+ (onClick || href) && 'cursor-pointer transition-colors duration-150 hover:bg-surface-200',+ className+ )++ if (href) {+ return (+ <Link+ href={href}+ target={target}+ rel={rel}+ className={cn('py-4 px-(--card-padding-x) border-b last:border-none', rootClassName)}+ >+ {content}+ </Link>+ )+ }++ return (+ <CardContent+ ref={ref}+ className={rootClassName}+ onClick={onClick}+ onKeyDown={handleKeyDown}+ role={onClick ? 'button' : role}+ tabIndex={onClick ? (tabIndex ?? 0) : tabIndex}+ {...props}+ >+ {content}</CardContent>)}diff --git a/apps/studio/components/ui/Resource/ResourceList.tsx b/apps/studio/components/ui/Resource/ResourceList.tsxindex 9bd90cdc76c..2acff847137 100644--- a/apps/studio/components/ui/Resource/ResourceList.tsx+++ b/apps/studio/components/ui/Resource/ResourceList.tsx@@ -8,8 +8,12 @@ export interface ResourceListProps extends HTMLAttributes<HTMLDivElement> {export const ResourceList = forwardRef<HTMLDivElement, ResourceListProps>(({ children, className, ...props }, ref) => {return (- <Card ref={ref} className="overflow-hidden" {...props}>- <div className={className}>{children}</div>+ <Card+ ref={ref}+ className={['overflow-hidden', className].filter(Boolean).join(' ')}+ {...props}+ >+ {children}</Card>)}diff --git a/apps/studio/hooks/misc/useStateTransition.ts b/apps/studio/hooks/misc/useStateTransition.tsindex 08235b095b9..13a6b24c73b 100644--- a/apps/studio/hooks/misc/useStateTransition.ts+++ b/apps/studio/hooks/misc/useStateTransition.ts@@ -1,4 +1,4 @@-import { useRef } from 'react'+import { useEffect, useRef } from 'react'export function useStateTransition<State extends { type: string },@@ -14,14 +14,17 @@ export function useStateTransition<) => void): void {const prevState = useRef(state)- const savedPrevState = prevState.current- const shouldRunCallback = savedPrevState.type === prevTest && state.type === newTest- prevState.current = state- if (shouldRunCallback) {- cb(- savedPrevState as Extract<State, { type: PrevType }>,- state as Extract<State, { type: NewType }>- )- }+ useEffect(() => {+ const savedPrevState = prevState.current++ if (savedPrevState.type === prevTest && state.type === newTest) {+ cb(+ savedPrevState as Extract<State, { type: PrevType }>,+ state as Extract<State, { type: NewType }>+ )+ }++ prevState.current = state+ }, [cb, newTest, prevTest, state])}