fleet/frontend/components/TableContainer/DataTable/TextCell/TextCell.tsx
gillespi314 fd23d42300
Add secondary select action buttons to DataTable (#1470)
Enhance DataTable and related components to enable multiple buttons for actions on selected rows

- Create new subcomponent ActionButton for DataTable
- Add renderPrimarySelectAction and renderSecondarySelectActions
- Add renderActionButton
- Refactor selectActionButtonText and onSelectActionClick as primarySelectActionButtonText and onPrimarySelectActionButtonText
- Refactor ManageHostsPage to conform to above change
- Refactor TextCell component to enable it to display boolean values in text
2021-07-26 12:07:27 -05:00

23 lines
461 B
TypeScript

import React from "react";
interface ITextCellProps {
value: string | number | boolean;
formatter?: (val: any) => string;
}
const TextCell = (props: ITextCellProps): JSX.Element => {
const {
value,
formatter = (val) => val, // identity function if no formatter is provided
} = props;
let val = value;
if (typeof value === "boolean") {
val = value.toString();
}
return <span>{formatter(val)}</span>;
};
export default TextCell;