Skip to content

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

Add compulsory org field and optional allow support access fields to support form

Joshen Lim83338852689c
diff --git a/studio/components/interfaces/Support/SupportForm.tsx b/studio/components/interfaces/Support/SupportForm.tsx
index c6b69ba3084..7e82751b889 100644
--- a/studio/components/interfaces/Support/SupportForm.tsx
+++ b/studio/components/interfaces/Support/SupportForm.tsx
@@ -12,10 +12,11 @@ import {
IconLoader,
IconAlertCircle,
IconExternalLink,
+ Checkbox,
} from 'ui'
import { CLIENT_LIBRARIES } from 'common/constants'
-import { Project } from 'types'
+import { Organization, Project } from 'types'
import { useStore, useFlag } from 'hooks'
import { post, get } from 'lib/common/fetch'
import { API_URL, PRICING_TIER_PRODUCT_IDS } from 'lib/constants'
@@ -50,9 +51,14 @@ const SupportForm: FC<Props> = ({ setSentCategory }) => {
const sortedOrganizations = app.organizations.list()
const sortedProjects = app.projects.list()
- const projectDefaults: Partial<Project>[] = [{ ref: 'no-project', name: 'No specific project' }]
const isInitialized = app.projects.isInitialized
+ const projectDefaults: Partial<Project>[] = [{ ref: 'no-project', name: 'No specific project' }]
+ const orgDefaults: Partial<Organization>[] = [
+ { slug: 'no-organization', name: 'No specific organization' },
+ ]
+
const projects = [...sortedProjects, ...projectDefaults]
+ const organizations = [...sortedOrganizations, ...orgDefaults]
const planNames = {
[PRICING_TIER_PRODUCT_IDS.FREE]: 'Free',
@@ -84,18 +90,29 @@ const SupportForm: FC<Props> = ({ setSentCategory }) => {
const selectedCategory = CATEGORY_OPTIONS.find((option) => {
if (option.value.toLowerCase() === ((category as string) ?? '').toLowerCase()) return option
})
+
+ const initialProjectRef =
+ selectedProject !== undefined
+ ? selectedProject.ref
+ : sortedProjects.length > 0
+ ? sortedProjects[0].ref
+ : 'no-project'
+ const initialOrganizationSlug =
+ initialProjectRef !== 'no-project'
+ ? sortedOrganizations.find((org) => {
+ const project = sortedProjects.find((project) => project.ref === initialProjectRef)
+ return org.id === project?.organization_id
+ })?.slug
+ : 'no-organization'
const initialValues = {
category: selectedCategory !== undefined ? selectedCategory.value : CATEGORY_OPTIONS[0].value,
severity: 'Low',
- projectRef:
- selectedProject !== undefined
- ? selectedProject.ref
- : sortedProjects.length > 0
- ? sortedProjects[0].ref
- : 'no-project',
+ projectRef: initialProjectRef,
+ organizationSlug: initialOrganizationSlug,
library: 'no-library',
subject: subject ?? '',
message: '',
+ allowSupportAccess: false,
}
const onFilesUpload = async (event: ChangeEvent<HTMLInputElement>) => {
@@ -126,11 +143,14 @@ const SupportForm: FC<Props> = ({ setSentCategory }) => {
}
const onValidate = (values: any) => {
+ console.log('onValidate', values)
const errors: any = {}
if (!values.subject) errors.subject = 'Please add a subject heading'
if (!values.message) errors.message = "Please add a message about the issue that you're facing"
if (values.category === 'Problem' && values.library === 'no-library')
errors.library = "Please select the library that you're facing issues with"
+ if (values.projectRef === 'no-project' && values.organizationSlug === 'no-organization')
+ errors.organizationSlug = 'Please select an organization'
return errors
}
@@ -178,11 +198,10 @@ const SupportForm: FC<Props> = ({ setSentCategory }) => {
return (
<Form id="support-form" initialValues={initialValues} validate={onValidate} onSubmit={onSubmit}>
- {({ isSubmitting, values }: any) => {
+ {({ isSubmitting, resetForm, values }: any) => {
const selectedCategory = CATEGORY_OPTIONS.find(
(category) => category.value === values.category
)
-
const selectedLibrary = CLIENT_LIBRARIES.find(
(library) => library.language === values.library
)
@@ -200,8 +219,20 @@ const SupportForm: FC<Props> = ({ setSentCategory }) => {
['Performance', 'Problem'].includes(values.category)
useEffect(() => {
- if (selectedProject && !selectedProject.subscription_tier) {
- app.projects.fetchSubscriptionTier(selectedProject as Project)
+ if (values.projectRef === 'no-project') {
+ const updatedValues = { ...values, organizationSlug: sortedOrganizations[0].slug }
+ resetForm({ values: updatedValues, initialValues: updatedValues })
+ } else if (selectedProject) {
+ if (!selectedProject.subscription_tier) {
+ app.projects.fetchSubscriptionTier(selectedProject as Project)
+ }
+ const organization = organizations.find(
+ (org) => org.id === selectedProject.organization_id
+ )
+ if (organization) {
+ const updatedValues = { ...values, organizationSlug: organization.slug }
+ resetForm({ values: updatedValues, initialValues: updatedValues })
+ }
}
}, [values.projectRef])
@@ -284,6 +315,28 @@ const SupportForm: FC<Props> = ({ setSentCategory }) => {
)}
</div>
+ {values.projectRef === 'no-project' && (
+ <div className="px-6">
+ <Listbox
+ id="organizationSlug"
+ layout="vertical"
+ label="Which organization is affected?"
+ >
+ {organizations.map((option) => {
+ return (
+ <Listbox.Option
+ key={`option-${option.slug}`}
+ label={option.name || ''}
+ value={option.slug}
+ >
+ <span>{option.name}</span>
+ </Listbox.Option>
+ )
+ })}
+ </Listbox>
+ </div>
+ )}
+
{selectedProject?.subscription_tier === PRICING_TIER_PRODUCT_IDS.FREE && (
<div className="px-6">
<InformationBox
@@ -328,71 +381,105 @@ const SupportForm: FC<Props> = ({ setSentCategory }) => {
{!isDisabled ? (
<>
- <div className="px-6">
- <Input
- id="subject"
- label="Subject"
- placeholder="Summary of the problem you have"
+ {['Performance'].includes(values.category) ? (
+ <DisabledStateForFreeTier
+ category={selectedCategory?.label ?? ''}
+ projectRef={values.projectRef}
/>
- </div>
- {values.category === 'Problem' && (
- <div className="px-6">
- <Listbox
- id="library"
- layout="vertical"
- label="Which library are you having issues with?"
- >
- <Listbox.Option
- disabled
- label="Please select a library"
- value="no-library"
- className="min-w-[500px]"
- >
- <span>Please select a library</span>
- </Listbox.Option>
- {CLIENT_LIBRARIES.map((option, i) => {
- return (
+ ) : (
+ <>
+ <div className="px-6">
+ <Input
+ id="subject"
+ label="Subject"
+ placeholder="Summary of the problem you have"
+ />
+ </div>
+ {values.category === 'Problem' && (
+ <div className="px-6">
+ <Listbox
+ id="library"
+ layout="vertical"
+ label="Which library are you having issues with?"
+ >
<Listbox.Option
- key={`option-${option.key}`}
- label={option.language}
- value={option.language}
+ disabled
+ label="Please select a library"
+ value="no-library"
className="min-w-[500px]"
>
- <span>{option.language}</span>
+ <span>Please select a library</span>
</Listbox.Option>
- )
- })}
- </Listbox>
- </div>
- )}
+ {CLIENT_LIBRARIES.map((option, i) => {
+ return (
+ <Listbox.Option
+ key={`option-${option.key}`}
+ label={option.language}
+ value={option.language}
+ className="min-w-[500px]"
+ >
+ <span>{option.language}</span>
+ </Listbox.Option>
+ )
+ })}
+ </Listbox>
+ </div>
+ )}
- {selectedLibrary !== undefined && (
- <div className="px-6 space-y-4 !mt-4">
- <div className="space-y-2">
- <p className="text-sm text-scale-1100">
- Found an issue or a bug? Try searching our Github issues or submit a new
- one.
- </p>
- </div>
- <div className="flex items-center space-x-4 overflow-x-auto">
- {selectedClientLibraries?.map((library) => {
- const libraryLanguage =
- values.library === 'Dart (Flutter)'
- ? library.name.split('-')[1]
- : values.library
- return (
+ {selectedLibrary !== undefined && (
+ <div className="px-6 space-y-4 !mt-4">
+ <div className="space-y-2">
+ <p className="text-sm text-scale-1100">
+ Found an issue or a bug? Try searching our Github issues or submit a new
+ one.
+ </p>
+ </div>
+ <div className="flex items-center space-x-4 overflow-x-auto">
+ {selectedClientLibraries?.map((library) => {
+ const libraryLanguage =
+ values.library === 'Dart (Flutter)'
+ ? library.name.split('-')[1]
+ : values.library
+ return (
+ <div
+ key={library.name}
+ className="w-[230px] min-w-[230px] min-h-[128px] rounded border border-scale-600 bg-scale-300 space-y-3 px-4 py-3"
+ >
+ <div className="space-y-1">
+ <p className="text-sm">{library.name}</p>
+ <p className="text-sm text-scale-1100">
+ For issues regarding the {libraryLanguage} client library
+ </p>
+ </div>
+ <div>
+ <Link href={library.url}>
+ <a target="_blank">
+ <Button
+ type="default"
+ icon={<IconExternalLink size={14} strokeWidth={1.5} />}
+ >
+ View Github issues
+ </Button>
+ </a>
+ </Link>
+ </div>
+ </div>
+ )
+ })}
<div
- key={library.name}
- className="w-[230px] min-w-[230px] min-h-[128px] rounded border border-scale-600 bg-scale-300 space-y-3 px-4 py-3"
+ className={[
+ 'px-4 py-3 rounded border border-scale-600 bg-scale-300',
+ 'w-[230px] min-w-[230px] min-h-[128px] flex flex-col justify-between space-y-3',
+ ].join(' ')}
>
<div className="space-y-1">
- <p className="text-sm">{library.name}</p>
+ <p className="text-sm">supabase</p>
<p className="text-sm text-scale-1100">
- For issues regarding the {libraryLanguage} client library
+ For any issues about our API
</p>
</div>
<div>
- <Link href={library.url}>
+ <Link href="https://github.com/supabase/supabase">
<a target="_blank">
<Button
type="default"
@@ -404,125 +491,108 @@ const SupportForm: FC<Props> = ({ setSentCategory }) => {
</Link>
</div>
</div>
- )
- })}
- <div
- className={[
- 'px-4 py-3 rounded border border-scale-600 bg-scale-300',
- 'w-[230px] min-w-[230px] min-h-[128px] flex flex-col justify-between space-y-3',
- ].join(' ')}
- >
- <div className="space-y-1">
- <p className="text-sm">supabase</p>
- <p className="text-sm text-scale-1100">For any issues about our API</p>
- </div>
- <div>
- <Link href="https://github.com/supabase/supabase">
- <a target="_blank">
- <Button
- type="default"
- icon={<IconExternalLink size={14} strokeWidth={1.5} />}
- >
- View Github issues
- </Button>
- </a>
- </Link>
</div>
</div>
- </div>
- </div>
- )}
+ )}
- <div className="px-6 space-y-2">
- <p className="text-sm text-scale-1100">Which services are affected?</p>
- <MultiSelect
- options={SERVICE_OPTIONS}
- value={selectedServices}
- placeholder="No particular service"
- searchPlaceholder="Search for a service"
- onChange={setSelectedServices}
- />
- </div>
- <div className="text-area-text-sm px-6">
- <Input.TextArea
- id="message"
- label="Message"
- placeholder="Describe the issue you're facing, along with any relevant information. Please be as detailed and specific as possible."
- limit={5000}
- labelOptional="5000 character limit"
- />
- </div>
- <div className="space-y-4 px-6">
- <div className="space-y-1">
- <p className="block text-sm text-scale-1100">Attachments</p>
- <p className="block text-sm text-scale-1000">
- Upload up to {MAX_ATTACHMENTS} screenshots that might be relevant to the issue
- that you're facing
- </p>
- </div>
- <div>
- <input
- multiple
- type="file"
- // @ts-ignore
- ref={uploadButtonRef}
- className="hidden"
- accept="image/png, image/jpeg"
- onChange={onFilesUpload}
- />
- </div>
- <div className="flex items-center space-x-2">
- {uploadedDataUrls.map((x: any, idx: number) => (
- <div
- key={idx}
- style={{ backgroundImage: `url("${x}")` }}
- className="relative h-14 w-14 rounded bg-cover bg-center bg-no-repeat"
- >
- <div
- className={[
- 'flex h-4 w-4 items-center justify-center rounded-full bg-red-900',
- 'absolute -top-1 -right-1 cursor-pointer',
- ].join(' ')}
- onClick={() => removeUploadedFile(idx)}
- >
- <IconX size={12} strokeWidth={2} />
- </div>
- </div>
- ))}
- {uploadedFiles.length < MAX_ATTACHMENTS && (
- <div
- className={[
- 'border border-scale-800 opacity-50 transition hover:opacity-100',
- 'group flex h-14 w-14 cursor-pointer items-center justify-center rounded',
- ].join(' ')}
- onClick={() => {
- if (uploadButtonRef.current) (uploadButtonRef.current as any).click()
- }}
- >
- <IconPlus strokeWidth={2} size={20} />
+ <div className="px-6 space-y-2">
+ <p className="text-sm text-scale-1100">Which services are affected?</p>
+ <MultiSelect
+ options={SERVICE_OPTIONS}
+ value={selectedServices}
+ placeholder="No particular service"
+ searchPlaceholder="Search for a service"
+ onChange={setSelectedServices}
+ />
+ </div>
+ <div className="text-area-text-sm px-6">
+ <Input.TextArea
+ id="message"
+ label="Message"
+ placeholder="Describe the issue you're facing, along with any relevant information. Please be as detailed and specific as possible."
+ limit={5000}
+ labelOptional="5000 character limit"
+ />
+ </div>
+ {['Problem', 'Database_unresponsive', 'Performance'].includes(
+ values.category
+ ) && (
+ <div className="px-6">
+ <Checkbox
+ name="allowSupportAccess"
+ label="Allow Supabase Support to access your project temporarily"
+ description="In some cases, we may require temporary access to your project to complete troubleshooting, or to answer questions related specifically to your project"
+ />
</div>
)}
- </div>
- </div>
- <div className="px-6">
- <div className="flex justify-end">
- <Button
- htmlType="submit"
- size="small"
- icon={<IconMail />}
- disabled={isSubmitting}
- loading={isSubmitting}
- >
- Send support request
- </Button>
- </div>
- </div>
+ <div className="space-y-4 px-6">
+ <div className="space-y-1">
+ <p className="block text-sm text-scale-1100">Attachments</p>
+ <p className="block text-sm text-scale-1000">
+ Upload up to {MAX_ATTACHMENTS} screenshots that might be relevant to the
+ issue that you're facing
+ </p>
+ </div>
+ <div>
+ <input
+ multiple
+ type="file"
+ // @ts-ignore
+ ref={uploadButtonRef}
+ className="hidden"
+ accept="image/png, image/jpeg"
+ onChange={onFilesUpload}
+ />
+ </div>
+ <div className="flex items-center space-x-2">
+ {uploadedDataUrls.map((x: any, idx: number) => (
+ <div
+ key={idx}
+ style={{ backgroundImage: `url("${x}")` }}
+ className="relative h-14 w-14 rounded bg-cover bg-center bg-no-repeat"
+ >
+ <div
+ className={[
+ 'flex h-4 w-4 items-center justify-center rounded-full bg-red-900',
+ 'absolute -top-1 -right-1 cursor-pointer',
+ ].join(' ')}
+ onClick={() => removeUploadedFile(idx)}
+ >
+ <IconX size={12} strokeWidth={2} />
+ </div>
+ </div>
+ ))}
+ {uploadedFiles.length < MAX_ATTACHMENTS && (
+ <div
+ className={[
+ 'border border-scale-800 opacity-50 transition hover:opacity-100',
+ 'group flex h-14 w-14 cursor-pointer items-center justify-center rounded',
+ ].join(' ')}
+ onClick={() => {
+ if (uploadButtonRef.current) (uploadButtonRef.current as any).click()
+ }}
+ >
+ <IconPlus strokeWidth={2} size={20} />
+ </div>
+ )}
+ </div>
+ </div>
+ <div className="px-6">
+ <div className="flex justify-end">
+ <Button
+ htmlType="submit"
+ size="small"
+ icon={<IconMail />}
+ disabled={isSubmitting}
+ loading={isSubmitting}
+ >
+ Send support request
+ </Button>
+ </div>
+ </div>
+ </>
+ )}
</>
- ) : ['Problem', 'Performance'].includes(values.category) ? (
- <DisabledStateForFreeTier
- category={selectedCategory?.label ?? ''}
- projectRef={values.projectRef}
- />
) : (
<></>
)}