1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

fix: add timestamp to feature toggle metrics (#4094)

fixes: #2873


![image](https://github.com/Unleash/unleash/assets/158948/7d5bb8ee-6b88-49ad-8c51-474e19dc833d)
This commit is contained in:
Ivar Conradi Østhus 2023-06-27 09:14:45 +02:00 committed by GitHub
parent be1e63508a
commit b36ab58f87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 2 deletions

View File

@ -0,0 +1,21 @@
import { VFC } from 'react';
import { useLocationSettings } from 'hooks/useLocationSettings';
import { formatDateYMDHM } from 'utils/formatDate';
import { parseISO } from 'date-fns';
import { TextCell } from 'component/common/Table/cells/TextCell/TextCell';
interface IDateTimeCellProps {
value?: Date | string | null;
}
export const DateTimeCell: VFC<IDateTimeCellProps> = ({ value }) => {
const { locationSettings } = useLocationSettings();
const date = value
? value instanceof Date
? formatDateYMDHM(value, locationSettings.locale)
: formatDateYMDHM(parseISO(value), locationSettings.locale)
: undefined;
return <TextCell lineClamp={1}>{date}</TextCell>;
};

View File

@ -1,6 +1,6 @@
import { IFeatureMetricsRaw } from 'interfaces/featureToggle';
import { TableBody, TableRow, useMediaQuery } from '@mui/material';
import { DateCell } from 'component/common/Table/cells/DateCell/DateCell';
import { DateTimeCell } from 'component/common/Table/cells/DateTimeCell/DateTimeCell';
import { useTable, useGlobalFilter, useSortBy } from 'react-table';
import { SortableTableHeader, TableCell, Table } from 'component/common/Table';
import { IconCell } from 'component/common/Table/cells/IconCell/IconCell';
@ -89,7 +89,9 @@ const COLUMNS = [
{
Header: 'Time',
accessor: 'timestamp',
Cell: (props: any) => <DateCell value={props.row.original.timestamp} />,
Cell: (props: any) => (
<DateTimeCell value={props.row.original.timestamp} />
),
},
{
Header: 'Application',

View File

@ -12,6 +12,19 @@ export const formatDateYMDHMS = (
});
};
export const formatDateYMDHM = (
date: number | string | Date,
locale: string
): string => {
return new Date(date).toLocaleString(locale, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
});
};
export const formatDateYMD = (
date: number | string | Date,
locale: string