11import { useState } from 'react' ;
22import { MetricsDataType , TSource } from '@hyperdx/common-utils/dist/types' ;
3- import { Modal , Paper , Tabs , Text , TextProps , Tooltip } from '@mantine/core' ;
3+ import { Modal , Paper , Tabs , TextProps , Tooltip } from '@mantine/core' ;
4+ import { IconCode } from '@tabler/icons-react' ;
45
56import { useTableMetadata } from '@/hooks/useMetadata' ;
67
@@ -11,13 +12,15 @@ interface SourceSchemaInfoIconProps {
1112 isEnabled : boolean ;
1213 tableCount : number ;
1314 iconStyles ?: Pick < TextProps , 'size' | 'color' > ;
15+ variant ?: 'icon' | 'text' ;
1416}
1517
1618const SourceSchemaInfoIcon = ( {
1719 onClick,
1820 isEnabled,
1921 tableCount,
2022 iconStyles,
23+ variant = 'icon' ,
2124} : SourceSchemaInfoIconProps ) => {
2225 const tooltipText = isEnabled
2326 ? tableCount > 1
@@ -33,11 +36,15 @@ const SourceSchemaInfoIcon = ({
3336 position = "right"
3437 onClick = { ( ) => isEnabled && onClick ( ) }
3538 >
36- < Text { ...iconStyles } >
37- < i
38- className = { `bi bi-code-square ${ isEnabled ? 'cursor-pointer' : '' } ` }
39- />
40- </ Text >
39+ { variant === 'text' ? (
40+ < span
41+ style = { { cursor : isEnabled ? 'pointer' : 'default' , ...iconStyles } }
42+ >
43+ Schema
44+ </ span >
45+ ) : (
46+ < IconCode size = { 16 } />
47+ ) }
4148 </ Tooltip >
4249 ) ;
4350} ;
@@ -79,6 +86,7 @@ export interface SourceSchemaPreviewProps {
7986 source ?: Pick < TSource , 'connection' | 'from' | 'metricTables' > &
8087 Partial < Pick < TSource , 'kind' | 'name' > > ;
8188 iconStyles ?: Pick < TextProps , 'size' | 'color' > ;
89+ variant ?: 'icon' | 'text' ;
8290}
8391
8492const METRIC_TYPE_NAMES : Record < MetricsDataType , string > = {
@@ -92,6 +100,7 @@ const METRIC_TYPE_NAMES: Record<MetricsDataType, string> = {
92100const SourceSchemaPreview = ( {
93101 source,
94102 iconStyles,
103+ variant = 'icon' ,
95104} : SourceSchemaPreviewProps ) => {
96105 const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
97106
@@ -130,6 +139,7 @@ const SourceSchemaPreview = ({
130139 onClick = { ( ) => setIsModalOpen ( true ) }
131140 iconStyles = { iconStyles }
132141 tableCount = { tables . length }
142+ variant = { variant }
133143 />
134144 { isEnabled && (
135145 < Modal
0 commit comments