Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
30 changes: 16 additions & 14 deletions src/pages/Stream/Views/Explore/JSONView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
STREAM_PRIMARY_TOOLBAR_CONTAINER_HEIGHT,
STREAM_SECONDARY_TOOLBAR_HRIGHT,
} from '@/constants/theme';
import { columnsToSkip, useLogsStore, logsStoreReducers, isJqSearch } from '../../providers/LogsProvider';
import { useLogsStore, logsStoreReducers, isJqSearch } from '../../providers/LogsProvider';
import { Log } from '@/@types/parseable/api/query';
import _ from 'lodash';
import jqSearch from '@/utils/jqSearch';
Expand Down Expand Up @@ -61,25 +61,29 @@ const CopyIcon = (props: { log: Log }) => {

const Row = (props: {
log: Log;
headers: string[];
searchValue: string;
disableHighlight: boolean;
shouldHighlight: (val: number | string | Date | null) => boolean;
}) => {
const { log, headers, disableHighlight, shouldHighlight } = props;
const { log, disableHighlight, shouldHighlight } = props;

return (
<Stack style={{ flexDirection: 'row' }} className={classes.rowContainer} gap={0}>
<span>
{_.isObject(log) ? (
_.map(headers, (header, index) => (
<Item
header={header}
key={index}
value={_.toString(log[header])}
highlight={disableHighlight ? false : shouldHighlight(log[header])}
/>
))
_.map(log, (value, key) => {
//skiping fields with empty strings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is still needed.
If you are iterating over a log object, why you'd want to test whether its empty or not ?

if (!_.toString(value)) return;

return (
<Item
header={key}
key={key}
value={_.toString(value)}
highlight={disableHighlight ? false : shouldHighlight(value)}
/>
);
})
) : (
<Item
header={null}
Expand All @@ -94,8 +98,7 @@ const Row = (props: {
};

const JsonRows = (props: { isSearching: boolean }) => {
const [{ pageData, headers, instantSearchValue }] = useLogsStore((store) => store.tableOpts);
const sanitizedHeaders = _.without(headers, ...columnsToSkip);
const [{ pageData, instantSearchValue }] = useLogsStore((store) => store.tableOpts);
const disableHighlight = props.isSearching || _.isEmpty(instantSearchValue) || isJqSearch(instantSearchValue);
const regExp = disableHighlight ? null : new RegExp(instantSearchValue, 'i');

Expand All @@ -112,7 +115,6 @@ const JsonRows = (props: { isSearching: boolean }) => {
<Row
log={d}
key={index}
headers={sanitizedHeaders}
searchValue={instantSearchValue}
disableHighlight={disableHighlight}
shouldHighlight={shouldHighlight}
Expand Down