@@ -11,18 +11,17 @@ import { SortableTableHeader, StaticTableHeader, type SortOrder } from "../ui/so
1111import { Typography } from "../ui/typography"
1212import { copyToClipboard } from "@/lib/utils"
1313
14- const START_MONITORING_STRING = "Start Monitoring"
15-
1614interface HotKeysProps {
1715 data : [ string , number , number | null , number ] [ ] | null
1816 errorMessage : string | null
1917 status ?: string
18+ monitorRunning ?: boolean
2019 onKeyClick ?: ( keyName : string ) => void
2120 onStartMonitoring ?: ( ) => void
2221 selectedKey ?: string | null
2322}
2423
25- export function HotKeys ( { data, errorMessage, status, onKeyClick, onStartMonitoring, selectedKey } : HotKeysProps ) {
24+ export function HotKeys ( { data, errorMessage, status, monitorRunning , onKeyClick, onStartMonitoring, selectedKey } : HotKeysProps ) {
2625 const [ sortOrder , setSortOrder ] = useState < SortOrder > ( "desc" )
2726
2827 const toggleSortOrder = ( ) => {
@@ -135,28 +134,25 @@ export function HotKeys({ data, errorMessage, status, onKeyClick, onStartMonitor
135134 ) : (
136135 < EmptyState
137136 action = {
138- errorMessage && (
137+ ( errorMessage || ! monitorRunning ) && (
139138 < div className = "mt-2 p-3 bg-red-50 dark:bg-red-900/20 rounded-md" >
140139 < div className = "flex items-start gap-2" >
141140 < AlertCircle className = "w-4 h-4 text-red-500 mt-0.5 shrink-0" />
142141 < Typography variant = "bodySm" >
143- { ( ( ) => {
144- const parts = errorMessage . split ( START_MONITORING_STRING )
145- if ( parts . length < 2 || ! onStartMonitoring ) return errorMessage
146- return (
147- < >
148- { parts [ 0 ] }
149- < button
150- className = "text-primary underline hover:opacity-80"
151- onClick = { onStartMonitoring }
152- type = "button"
153- >
154- { START_MONITORING_STRING }
155- </ button >
156- { parts . slice ( 1 ) . join ( START_MONITORING_STRING ) }
157- </ >
158- )
159- } ) ( ) }
142+ { ! monitorRunning && onStartMonitoring ? (
143+ < >
144+ Monitor is not running.{ " " }
145+ < button
146+ className = "text-primary underline hover:opacity-80"
147+ onClick = { onStartMonitoring }
148+ type = "button"
149+ >
150+ Start Monitoring
151+ </ button >
152+ </ >
153+ ) : (
154+ errorMessage
155+ ) }
160156 </ Typography >
161157 </ div >
162158 </ div >
0 commit comments