fix: detach the log indicator from timestamp column (#6681)

This commit is contained in:
Vikrant Gupta 2024-12-20 13:25:52 +05:30 committed by GitHub
parent 53ebd39f41
commit 8e7c78e1b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 13 deletions

View File

@ -22,6 +22,13 @@
} }
} }
.state-indicator {
width: 15px;
.log-state-indicator {
padding: 0px;
}
}
.table-timestamp { .table-timestamp {
display: flex; display: flex;
align-items: center; align-items: center;
@ -29,10 +36,6 @@
.ant-typography { .ant-typography {
margin-bottom: 0; margin-bottom: 0;
} }
.log-state-indicator {
padding: 0px;
}
} }
.lightMode { .lightMode {

View File

@ -75,12 +75,28 @@ export const useTableView = (props: UseTableViewProps): UseTableViewResult => {
} }
return [ return [
{
// We do not need any title and data index for the log state indicator
title: '',
dataIndex: '',
key: 'state-indicator',
render: (_, item): ColumnTypeRender<Record<string, unknown>> => ({
children: (
<div className={cx('state-indicator', fontSize)}>
<LogStateIndicator
type={getLogIndicatorTypeForTable(item)}
fontSize={fontSize}
/>
</div>
),
}),
},
{ {
title: 'timestamp', title: 'timestamp',
dataIndex: 'timestamp', dataIndex: 'timestamp',
key: 'timestamp', key: 'timestamp',
// https://github.com/ant-design/ant-design/discussions/36886 // https://github.com/ant-design/ant-design/discussions/36886
render: (field, item): ColumnTypeRender<Record<string, unknown>> => { render: (field): ColumnTypeRender<Record<string, unknown>> => {
const date = const date =
typeof field === 'string' typeof field === 'string'
? formatTimezoneAdjustedTimestamp(field, 'YYYY-MM-DD HH:mm:ss.SSS') ? formatTimezoneAdjustedTimestamp(field, 'YYYY-MM-DD HH:mm:ss.SSS')
@ -91,10 +107,6 @@ export const useTableView = (props: UseTableViewProps): UseTableViewResult => {
return { return {
children: ( children: (
<div className="table-timestamp"> <div className="table-timestamp">
<LogStateIndicator
type={getLogIndicatorTypeForTable(item)}
fontSize={fontSize}
/>
<Typography.Paragraph ellipsis className={cx('text', fontSize)}> <Typography.Paragraph ellipsis className={cx('text', fontSize)}>
{date} {date}
</Typography.Paragraph> </Typography.Paragraph>

View File

@ -79,6 +79,7 @@ export default function TableRow({
return ( return (
<TableCellStyled <TableCellStyled
$isDragColumn={false} $isDragColumn={false}
$isLogIndicator={column.key === 'state-indicator'}
$isDarkMode={isDarkMode} $isDarkMode={isDarkMode}
key={column.key} key={column.key}
fontSize={fontSize} fontSize={fontSize}

View File

@ -126,7 +126,7 @@ const InfinityTable = forwardRef<TableVirtuosoHandle, InfinityTableProps>(
return ( return (
<TableHeaderCellStyled <TableHeaderCellStyled
$isTimestamp={column.key === 'timestamp'} $isLogIndicator={column.key === 'state-indicator'}
$isDarkMode={isDarkMode} $isDarkMode={isDarkMode}
$isDragColumn={isDragColumn} $isDragColumn={isDragColumn}
key={column.key} key={column.key}

View File

@ -7,7 +7,7 @@ import { getActiveLogBackground } from 'utils/logs';
interface TableHeaderCellStyledProps { interface TableHeaderCellStyledProps {
$isDragColumn: boolean; $isDragColumn: boolean;
$isDarkMode: boolean; $isDarkMode: boolean;
$isTimestamp?: boolean; $isLogIndicator?: boolean;
fontSize?: FontSize; fontSize?: FontSize;
} }
@ -28,11 +28,12 @@ export const TableCellStyled = styled.td<TableHeaderCellStyledProps>`
background-color: ${(props): string => background-color: ${(props): string =>
props.$isDarkMode ? 'inherit' : themeColors.whiteCream}; props.$isDarkMode ? 'inherit' : themeColors.whiteCream};
${({ $isLogIndicator }): string =>
$isLogIndicator ? 'padding: 0 0 0 8px;' : ''}
color: ${(props): string => color: ${(props): string =>
props.$isDarkMode ? themeColors.white : themeColors.bckgGrey}; props.$isDarkMode ? themeColors.white : themeColors.bckgGrey};
`; `;
// handle the light theme here
export const TableRowStyled = styled.tr<{ export const TableRowStyled = styled.tr<{
$isActiveLog: boolean; $isActiveLog: boolean;
$isDarkMode: boolean; $isDarkMode: boolean;
@ -85,7 +86,7 @@ export const TableHeaderCellStyled = styled.th<TableHeaderCellStyledProps>`
: fontSize === FontSize.LARGE : fontSize === FontSize.LARGE
? `font-size:14px; line-height:24px; padding: 0.5rem;` ? `font-size:14px; line-height:24px; padding: 0.5rem;`
: ``}; : ``};
${({ $isTimestamp }): string => ($isTimestamp ? 'padding-left: 24px;' : '')} ${({ $isLogIndicator }): string => ($isLogIndicator ? 'padding: 0px; ' : '')}
color: ${(props): string => color: ${(props): string =>
props.$isDarkMode ? 'var(--bg-vanilla-100, #fff)' : themeColors.bckgGrey}; props.$isDarkMode ? 'var(--bg-vanilla-100, #fff)' : themeColors.bckgGrey};
`; `;