fleet/frontend/pages/labels/components/ManualLabelForm/LabelHostTargetTableConfig.tsx
Gabriel Hernandez 2fc4e520b8
add ability to create manual labels (#18303)
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>
2024-04-16 17:22:08 +01:00

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;