2021-09-10 19:06:37 +00:00
|
|
|
/* eslint-disable react/prop-types */
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
2024-03-13 19:09:16 +00:00
|
|
|
import { Column, Row } from "react-table";
|
2021-09-10 19:06:37 +00:00
|
|
|
|
2024-03-13 19:09:16 +00:00
|
|
|
import { IStringCellProps } from "interfaces/datatable_config";
|
2023-02-22 21:27:02 +00:00
|
|
|
import { IHost } from "interfaces/host";
|
2021-09-10 19:06:37 +00:00
|
|
|
|
|
|
|
|
import TextCell from "components/TableContainer/DataTable/TextCell";
|
2023-02-22 21:27:02 +00:00
|
|
|
import LiveQueryIssueCell from "components/TableContainer/DataTable/LiveQueryIssueCell/LiveQueryIssueCell";
|
2022-12-13 18:04:07 +00:00
|
|
|
import StatusIndicator from "components/StatusIndicator";
|
2024-12-18 15:12:27 +00:00
|
|
|
import Button from "components/buttons/Button";
|
2023-08-02 15:07:24 +00:00
|
|
|
import Icon from "components/Icon/Icon";
|
2021-09-10 19:06:37 +00:00
|
|
|
|
2024-04-16 16:22:08 +00:00
|
|
|
export type ITargestInputHostTableConfig = Column<IHost>;
|
2024-03-13 19:09:16 +00:00
|
|
|
type ITableStringCellProps = IStringCellProps<IHost>;
|
2023-02-22 21:27:02 +00:00
|
|
|
|
2021-09-10 19:06:37 +00:00
|
|
|
// NOTE: cellProps come from react-table
|
|
|
|
|
// more info here https://react-table.tanstack.com/docs/api/useTable#cell-properties
|
2022-06-10 18:29:45 +00:00
|
|
|
export const generateTableHeaders = (
|
2024-03-13 19:09:16 +00:00
|
|
|
handleRowRemove?: (value: Row<IHost>) => void
|
2024-04-16 16:22:08 +00:00
|
|
|
): ITargestInputHostTableConfig[] => {
|
2022-06-10 18:29:45 +00:00
|
|
|
const deleteHeader = handleRowRemove
|
2021-09-10 19:06:37 +00:00
|
|
|
? [
|
|
|
|
|
{
|
2021-11-08 22:12:58 +00:00
|
|
|
id: "delete",
|
|
|
|
|
Header: "",
|
2024-03-13 19:09:16 +00:00
|
|
|
Cell: (cellProps: ITableStringCellProps) => (
|
2024-12-18 15:12:27 +00:00
|
|
|
<Button
|
|
|
|
|
onClick={() => handleRowRemove(cellProps.row)}
|
|
|
|
|
variant="icon"
|
|
|
|
|
>
|
2023-10-31 16:06:38 +00:00
|
|
|
<Icon name="close-filled" />
|
2024-12-18 15:12:27 +00:00
|
|
|
</Button>
|
2021-11-08 22:12:58 +00:00
|
|
|
),
|
2021-09-10 19:06:37 +00:00
|
|
|
disableHidden: true,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
: [];
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
{
|
2022-10-14 19:26:15 +00:00
|
|
|
Header: "Host",
|
|
|
|
|
accessor: "display_name",
|
2024-03-13 19:09:16 +00:00
|
|
|
Cell: (cellProps: ITableStringCellProps) => {
|
2023-02-22 21:27:02 +00:00
|
|
|
return (
|
|
|
|
|
<LiveQueryIssueCell
|
|
|
|
|
displayName={cellProps.cell.value}
|
|
|
|
|
distributedInterval={cellProps.row.original.distributed_interval}
|
|
|
|
|
status={cellProps.row.original.status}
|
|
|
|
|
rowId={cellProps.row.original.id}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
},
|
2021-09-10 19:06:37 +00:00
|
|
|
},
|
2022-06-10 18:29:45 +00:00
|
|
|
// TODO: Consider removing status column from selected hosts table because
|
|
|
|
|
// status info is not refreshed once a target has been selected
|
2021-09-10 19:06:37 +00:00
|
|
|
{
|
|
|
|
|
Header: "Status",
|
|
|
|
|
disableSortBy: true,
|
|
|
|
|
accessor: "status",
|
2022-12-13 18:04:07 +00:00
|
|
|
Cell: (cellProps) => <StatusIndicator value={cellProps.cell.value} />,
|
2021-09-10 19:06:37 +00:00
|
|
|
},
|
|
|
|
|
{
|
2022-10-25 15:56:09 +00:00
|
|
|
Header: "Private IP address",
|
2021-09-10 19:06:37 +00:00
|
|
|
accessor: "primary_ip",
|
|
|
|
|
Cell: (cellProps) => <TextCell value={cellProps.cell.value} />,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Header: "MAC address",
|
|
|
|
|
accessor: "primary_mac",
|
|
|
|
|
Cell: (cellProps) => <TextCell value={cellProps.cell.value} />,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Header: "OS",
|
|
|
|
|
accessor: "os_version",
|
|
|
|
|
Cell: (cellProps) => <TextCell value={cellProps.cell.value} />,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
Header: "Osquery",
|
|
|
|
|
accessor: "osquery_version",
|
|
|
|
|
Cell: (cellProps) => <TextCell value={cellProps.cell.value} />,
|
|
|
|
|
},
|
2021-11-08 22:12:58 +00:00
|
|
|
...deleteHeader,
|
2021-09-10 19:06:37 +00:00
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default null;
|