Skip to content

Commit 9046a7a

Browse files
authored
Adjust behaviour of alert error support (supabase#30966)
* Adjust behaviour of alert error support * Remove hardcode * Remove console log
1 parent 95c9796 commit 9046a7a

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

apps/studio/components/interfaces/Support/SupportForm.utils.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ export const uploadAttachments = async (ref: string, files: File[]) => {
5656
return data ? data.map((file) => file.signedUrl) : []
5757
}
5858

59-
export const formatMessage = (message: string, attachments: string[]) => {
59+
export const formatMessage = (message: string, attachments: string[], error?: string) => {
60+
const errorString = error !== undefined ? `\nError: ${error}` : ''
6061
if (attachments.length > 0) {
6162
const attachmentsImg = attachments.map((url) => `\n${url}`)
62-
return `${message}\n${attachmentsImg.join('')}`
63+
return `${message}\n${attachmentsImg.join('')}${errorString}`
6364
} else {
64-
return message
65+
return `${message}${errorString}`
6566
}
6667
}
6768

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import {
5353
SEVERITY_OPTIONS,
5454
} from './Support.constants'
5555
import { formatMessage, uploadAttachments } from './SupportForm.utils'
56+
import { Admonition } from 'ui-patterns'
5657

5758
const MAX_ATTACHMENTS = 5
5859
const INCLUDE_DISCUSSIONS = ['Problem', 'Database_unresponsive']
@@ -68,7 +69,14 @@ interface SupportFormV2Props {
6869
export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFormV2Props) => {
6970
const { profile } = useProfile()
7071
const supabaseClient = useSupabaseClient()
71-
const { ref, slug, category: urlCategory, subject: urlSubject, message: urlMessage } = useParams()
72+
const {
73+
ref,
74+
slug,
75+
category: urlCategory,
76+
subject: urlSubject,
77+
message: urlMessage,
78+
error,
79+
} = useParams()
7280

7381
const uploadButtonRef = useRef(null)
7482
const [isSubmitting, setIsSubmitting] = useState(false)
@@ -203,7 +211,7 @@ export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFo
203211
organizationSlug: values.organizationSlug === 'no-org' ? undefined : values.organizationSlug,
204212
library:
205213
values.category === 'Problem' && selectedLibrary !== undefined ? selectedLibrary.key : '',
206-
message: formatMessage(values.message, attachments),
214+
message: formatMessage(values.message, attachments, error),
207215
verified: true,
208216
tags: ['dashboard-support-form'],
209217
siteUrl: '',
@@ -621,6 +629,15 @@ export const SupportFormV2 = ({ setSentCategory, setSelectedProject }: SupportFo
621629
placeholder="Describe the issue you're facing, along with any relevant information. Please be as detailed and specific as possible."
622630
/>
623631
</FormControl_Shadcn_>
632+
{error !== undefined && (
633+
<Admonition
634+
showIcon={false}
635+
type="default"
636+
className="mt-2"
637+
title="The error that you ran into will be included in your message for reference"
638+
description={`Error: ${error}`}
639+
/>
640+
)}
624641
</FormItemLayout>
625642
)}
626643
/>

apps/studio/components/ui/AlertError.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const AlertError = ({
2626

2727
if (projectRef) href += `&ref=${projectRef}`
2828
if (subjectString) href += `&subject=${subjectString}`
29-
if (error) href += `&message=Error:%20${error.message}`
29+
if (error) href += `&error=${error.message}`
3030

3131
const formattedErrorMessage = error?.message?.includes('503')
3232
? '503 Service Temporarily Unavailable'

0 commit comments

Comments
 (0)