mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
relates to #17031 Adds functionality to create manual labels in fleet. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Added/updated tests - [x] M0anual QA for all new/changed functionality --------- Co-authored-by: Martin Angers <martin.n.angers@gmail.com>
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
/* eslint-disable react/prop-types */
|
|
|
|
import React from "react";
|
|
import { Column, Row } from "react-table";
|
|
|
|
import { IStringCellProps } from "interfaces/datatable_config";
|
|
import { IHost } from "interfaces/host";
|
|
|
|
import TextCell from "components/TableContainer/DataTable/TextCell";
|
|
import Icon from "components/Icon/Icon";
|
|
|
|
export type ITargestInputHostTableConfig = Column<IHost>;
|
|
type ITableStringCellProps = IStringCellProps<IHost>;
|
|
|
|
// NOTE: cellProps come from react-table
|
|
// more info here https://react-table.tanstack.com/docs/api/useTable#cell-properties
|
|
export const generateTableHeaders = (
|
|
handleRowRemove?: (value: Row<IHost>) => void
|
|
): ITargestInputHostTableConfig[] => {
|
|
const deleteHeader = handleRowRemove
|
|
? [
|
|
{
|
|
id: "delete",
|
|
Header: "",
|
|
Cell: (cellProps: ITableStringCellProps) => (
|
|
<div onClick={() => handleRowRemove(cellProps.row)}>
|
|
<Icon name="close-filled" />
|
|
</div>
|
|
),
|
|
disableHidden: true,
|
|
},
|
|
]
|
|
: [];
|
|
|
|
return [
|
|
{
|
|
Header: "Host",
|
|
accessor: "display_name",
|
|
Cell: (cellProps) => <TextCell value={cellProps.cell.value} />,
|
|
},
|
|
{
|
|
Header: "Hostname",
|
|
accessor: "hostname",
|
|
Cell: (cellProps) => <TextCell value={cellProps.cell.value} />,
|
|
},
|
|
{
|
|
Header: "Serial number",
|
|
accessor: "hardware_serial",
|
|
Cell: (cellProps) => <TextCell value={cellProps.cell.value} />,
|
|
},
|
|
...deleteHeader,
|
|
];
|
|
};
|
|
|
|
export default null;
|