From 166e5612ebdd34045a78dc18a31177777bcd025a Mon Sep 17 00:00:00 2001 From: Pranshu Chittora Date: Tue, 16 Aug 2022 18:53:34 +0530 Subject: [PATCH] feat: restrict timestamp from adding it to query (#1517) Co-authored-by: Palash Gupta --- .../src/components/Logs/LogItem/index.tsx | 3 +- .../container/LogDetailedView/TableView.tsx | 41 +++++++++++-------- frontend/src/container/LogLiveTail/index.tsx | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/frontend/src/components/Logs/LogItem/index.tsx b/frontend/src/components/Logs/LogItem/index.tsx index 5ddf160097..ba51b59373 100644 --- a/frontend/src/components/Logs/LogItem/index.tsx +++ b/frontend/src/components/Logs/LogItem/index.tsx @@ -2,6 +2,7 @@ import { blue, grey, orange } from '@ant-design/colors'; import { CopyFilled, CopyrightCircleFilled, ExpandAltOutlined } from '@ant-design/icons'; import { Button, Card, Divider, Row, Typography } from 'antd'; import { map } from 'd3'; +import dayjs from 'dayjs'; import { FlatLogData } from 'lib/logs/flatLogData'; import { flatMap, flatMapDeep } from 'lodash-es'; import React, { useCallback, useMemo } from 'react'; @@ -95,7 +96,7 @@ function LogItem({ logData }) { )} {'}'} diff --git a/frontend/src/container/LogDetailedView/TableView.tsx b/frontend/src/container/LogDetailedView/TableView.tsx index 9e55e34df9..8548cd4829 100644 --- a/frontend/src/container/LogDetailedView/TableView.tsx +++ b/frontend/src/container/LogDetailedView/TableView.tsx @@ -14,6 +14,9 @@ import React, { useMemo, useState } from 'react'; import ActionItem from './ActionItem'; +// Fields which should be restricted from adding it to query +const RESTRICTED_FIELDS = ['timestamp']; + function TableView({ logData }) { const [fieldSearchInput, setFieldSearchInput] = useState(''); @@ -38,27 +41,33 @@ function TableView({ logData }) { { title: 'Action', width: 75, - render: (fieldData) => ( - - ), + render: (fieldData) => { + const fieldKey = fieldData.field.split('.').slice(-1); + if (!RESTRICTED_FIELDS.includes(fieldKey[0])) { + return ; + } + return null; + }, }, { title: 'Field', dataIndex: 'field', key: 'field', width: '35%', - render: (field: string) => ( - - {' '} - {field} - - ), + render: (field: string) => { + const fieldKey = field.split('.').slice(-1); + const renderedField = {field}; + + if (!RESTRICTED_FIELDS.includes(fieldKey[0])) { + return ( + + {' '} + {renderedField} + + ); + } + return renderedField; + }, }, { title: 'Value', @@ -83,7 +92,7 @@ function TableView({ logData }) { /> 0 ? { idGt: logs[0].id,