@@ -13,11 +13,9 @@ import {
1313} from '../ui/alert-dialog' ;
1414import { toast } from 'sonner' ;
1515import { env } from '~/env' ;
16+ import { cn } from '~/lib/utils' ;
1617
17- export const DebugInfo : React . FC < React . PropsWithChildren < { gitRevision : string | null } > > = ( {
18- children,
19- gitRevision,
20- } ) => {
18+ export const DebugInfo : React . FC < React . PropsWithChildren > = ( { children } ) => {
2119 const { t } = useTranslation ( 'common' ) ;
2220 const [ newVersion , setNewVersion ] = React . useState < string | null > ( null ) ;
2321
@@ -37,16 +35,16 @@ export const DebugInfo: React.FC<React.PropsWithChildren<{ gitRevision: string |
3735 }
3836 } ;
3937
40- if ( process . env . NEXT_PUBLIC_VERSION ) {
38+ if ( env . NEXT_PUBLIC_VERSION ) {
4139 void fetchLatestVersion ( ) ;
4240 }
4341 } , [ ] ) ;
4442
4543 const copyToClipboard = useCallback ( ( ) => {
4644 // Copy to clipboard
4745 const debugInfo = [ `UserAgent: ${ navigator . userAgent } ` ] ;
48- if ( gitRevision ) {
49- debugInfo . push ( `${ t ( 'account.debug_info_details.git' ) } : ${ gitRevision } ` ) ;
46+ if ( env . NEXT_PUBLIC_GIT_SHA ) {
47+ debugInfo . push ( `${ t ( 'account.debug_info_details.git' ) } : ${ env . NEXT_PUBLIC_GIT_SHA } ` ) ;
5048 }
5149 if ( env . NEXT_PUBLIC_VERSION ) {
5250 debugInfo . push ( `${ t ( 'account.debug_info_details.version' ) } ${ env . NEXT_PUBLIC_VERSION } ` ) ;
@@ -57,33 +55,32 @@ export const DebugInfo: React.FC<React.PropsWithChildren<{ gitRevision: string |
5755 toast . error ( t ( 'account.debug_info_details.copy_failed' ) ) ;
5856 console . error ( 'Failed to copy debug info:' , error ) ;
5957 }
60- } , [ gitRevision , t ] ) ;
58+ } , [ t ] ) ;
6159
6260 return (
6361 < AlertDialog >
64- < AlertDialogTrigger > { children } </ AlertDialogTrigger >
62+ < AlertDialogTrigger asChild > { children } </ AlertDialogTrigger >
6563 < AlertDialogContent >
6664 < AlertDialogHeader >
6765 < AlertDialogTitle > { t ( 'account.debug_info_details.title' ) } </ AlertDialogTitle >
6866 < AlertDialogDescription >
69- < p > { t ( 'account.debug_info_details.description' ) } </ p >
70- < pre className = "mt-4 text-wrap" >
71- { t ( 'account.debug_info_details.user_agent' ) } :
72- < br />
73- { navigator . userAgent }
74- </ pre >
75- { gitRevision && (
76- < pre className = "text-wrap" >
77- { t ( 'account.debug_info_details.git' ) } :< br />
78- { gitRevision }
79- </ pre >
80- ) }
81- { env . NEXT_PUBLIC_VERSION && (
82- < pre className = "text-wrap" >
83- { t ( 'account.debug_info_details.version' ) } :< br />
84- { env . NEXT_PUBLIC_VERSION }
85- </ pre >
86- ) }
67+ { t ( 'account.debug_info_details.description' ) }
68+ < DebugInfoRow
69+ label = { t ( 'account.debug_info_details.user_agent' ) }
70+ value = { navigator . userAgent }
71+ className = "mt-4"
72+ />
73+
74+ < DebugInfoRow
75+ label = { t ( 'account.debug_info_details.git' ) }
76+ value = { env . NEXT_PUBLIC_GIT_SHA }
77+ className = "mt-4"
78+ />
79+ < DebugInfoRow
80+ label = { t ( 'account.debug_info_details.version' ) }
81+ value = { env . NEXT_PUBLIC_VERSION }
82+ className = "mt-4"
83+ />
8784 { newVersion && env . NEXT_PUBLIC_VERSION && newVersion !== env . NEXT_PUBLIC_VERSION ? (
8885 < p className = "mt-4 text-sm text-yellow-600" >
8986 { t ( 'account.debug_info_details.new_version_available' ) } : { newVersion }
@@ -99,3 +96,23 @@ export const DebugInfo: React.FC<React.PropsWithChildren<{ gitRevision: string |
9996 </ AlertDialog >
10097 ) ;
10198} ;
99+
100+ const Label : React . FC < React . PropsWithChildren < { className ?: string } > > = ( {
101+ children,
102+ className,
103+ } ) => < span className = { cn ( 'text-sm text-white' , className ) } > { children } </ span > ;
104+
105+ const Value : React . FC < React . PropsWithChildren < { className ?: string } > > = ( {
106+ children,
107+ className,
108+ } ) => < span className = { cn ( 'text-primary text-sm' , className ) } > { children } </ span > ;
109+
110+ export const DebugInfoRow : React . FC <
111+ React . PropsWithChildren < { label : string ; value ?: string | null ; className ?: string } >
112+ > = ( { label, value, className } ) =>
113+ value ? (
114+ < span className = { cn ( 'flex flex-col' , className ) } >
115+ < Label > { label } </ Label >
116+ < Value > { value } </ Value >
117+ </ span >
118+ ) : null ;
0 commit comments