Skip to content

Commit 6c8165f

Browse files
authored
Merge pull request #276 from valkey-io/bring-start-monitoring-button-back
2 parents 9084244 + d2b7170 commit 6c8165f

3 files changed

Lines changed: 19 additions & 22 deletions

File tree

apps/frontend/src/components/monitoring/Monitoring.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export const Monitoring = () => {
185185
<HotKeys
186186
data={hotKeysData}
187187
errorMessage={hotKeysErrorMessage as string | null}
188+
monitorRunning={monitorRunning}
188189
onKeyClick={handleKeyClick}
189190
onStartMonitoring={() => setConfigOpen(true)}
190191
selectedKey={selectedKey}

apps/frontend/src/components/monitoring/hot-keys.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@ import { SortableTableHeader, StaticTableHeader, type SortOrder } from "../ui/so
1111
import { Typography } from "../ui/typography"
1212
import { copyToClipboard } from "@/lib/utils"
1313

14-
const START_MONITORING_STRING = "Start Monitoring"
15-
1614
interface 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>

apps/metrics/src/handlers/monitor-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as Streamer from "../effects/ndjson-streamer.js"
77

88
export const readMonitorMetadata = () => getCollectorMeta(MONITOR)
99

10-
const toResponse = ({ isRunning, willCompleteAt }) => ({
10+
const toResponse = ({ isRunning, willCompleteAt, startedAt }) => ({
1111
monitorRunning: isRunning,
1212
checkAt: willCompleteAt,
1313
startedAt: startedAt ?? null,

0 commit comments

Comments
 (0)