Skip to content

Commit 7d7edad

Browse files
committed
Enhance EmptyState component with className prop and update usage in EmptyObservability
1 parent 993db66 commit 7d7edad

File tree

3 files changed

+84
-80
lines changed

3 files changed

+84
-80
lines changed

web/oss/src/components/EmptyState/EmptyState.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {useState} from "react"
44
import {Stream} from "@cloudflare/stream-react"
55
import {ArrowRight} from "@phosphor-icons/react"
66
import {Button, Skeleton, Typography} from "antd"
7+
import clsx from "clsx"
78

89
export interface EmptyStateProps {
910
/** Cloudflare Stream video ID (preferred) */
@@ -23,6 +24,7 @@ export interface EmptyStateProps {
2324
label: string
2425
href: string
2526
}
27+
className?: string
2628
}
2729

2830
const VIDEO_ASPECT_RATIO = 16 / 9
@@ -35,6 +37,7 @@ const EmptyState = ({
3537
description,
3638
primaryCta,
3739
secondaryCta,
40+
className,
3841
}: EmptyStateProps) => {
3942
const [videoLoaded, setVideoLoaded] = useState(false)
4043
const [imageLoaded, setImageLoaded] = useState(false)
@@ -103,7 +106,7 @@ const EmptyState = ({
103106
}
104107

105108
return (
106-
<div className="mx-auto w-full max-w-4xl px-8 py-8">
109+
<div className={clsx("mx-auto w-full max-w-4xl px-8 py-8", className)}>
107110
<div className="flex w-full flex-col items-center text-center">
108111
{/* Title + Description */}
109112
<div className="mb-6">

web/oss/src/components/pages/observability/components/EmptyObservability/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const EmptyObservability = () => {
1515

1616
return (
1717
<EmptyState
18+
className="py-4"
1819
videoId={EMPTY_STATE_VIDEOS.observability}
1920
previewAlt="Observability demo showing trace visualization"
2021
title="No traces yet"

web/oss/src/components/pages/observability/components/ObservabilityTable/index.tsx

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -203,94 +203,94 @@ const ObservabilityTable = () => {
203203
}))
204204
}, [columns, editColumns])
205205

206-
if (isEmptyState) {
207-
return <EmptyObservability />
208-
}
209-
210206
return (
211-
<div className="flex flex-col gap-2">
207+
<div className="flex flex-col gap-6">
212208
<ObservabilityHeader
213209
columns={columns}
214210
componentType="traces"
215211
onRefresh={handleRefresh}
216212
refreshTrigger={refreshTrigger}
217213
/>
218214

219-
<div className="flex flex-col gap-2">
220-
<Table
221-
rowSelection={{
222-
type: "checkbox",
223-
columnWidth: 48,
224-
selectedRowKeys,
225-
...rowSelection,
226-
}}
227-
loading={showTableLoading}
228-
columns={mergedColumns as TableColumnType<TraceSpanNode>[]}
229-
dataSource={traces}
230-
bordered
231-
style={{cursor: "pointer"}}
232-
sticky={{
233-
offsetHeader: 0,
234-
offsetScroll: 0,
235-
}}
236-
onRow={(record, index) => ({
237-
onClick: () => {
238-
setSelectedNode(record.span_id)
239-
const isSpanView = traceTabs === "span"
240-
241-
const targetTraceId = String(
242-
record.trace_id ||
243-
(record as any)?.invocationIds?.trace_id ||
244-
(record as any)?.node?.trace_id ||
245-
(record as any)?.root?.id ||
246-
(record as any)?.traceId ||
247-
(record as any)?.trace?.id ||
248-
record.span_id ||
249-
"",
250-
)
251-
252-
const targetSpanId = isSpanView
253-
? String(record.span_id || "")
254-
: String(record.span_id || "")
255-
256-
if (!targetTraceId) {
257-
console.warn(
258-
"TraceDrawer: unable to determine trace id for record",
259-
record,
215+
{isEmptyState ? (
216+
<EmptyObservability />
217+
) : (
218+
<div className="flex flex-col gap-2">
219+
<Table
220+
rowSelection={{
221+
type: "checkbox",
222+
columnWidth: 48,
223+
selectedRowKeys,
224+
...rowSelection,
225+
}}
226+
loading={showTableLoading}
227+
columns={mergedColumns as TableColumnType<TraceSpanNode>[]}
228+
dataSource={traces}
229+
bordered
230+
style={{cursor: "pointer"}}
231+
sticky={{
232+
offsetHeader: 0,
233+
offsetScroll: 0,
234+
}}
235+
onRow={(record, index) => ({
236+
onClick: () => {
237+
setSelectedNode(record.span_id)
238+
const isSpanView = traceTabs === "span"
239+
240+
const targetTraceId = String(
241+
record.trace_id ||
242+
(record as any)?.invocationIds?.trace_id ||
243+
(record as any)?.node?.trace_id ||
244+
(record as any)?.root?.id ||
245+
(record as any)?.traceId ||
246+
(record as any)?.trace?.id ||
247+
record.span_id ||
248+
"",
260249
)
261-
return
262-
}
263-
264-
setSelectedTraceId(targetTraceId)
265-
setTraceDrawerActiveSpan(targetSpanId || null)
266-
setTraceParam(targetTraceId)
267-
if (targetSpanId) {
268-
setSpanParam(targetSpanId)
269-
} else {
270-
setSpanParam(undefined)
271-
}
272-
},
273-
"data-tour": index === 0 ? "trace-row" : undefined,
274-
})}
275-
components={{
276-
header: {
277-
cell: ResizableTitle,
278-
},
279-
}}
280-
pagination={false}
281-
scroll={{x: "max-content"}}
282-
/>
283-
{hasMoreTraces && (
284-
<Button
285-
onClick={handleLoadMore}
286-
disabled={isFetchingMore}
287-
type="text"
288-
size="large"
289-
>
290-
{isFetchingMore ? "Loading…" : "Click here to load more"}
291-
</Button>
292-
)}
293-
</div>
250+
251+
const targetSpanId = isSpanView
252+
? String(record.span_id || "")
253+
: String(record.span_id || "")
254+
255+
if (!targetTraceId) {
256+
console.warn(
257+
"TraceDrawer: unable to determine trace id for record",
258+
record,
259+
)
260+
return
261+
}
262+
263+
setSelectedTraceId(targetTraceId)
264+
setTraceDrawerActiveSpan(targetSpanId || null)
265+
setTraceParam(targetTraceId)
266+
if (targetSpanId) {
267+
setSpanParam(targetSpanId)
268+
} else {
269+
setSpanParam(undefined)
270+
}
271+
},
272+
"data-tour": index === 0 ? "trace-row" : undefined,
273+
})}
274+
components={{
275+
header: {
276+
cell: ResizableTitle,
277+
},
278+
}}
279+
pagination={false}
280+
scroll={{x: "max-content"}}
281+
/>
282+
{hasMoreTraces && (
283+
<Button
284+
onClick={handleLoadMore}
285+
disabled={isFetchingMore}
286+
type="text"
287+
size="large"
288+
>
289+
{isFetchingMore ? "Loading…" : "Click here to load more"}
290+
</Button>
291+
)}
292+
</div>
293+
)}
294294

295295
<TestsetDrawer
296296
open={testsetDrawerData.length > 0}

0 commit comments

Comments
 (0)