import React from 'react';
import { Icon } from 'UI';
import { CopyOutlined } from '@ant-design/icons';
import { Button } from 'antd';
import cn from 'classnames';
import copy from 'copy-to-clipboard';
import { getDateFromString } from 'App/date';
import JumpButton from 'App/components/shared/DevTools/JumpButton';
import { useTranslation } from 'react-i18next';
export function TableHeader({ size }: { size: number }) {
const { t } = useTranslation();
return (
{t('timestamp')}
{t('status')}
{t('content')}
{size} {t('Records')}
);
}
export function LogRow({
log,
onJump,
isActive,
}: {
log: { timestamp: string; status: string; content: string };
onJump: (ts: number) => void;
isActive?: boolean;
}) {
const [isExpanded, setIsExpanded] = React.useState(false);
const bg = (status: string) => {
// types: warn error info none
if (status === 'WARN') {
return 'bg-yellow';
}
if (status === 'ERROR') {
return 'bg-red-lightest';
}
return 'bg-white';
};
const border = (status: string) => {
// types: warn error info none
if (status === 'WARN') {
return 'border-l border-l-4 border-l-amber-500';
}
if (status === 'ERROR') {
return 'border-l border-l-4 border-l-red';
}
return 'border-l border-l-4 border-gray-lighter';
};
return (
{log.timestamp === 'N/A' ? null : (
onJump(new Date(log.timestamp).getTime())} />
)}
setIsExpanded((prev) => !prev)}
>
{getDateFromString(log.timestamp)}
{log.status}
{log.content}
{isExpanded ? (
{log.content.split('\n').map((line, index) => (
))}
}
onClick={() => copy(log.content)}
/>
) : null}
);
}