1
1
import { ExternalLink , Loader2 } from 'lucide-react'
2
- import Link from 'next/link '
2
+ import { parseAsBoolean , useQueryState } from 'nuqs '
3
3
import { forwardRef } from 'react'
4
4
5
5
import { useParams } from 'common'
6
6
import { subscriptionHasHipaaAddon } from 'components/interfaces/Billing/Subscription/Subscription.utils'
7
7
import CopyButton from 'components/ui/CopyButton'
8
+ import { InlineLink , InlineLinkClassName } from 'components/ui/InlineLink'
8
9
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
9
10
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
10
11
import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
11
12
import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'
12
- import { AiIconAnimation , Button , Tooltip , TooltipContent , TooltipTrigger } from 'ui'
13
+ import { AiIconAnimation , Button , cn , Tooltip , TooltipContent , TooltipTrigger } from 'ui'
13
14
import Results from './Results'
14
15
15
16
export type UtilityTabResultsProps = {
@@ -21,11 +22,12 @@ export type UtilityTabResultsProps = {
21
22
}
22
23
23
24
const UtilityTabResults = forwardRef < HTMLDivElement , UtilityTabResultsProps > (
24
- ( { id, isExecuting, isDisabled, isDebugging, onDebug } , htmlRef ) => {
25
+ ( { id, isExecuting, isDisabled, isDebugging, onDebug } ) => {
25
26
const { ref } = useParams ( )
26
27
const state = useDatabaseSelectorStateSnapshot ( )
27
28
const organization = useSelectedOrganization ( )
28
29
const snapV2 = useSqlEditorV2StateSnapshot ( )
30
+ const [ , setShowConnect ] = useQueryState ( 'showConnect' , parseAsBoolean . withDefault ( false ) )
29
31
30
32
const result = snapV2 . results [ id ] ?. [ 0 ]
31
33
const { data : subscription } = useOrgSubscriptionQuery ( { orgSlug : organization ?. slug } )
@@ -35,7 +37,9 @@ const UtilityTabResults = forwardRef<HTMLDivElement, UtilityTabResultsProps>(
35
37
36
38
const isTimeout =
37
39
result ?. error ?. message ?. includes ( 'canceling statement due to statement timeout' ) ||
38
- result ?. error ?. message ?. includes ( 'upstream request timeout' )
40
+ result ?. error ?. message ?. includes ( 'upstream request timeout' ) ||
41
+ result ?. error ?. message ?. includes ( 'Query read timeout' )
42
+
39
43
const isNetWorkError = result ?. error ?. message ?. includes ( 'EHOSTUNREACH' )
40
44
41
45
if ( isExecuting ) {
@@ -61,26 +65,25 @@ const UtilityTabResults = forwardRef<HTMLDivElement, UtilityTabResultsProps>(
61
65
< div className = "flex flex-row justify-between items-start py-4 px-6 gap-x-4" >
62
66
{ isTimeout ? (
63
67
< div className = "flex flex-col gap-y-1" >
64
- < p className = "font-mono text-sm" > SQL query ran into an upstream timeout</ p >
65
- < p className = "font-mono text-sm text-foreground-light" >
68
+ < p className = "font-mono text-sm tracking-tight" >
69
+ Error: SQL query ran into an upstream timeout
70
+ </ p >
71
+ < p className = "text-sm text-foreground-light" >
66
72
You can either{ ' ' }
67
- < a
68
- target = "_blank"
69
- rel = "noreferrer"
70
- className = "underline transition hover:text-foreground"
71
- href = "https://supabase.com/docs/guides/platform/performance#examining-query-performance"
72
- >
73
+ < InlineLink href = "https://supabase.com/docs/guides/platform/performance#examining-query-performance" >
73
74
optimize your query
74
- </ a >
75
+ </ InlineLink >
75
76
, or{ ' ' }
76
- < a
77
- target = "_blank"
78
- rel = "noreferrer"
79
- className = "underline transition hover:text-foreground"
80
- href = "https://supabase.com/docs/guides/database/timeouts"
81
- >
77
+ < InlineLink href = "https://supabase.com/docs/guides/database/timeouts" >
82
78
increase the statement timeout
83
- </ a >
79
+ </ InlineLink >
80
+ { ' or ' }
81
+ < span
82
+ className = { cn ( InlineLinkClassName , 'cursor-pointer' ) }
83
+ onClick = { ( ) => setShowConnect ( true ) }
84
+ >
85
+ connect to your database directly
86
+ </ span >
84
87
.
85
88
</ p >
86
89
</ div >
@@ -110,15 +113,13 @@ const UtilityTabResults = forwardRef<HTMLDivElement, UtilityTabResultsProps>(
110
113
{ payloadTooLargeError && (
111
114
< p className = "text-sm text-foreground-light flex items-center gap-x-1" >
112
115
Run this query by{ ' ' }
113
- < Link
114
- target = "_blank"
115
- rel = "noreferrer"
116
- href = { `/project/${ ref } /settings/database` }
117
- className = "underline transition hover:text-foreground flex items-center gap-x-1"
116
+ < span
117
+ onClick = { ( ) => setShowConnect ( true ) }
118
+ className = { cn ( InlineLinkClassName , 'flex items-center gap-x-1' ) }
118
119
>
119
120
connecting to your database directly
120
121
< ExternalLink size = { 12 } />
121
- </ Link >
122
+ </ span >
122
123
.
123
124
</ p >
124
125
) }
0 commit comments