diff --git a/changes/issue-6521-convert-uptime-to-last-restarted b/changes/issue-6521-convert-uptime-to-last-restarted new file mode 100644 index 0000000000..6218a64a5d --- /dev/null +++ b/changes/issue-6521-convert-uptime-to-last-restarted @@ -0,0 +1 @@ +* Convert uptime column to last restarted on the Manage hosts page \ No newline at end of file diff --git a/frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx b/frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx index 12aec6a180..e408abf2d4 100644 --- a/frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx +++ b/frontend/pages/hosts/ManageHostsPage/HostTableConfig.tsx @@ -15,7 +15,7 @@ import StatusCell from "components/TableContainer/DataTable/StatusCell/StatusCel import TextCell from "components/TableContainer/DataTable/TextCell/TextCell"; import { humanHostMemory, - humanHostUptime, + humanHostLastRestart, humanHostLastSeen, humanHostDetailUpdated, hostTeamName, @@ -324,7 +324,7 @@ const allHostTableHeaders: IDataColumn[] = [ Cell: (cellProps: ICellProps) => , }, { - title: "Uptime", + title: "Last restarted", Header: (cellProps: IHeaderProps) => ( ), accessor: "uptime", - Cell: (cellProps: ICellProps) => ( - - ), + Cell: (cellProps: ICellProps) => { + const { uptime, detail_updated_at } = cellProps.row.original; + + return ( + + ); + }, }, { title: "CPU", diff --git a/frontend/utilities/helpers.ts b/frontend/utilities/helpers.ts index 75563e660e..487969f025 100644 --- a/frontend/utilities/helpers.ts +++ b/frontend/utilities/helpers.ts @@ -580,16 +580,6 @@ export const inMilliseconds = (nanoseconds: number): number => { return nanoseconds / NANOSECONDS_PER_MILLISECOND; }; -export const humanHostUptime = (uptimeInNanoseconds: number): string => { - const uptimeMilliseconds = inMilliseconds(uptimeInNanoseconds); - const restartDate = new Date(); - restartDate.setMilliseconds( - restartDate.getMilliseconds() - uptimeMilliseconds - ); - - return formatDistanceToNow(new Date(restartDate), { addSuffix: true }); -}; - export const humanHostLastRestart = ( detailUpdatedAt: string, uptime: number @@ -817,7 +807,6 @@ export default { generateRole, generateTeam, greyCell, - humanHostUptime, humanHostLastSeen, humanHostEnrolled, humanHostMemory,