Skip to content

Commit a87387b

Browse files
monicakhjoshenlim
andauthored
feat: show "Allow support access to your project" toggle for all support categories (supabase#42254)
Previously, the “Allow support access to your project” toggle was only shown for specific issue categories in our support form. This change makes the toggle available for all categories. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Support access toggle and submission now suppress support access for Account Deletion, Sales Enquiry, and Refund categories. * **Refactor** * Reworked category gating so UI visibility and submitted payload consistently respect the disabled-category list. * **UI** * Category list updated—"Others" removed and category options adjusted so all available options are shown. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
1 parent 88ed2aa commit a87387b

6 files changed

Lines changed: 43 additions & 65 deletions

File tree

apps/studio/components/interfaces/Support/CategoryAndSeverityInfo.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import type { UseFormReturn } from 'react-hook-form'
21
// End of third-party imports
3-
42
import { SupportCategories } from '@supabase/shared-types/out/constants'
53
import { InlineLink } from 'components/ui/InlineLink'
4+
import type { UseFormReturn } from 'react-hook-form'
65
import {
7-
cn,
86
FormControl_Shadcn_,
97
FormField_Shadcn_,
10-
Select_Shadcn_,
118
SelectContent_Shadcn_,
129
SelectGroup_Shadcn_,
1310
SelectItem_Shadcn_,
1411
SelectTrigger_Shadcn_,
1512
SelectValue_Shadcn_,
13+
Select_Shadcn_,
14+
cn,
1615
} from 'ui'
1716
import { Admonition } from 'ui-patterns/admonition'
1817
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
18+
1919
import {
2020
CATEGORY_OPTIONS,
2121
type ExtendedSupportCategories,
@@ -91,7 +91,7 @@ function CategorySelector({ form }: CategorySelectorProps) {
9191
</SelectTrigger_Shadcn_>
9292
<SelectContent_Shadcn_>
9393
<SelectGroup_Shadcn_>
94-
{CATEGORY_OPTIONS.filter((option) => !option.hidden).map((option) => (
94+
{CATEGORY_OPTIONS.map((option) => (
9595
<SelectItem_Shadcn_ key={option.value} value={option.value}>
9696
{option.label}
9797
<span className="block text-xs text-foreground-lighter">

apps/studio/components/interfaces/Support/LinkSupportTicketForm.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import { zodResolver } from '@hookform/resolvers/zod'
2+
import { useLinkSupportTicketMutation } from 'data/feedback/link-support-ticket-mutation'
3+
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
24
import { Link2 } from 'lucide-react'
35
import { useEffect } from 'react'
46
import type { SubmitHandler } from 'react-hook-form'
57
import { useForm } from 'react-hook-form'
68
import { toast } from 'sonner'
7-
8-
import { useLinkSupportTicketMutation } from 'data/feedback/link-support-ticket-mutation'
9-
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
109
import {
1110
Button,
1211
DialogSectionSeparator,
13-
Form_Shadcn_,
1412
FormControl_Shadcn_,
1513
FormField_Shadcn_,
14+
Form_Shadcn_,
1615
Input_Shadcn_,
1716
} from 'ui'
1817
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
18+
1919
import { CategoryAndSeverityInfo } from './CategoryAndSeverityInfo'
2020
import {
2121
LinkSupportTicketFormSchema,
2222
type LinkSupportTicketFormValues,
2323
} from './LinkSupportTicketForm.schema'
2424
import { OrganizationSelector } from './OrganizationSelector'
2525
import { ProjectAndPlanInfo } from './ProjectAndPlanInfo'
26-
import { SUPPORT_ACCESS_CATEGORIES, SupportAccessToggle } from './SupportAccessToggle'
27-
import { getOrgSubscriptionPlan, NO_ORG_MARKER, NO_PROJECT_MARKER } from './SupportForm.utils'
26+
import { DISABLE_SUPPORT_ACCESS_CATEGORIES, SupportAccessToggle } from './SupportAccessToggle'
27+
import { NO_ORG_MARKER, NO_PROJECT_MARKER, getOrgSubscriptionPlan } from './SupportForm.utils'
2828

2929
interface LinkSupportTicketFormProps {
3030
conversationId: string
@@ -88,9 +88,10 @@ export const LinkSupportTicketForm = ({
8888
? values.projectRef
8989
: undefined,
9090
category: values.category,
91-
allow_support_access: SUPPORT_ACCESS_CATEGORIES.includes(values.category)
92-
? values.allowSupportAccess
93-
: false,
91+
allow_support_access:
92+
values.category && !DISABLE_SUPPORT_ACCESS_CATEGORIES.includes(values.category)
93+
? values.allowSupportAccess
94+
: false,
9495
})
9596
}
9697

@@ -153,7 +154,7 @@ export const LinkSupportTicketForm = ({
153154

154155
<DialogSectionSeparator />
155156

156-
{SUPPORT_ACCESS_CATEGORIES.includes(category) && (
157+
{!!category && !DISABLE_SUPPORT_ACCESS_CATEGORIES.includes(category) && (
157158
<>
158159
<div className="py-4">
159160
<SupportAccessToggle form={form as any} />

apps/studio/components/interfaces/Support/Support.constants.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export const CATEGORY_OPTIONS: {
1010
label: string
1111
description: string
1212
query?: string
13-
hidden?: boolean
1413
}[] = [
1514
{
1615
value: SupportCategories.PROBLEM,
@@ -78,13 +77,6 @@ export const CATEGORY_OPTIONS: {
7877
query: undefined,
7978
},
8079
]),
81-
{
82-
value: 'Others' as const,
83-
label: 'Others',
84-
description: 'Issues that are not related to any of the other categories',
85-
query: undefined,
86-
hidden: true,
87-
},
8880
]
8981

9082
export const SEVERITY_OPTIONS = [

apps/studio/components/interfaces/Support/SupportAccessToggle.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import { ChevronRight } from 'lucide-react'
2-
import Link from 'next/link'
3-
import type { UseFormReturn } from 'react-hook-form'
41
// End of third-party imports
52

63
import { SupportCategories } from '@supabase/shared-types/out/constants'
4+
import { ChevronRight } from 'lucide-react'
5+
import Link from 'next/link'
6+
import type { UseFormReturn } from 'react-hook-form'
77
import {
88
Badge,
9-
Collapsible_Shadcn_,
109
CollapsibleContent_Shadcn_,
1110
CollapsibleTrigger_Shadcn_,
11+
Collapsible_Shadcn_,
1212
FormField_Shadcn_,
1313
Switch,
1414
} from 'ui'
1515
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
16+
1617
import type { ExtendedSupportCategories } from './Support.constants'
1718
import type { SupportFormValues } from './SupportForm.schema'
1819

19-
export const SUPPORT_ACCESS_CATEGORIES: ExtendedSupportCategories[] = [
20-
SupportCategories.DATABASE_UNRESPONSIVE,
21-
SupportCategories.PERFORMANCE_ISSUES,
22-
SupportCategories.PROBLEM,
23-
SupportCategories.DASHBOARD_BUG,
20+
export const DISABLE_SUPPORT_ACCESS_CATEGORIES: ExtendedSupportCategories[] = [
21+
SupportCategories.ACCOUNT_DELETION,
22+
SupportCategories.SALES_ENQUIRY,
23+
SupportCategories.REFUND,
2424
]
2525

2626
interface SupportAccessToggleProps {

apps/studio/components/interfaces/Support/SupportFormV2.tsx

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import { useEffect, type Dispatch, type MouseEventHandler } from 'react'
2-
import type { SubmitHandler, UseFormReturn } from 'react-hook-form'
31
// End of third-party imports
4-
52
import { SupportCategories } from '@supabase/shared-types/out/constants'
63
import { useConstant, useFlag } from 'common'
74
import { CLIENT_LIBRARIES } from 'common/constants'
@@ -13,7 +10,10 @@ import { useGenerateAttachmentURLsMutation } from 'data/support/generate-attachm
1310
import { useDeploymentCommitQuery } from 'data/utils/deployment-commit-query'
1411
import { detectBrowser } from 'lib/helpers'
1512
import { useProfile } from 'lib/profile'
13+
import { type Dispatch, type MouseEventHandler } from 'react'
14+
import type { SubmitHandler, UseFormReturn } from 'react-hook-form'
1615
import { DialogSectionSeparator, Form_Shadcn_ } from 'ui'
16+
1717
import {
1818
AffectedServicesSelector,
1919
CATEGORIES_WITHOUT_AFFECTED_SERVICES,
@@ -27,15 +27,15 @@ import { OrganizationSelector } from './OrganizationSelector'
2727
import { ProjectAndPlanInfo } from './ProjectAndPlanInfo'
2828
import { SubjectAndSuggestionsInfo } from './SubjectAndSuggestionsInfo'
2929
import { SubmitButton } from './SubmitButton'
30-
import { SUPPORT_ACCESS_CATEGORIES, SupportAccessToggle } from './SupportAccessToggle'
30+
import { DISABLE_SUPPORT_ACCESS_CATEGORIES, SupportAccessToggle } from './SupportAccessToggle'
3131
import type { SupportFormValues } from './SupportForm.schema'
3232
import type { SupportFormActions, SupportFormState } from './SupportForm.state'
3333
import {
34+
NO_ORG_MARKER,
35+
NO_PROJECT_MARKER,
3436
formatMessage,
3537
formatStudioVersion,
3638
getOrgSubscriptionPlan,
37-
NO_ORG_MARKER,
38-
NO_PROJECT_MARKER,
3939
} from './SupportForm.utils'
4040
import {
4141
DASHBOARD_LOG_CATEGORIES,
@@ -128,12 +128,12 @@ export const SupportFormV2 = ({ form, initialError, state, dispatch }: SupportFo
128128

129129
const payload = {
130130
...values,
131-
category,
132131
organizationSlug: values.organizationSlug ?? NO_ORG_MARKER,
133132
projectRef: values.projectRef ?? NO_PROJECT_MARKER,
134-
allowSupportAccess: SUPPORT_ACCESS_CATEGORIES.includes(values.category)
135-
? values.allowSupportAccess
136-
: false,
133+
allowSupportAccess:
134+
values.category && !DISABLE_SUPPORT_ACCESS_CATEGORIES.includes(values.category)
135+
? values.allowSupportAccess
136+
: false,
137137
library:
138138
values.category === SupportCategories.PROBLEM && selectedLibrary !== undefined
139139
? selectedLibrary.key
@@ -179,15 +179,6 @@ export const SupportFormV2 = ({ form, initialError, state, dispatch }: SupportFo
179179
handleFormSubmit(event)
180180
}
181181

182-
useEffect(() => {
183-
if (simplifiedSupportForm) {
184-
form.setValue('category', 'Others')
185-
} else {
186-
form.setValue('category', '' as any)
187-
}
188-
// eslint-disable-next-line react-hooks/exhaustive-deps
189-
}, [simplifiedSupportForm])
190-
191182
return (
192183
<Form_Shadcn_ {...form}>
193184
<form id="support-form" className="flex flex-col gap-y-6">
@@ -202,14 +193,12 @@ export const SupportFormV2 = ({ form, initialError, state, dispatch }: SupportFo
202193
subscriptionPlanId={subscriptionPlanId}
203194
category={category}
204195
/>
205-
{!simplifiedSupportForm && (
206-
<CategoryAndSeverityInfo
207-
form={form}
208-
category={category}
209-
severity={severity}
210-
projectRef={projectRef}
211-
/>
212-
)}
196+
<CategoryAndSeverityInfo
197+
form={form}
198+
category={category}
199+
severity={severity}
200+
projectRef={projectRef}
201+
/>
213202
</div>
214203

215204
<DialogSectionSeparator />
@@ -235,7 +224,7 @@ export const SupportFormV2 = ({ form, initialError, state, dispatch }: SupportFo
235224
</>
236225
)}
237226

238-
{SUPPORT_ACCESS_CATEGORIES.includes(category) && (
227+
{!!category && !DISABLE_SUPPORT_ACCESS_CATEGORIES.includes(category) && (
239228
<>
240229
<SupportAccessToggle form={form} />
241230
<DialogSectionSeparator />

apps/studio/components/interfaces/Support/__tests__/SupportFormPage.test.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -891,10 +891,6 @@ describe('SupportFormPage', () => {
891891
await userEvent.clear(messageField)
892892
await userEvent.type(messageField, 'MFA challenge fails with an unknown error code')
893893

894-
expect(
895-
screen.queryByRole('switch', { name: /allow support access to your project/i })
896-
).toBeNull()
897-
898894
await userEvent.click(getSubmitButton(screen))
899895

900896
await waitFor(() => {
@@ -910,7 +906,7 @@ describe('SupportFormPage', () => {
910906
organizationSlug: 'org-2',
911907
library: '',
912908
affectedServices: '',
913-
allowSupportAccess: false,
909+
allowSupportAccess: true,
914910
verified: true,
915911
tags: ['dashboard-support-form'],
916912
siteUrl: 'https://project-2.supabase.dev',

0 commit comments

Comments
 (0)