mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +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:
parent
be1e63508a
commit
b36ab58f87
@ -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>;
|
||||||
|
};
|
@ -1,6 +1,6 @@
|
|||||||
import { IFeatureMetricsRaw } from 'interfaces/featureToggle';
|
import { IFeatureMetricsRaw } from 'interfaces/featureToggle';
|
||||||
import { TableBody, TableRow, useMediaQuery } from '@mui/material';
|
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 { useTable, useGlobalFilter, useSortBy } from 'react-table';
|
||||||
import { SortableTableHeader, TableCell, Table } from 'component/common/Table';
|
import { SortableTableHeader, TableCell, Table } from 'component/common/Table';
|
||||||
import { IconCell } from 'component/common/Table/cells/IconCell/IconCell';
|
import { IconCell } from 'component/common/Table/cells/IconCell/IconCell';
|
||||||
@ -89,7 +89,9 @@ const COLUMNS = [
|
|||||||
{
|
{
|
||||||
Header: 'Time',
|
Header: 'Time',
|
||||||
accessor: 'timestamp',
|
accessor: 'timestamp',
|
||||||
Cell: (props: any) => <DateCell value={props.row.original.timestamp} />,
|
Cell: (props: any) => (
|
||||||
|
<DateTimeCell value={props.row.original.timestamp} />
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: 'Application',
|
Header: 'Application',
|
||||||
|
@ -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 = (
|
export const formatDateYMD = (
|
||||||
date: number | string | Date,
|
date: number | string | Date,
|
||||||
locale: string
|
locale: string
|
||||||
|
Loading…
Reference in New Issue
Block a user