mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
* rework data table, got to point of calling network request correctly * got to point of rendering table columns and data * finish up functional changes to data table * fix tests * fix styles for table container and data table * clean up some styles * update to styles for no host configured * cleanup and docs * add missing method for host table text formatting * disabling unused test. will add back in next PR * clean up code
45 lines
1 KiB
TypeScript
45 lines
1 KiB
TypeScript
import React from 'react';
|
|
import { useDispatch } from 'react-redux';
|
|
import { push } from 'react-router-redux';
|
|
|
|
import { IHost } from 'interfaces/host';
|
|
import helpers from 'kolide/helpers';
|
|
import PATHS from 'router/paths';
|
|
import Button from 'components/buttons/Button/Button';
|
|
|
|
interface ILinkCellProps {
|
|
value: string;
|
|
host: IHost;
|
|
}
|
|
|
|
const LinkCell = (props: ILinkCellProps): JSX.Element => {
|
|
const { value, host } = props;
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const onHostClick = (selectedHost: IHost): void => {
|
|
dispatch(push(PATHS.HOST_DETAILS(selectedHost)));
|
|
};
|
|
|
|
const lastSeenTime = (status: string, seenTime: string): string => {
|
|
const { humanHostLastSeen } = helpers;
|
|
|
|
if (status !== 'online') {
|
|
return `Last Seen: ${humanHostLastSeen(seenTime)} UTC`;
|
|
}
|
|
|
|
return 'Online';
|
|
};
|
|
|
|
return (
|
|
<Button
|
|
onClick={() => onHostClick(host)}
|
|
variant="text-link"
|
|
title={lastSeenTime(host.status, host.seen_time)}
|
|
>
|
|
{value}
|
|
</Button>
|
|
);
|
|
};
|
|
|
|
export default LinkCell;
|