Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle zed.Union types in format.ts #3118

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/zui/src/components/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export function formatValue(
if (data instanceof zed.Map) {
return `|{...${data.value.size}}|`
}
if (data instanceof zed.Union) {
return formatValue(data.value, config)
}
return null
}

Expand Down
4 changes: 1 addition & 3 deletions apps/zui/src/views/detail-pane/Fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ const DataPanel = React.memo<DTProps>(function DataTable({
<Data key={index}>
<Name>{field.path.join(" ‣ ")}</Name>
<Value className={zedTypeClassName(field.data)}>
{field.data instanceof zed.Union
? format(field.data.value as zed.Primitive)
: format(field.data as zed.Primitive)}
{format(field.data as zed.Primitive)}
</Value>
</Data>
))}
Expand Down
Loading