Skip to content

Commit da8a5cf

Browse files
authored
Handled the dot notation and value 0 in LogsTable (#357)
1 parent 9bb2544 commit da8a5cf

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/pages/Stream/Views/Explore/StaticLogTable.tsx

+27-6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,31 @@ const TableContainer = (props: { children: ReactNode }) => {
2929

3030
const localTz = timeRangeUtils.getLocalTimezone();
3131

32+
type CellType = string | number | boolean | null | undefined;
33+
34+
const getSanitizedValue = (value: CellType, isTimestamp: boolean) => {
35+
if (isTimestamp) {
36+
const timestamp = String(value).trim();
37+
const isValidTimestamp = !isNaN(Date.parse(timestamp));
38+
39+
if (timestamp && isValidTimestamp) {
40+
return formatLogTs(timestamp);
41+
} else {
42+
return '';
43+
}
44+
}
45+
46+
if (value === null || value === undefined) {
47+
return '';
48+
}
49+
50+
if (typeof value === 'boolean') {
51+
return value.toString();
52+
}
53+
54+
return String(value);
55+
};
56+
3257
const makeHeaderOpts = (headers: string[], isSecureHTTPContext: boolean, fieldTypeMap: FieldTypeMap) => {
3358
return _.reduce(
3459
headers,
@@ -42,19 +67,15 @@ const makeHeaderOpts = (headers: string[], isSecureHTTPContext: boolean, fieldTy
4267
header: isTimestamp ? `${header} (${localTz})` : header,
4368
grow: true,
4469
Cell: ({ cell }: { cell: any }) => {
45-
const value = _.isFunction(cell.getValue) ? cell.getValue() : '';
70+
const value = _.get(cell.row.original, header, '');
4671
const isTimestamp = _.chain(cell)
4772
.get('column.id', null)
4873
.thru((val) => {
4974
const datatype = _.get(fieldTypeMap, val, null);
5075
return datatype === 'timestamp';
5176
})
5277
.value();
53-
const sanitizedValue = isTimestamp
54-
? formatLogTs(value)
55-
: _.isBoolean(value) || value
56-
? _.toString(value)
57-
: '';
78+
const sanitizedValue = getSanitizedValue(value, isTimestamp);
5879
return (
5980
<div className={tableStyles.customCellContainer} style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>
6081
{sanitizedValue}

0 commit comments

Comments
 (0)