Display "No team" in Hosts table if the host is not assigned to any team (#1221)

- Add new formatter that returns "No team" if `team` does not exist
- Add sort to the "Team" column
This commit is contained in:
Zach Wasserman 2021-06-28 10:59:06 -07:00 committed by GitHub
parent 7a9e662f07
commit f1e42ee775
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -344,6 +344,14 @@ export const humanHostDetailUpdated = (detailUpdated: string): string => {
return moment(detailUpdated).fromNow();
};
export const hostTeamName = (teamName: string | null): string => {
if (!teamName) {
return "No team";
}
return teamName;
};
export const humanQueryLastRun = (lastRun: string): string => {
// Handles the case when a query has never been ran.
// July 28, 2016 is the date of the initial commit to fleet/fleet.
@ -405,6 +413,7 @@ export default {
humanHostEnrolled,
humanHostMemory,
humanHostDetailUpdated,
hostTeamName,
humanQueryLastRun,
secondsToHms,
labelSlug,

View file

@ -16,6 +16,7 @@ import {
humanHostUptime,
humanHostLastSeen,
humanHostDetailUpdated,
hostTeamName,
} from "fleet/helpers";
import { IConfig } from "interfaces/config";
import { IUser } from "interfaces/user";
@ -107,9 +108,16 @@ const allHostTableHeaders: IHostDataColumn[] = [
},
{
title: "Team",
Header: "Team",
Header: (cellProps) => (
<HeaderCell
value={cellProps.column.title}
isSortedDesc={cellProps.column.isSortedDesc}
/>
),
accessor: "team_name",
Cell: (cellProps) => <TextCell value={cellProps.cell.value} />,
Cell: (cellProps) => (
<TextCell value={cellProps.cell.value} formatter={hostTeamName} />
),
},
{
title: "Status",