fleet/frontend/components
Jordan Wright 39e9cdd7b1
Fix certain datetimes to display "Never" when they are prior to Fleet's launch date (#14487)
# Checklist for submitter

- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality

> [!NOTE]  
> For the reviewer, you won't hurt my feelings at all if you have a
better implementation in mind and want to close this out! I'll be
upfront that I'm much more of a Go dev than a frontend dev. I'm just
using this issue as an opportunity to become more familiar with Fleet,
since I'm a fan of what y'all are doing and have been looking for a
project to spend some spare-time contributing to 😄
>
> You should also have edit access to this branch, so feel free to
commandeer it as you see fit.

# Summary

This PR aims to fix a regression identified in #14353 in which certain
"zero" datetimes are displayed as "54 years ago" instead of the
preferred "Never". The "zero" datetimes are commonly used [as a proxy to
indicate](5cb8051a40/server/datastore/mysql/hosts.go (L1649))
that a date wasn't set, e.g. when a host hasn't had its details fetched
yet.

We don't want to apply this treatment to _all_ datetimes, since some
(like vulnerability data) have valid dates before Fleet was created.

To support both use cases, I:

* Added an optional boolean, `cutoffBeforeFleetLaunch`, to indicate that
dates should be cutoff prior to the hardcoded Fleet launch date. This is
set to `false` in `HumanTimeDiffWithDateTip` for
backwards-compatibility.
* Created `HumanTimeDiffWithFleetLaunchCutoff` which is a drop-in
replacement for `HumanTimeDiffWithDateTip` that sets the
`cutoffBeforeFleetLaunch` flag to `true`.

I then used `HumanTimeDiffWithFleetLaunchCutoff` in the various host
related fields I could find. It's possible I missed some, so please
double-check me! I'm still getting my bearings on the codebase.

Here's a screenshot showing the host table with a host that I had
deleted and waited to appear again:

<img width="1381" alt="Screenshot 2023-10-11 at 11 27 29 PM"
src="https://github.com/fleetdm/fleet/assets/1317288/3cd23879-3233-409f-91a0-8b5e02d09deb">

You may find it helpful to review this commit-by-commit.

Closes #14353
2023-10-16 16:43:47 +01:00
..
AddHostsModal Fleet UI: Variable Fleet URL for ChromeOS extension (#12393) 2023-06-19 11:28:11 -04:00
App Update controls tabs to show mdm disabled UI state per tab (#13794) 2023-09-11 12:52:24 +01:00
AuthenticationFormWrapper Disable edit query for o and o+ (#14514) 2023-10-12 13:45:37 -07:00
Avatar add figma to storybook and a couple new stories (#11521) 2023-05-09 16:53:43 +01:00
AvatarTopNav Finalize new default avatar images (#9604) 2023-02-01 13:06:06 -06:00
BackLink Fleet UI: More icons updated (#13270) 2023-08-28 13:09:21 -04:00
buttons UI - Add 'Discard data' option to Save Query modal (#14284) 2023-10-04 15:19:26 -07:00
Card Feat: saved scripts (#14409) 2023-10-10 19:00:45 -03:00
ClickableUrls Fleet UI: More picky regex (Add alternative where must have http and/or www in link) (#13639) 2023-09-01 11:57:15 -04:00
ClickOutside add prettier and have it format all fleet application code (#625) 2021-04-12 14:32:25 +01:00
CustomLink Fleet UI: More icons updated (#13270) 2023-08-28 13:09:21 -04:00
DataError Feat UI view script activity and script details (#13388) 2023-08-29 11:47:37 +01:00
DeviceUserError Fleet UI: Update icons (6 icons only) (#11907) 2023-06-02 09:48:17 -04:00
DiskSpaceGraph Fleet UI: [tiny bug] Fix weird scroll behavior (#12435) 2023-06-22 08:24:57 -07:00
EmailTokenRedirect Removed all traces of Redux from the app! (#5287) 2022-04-22 09:45:35 -07:00
EmptyTable Frontend: Step 1 for query caching (organize FE directories, build save modals, modify routes/URLs) (#13908) 2023-10-02 12:26:53 -07:00
EnrollSecrets Fleet UI: [tiny bug] Copy message (#12411) 2023-06-21 09:14:47 -04:00
FlashMessage Fleet UI: Update icons (x in flash message and selected targets dropdown) (#12992) 2023-08-02 11:07:24 -04:00
FleetAce Fleet UI: Dynamic autofill for SQL editor (#13093) 2023-08-03 12:42:51 -04:00
FleetMarkdown Fleet UI: Dynamic autofill for SQL editor (#13093) 2023-08-03 12:42:51 -04:00
forms UI: Fix edit query form padding; align all Fleet checkboxes with their text (#14545) 2023-10-13 16:07:53 -07:00
HumanTimeDiffWithDateTip Fix certain datetimes to display "Never" when they are prior to Fleet's launch date (#14487) 2023-10-16 16:43:47 +01:00
Icon Fleet UI: More icons updated (#13270) 2023-08-28 13:09:21 -04:00
icons UI - Add 'Discard data' option to Save Query modal (#14284) 2023-10-04 15:19:26 -07:00
InfoBanner Fleet UI: Repush changes to fix info banner again (#14490) 2023-10-12 11:56:40 -04:00
LastUpdatedText add components to storybook (#11500) 2023-05-03 17:51:33 +01:00
LinkWithContext add components to storybook (#11500) 2023-05-03 17:51:33 +01:00
LiveQuery Fleet UI: [unreleased bug] Fix online hosts percentage string that wasn't rendering (#14568) 2023-10-16 10:55:47 -04:00
LogDestinationIndicator Fleet UI: New manage query automations modal (#12747) 2023-07-27 13:47:54 -07:00
MainContent Fleet UI: [released tiny bug] Fix dashboard double scroll bar (#13309) 2023-08-18 09:15:44 -04:00
MDM Improve the error handling for MDM SSO during DEP enrollment (#12966) 2023-07-26 14:20:36 -03:00
Modal Fleet UI: Dropdown arrows updated, on hover button icon color, etc (#13129) 2023-08-07 09:25:32 -04:00
modals/ShowQueryModal Fleet UI: Show query button added to policy results page (#10164) 2023-02-28 12:55:56 -05:00
NotSupported UI: Ensure 'Not supported' cell for Chromebooks never wraps (#12227) 2023-06-08 12:10:37 -04:00
Pagination Fleet UI: Manage Host and Manage Software uses URL params as source of truth (#11253) 2023-04-24 09:24:28 -04:00
PlatformCompatibility Revert "Merge front-end changes into 7765 Master Dev branch (#12905)" 2023-07-27 13:32:24 -07:00
PlatformSelector Fleet UI: Add ChromeOS to user flows related to policies (#12095) 2023-06-06 09:44:55 -04:00
PremiumFeatureIconWithTooltip add components to storybook (#11500) 2023-05-03 17:51:33 +01:00
PremiumFeatureMessage Fleet UI: Improvements to Sandbox mode styling (#12195) 2023-06-07 12:00:02 -04:00
queries Frontend: Step 1 for query caching (organize FE directories, build save modals, modify routes/URLs) (#13908) 2023-10-02 12:26:53 -07:00
QueryFrequencyIndicator Fleet UI: Fix custom query frequency on manage automations modal (#13511) 2023-08-25 13:00:14 -04:00
Sandbox Fleet UI: Improvements to Sandbox mode styling (#12195) 2023-06-07 12:00:02 -04:00
SectionHeader Feat UI add end user auth to controls page (#11991) 2023-06-02 14:14:39 +01:00
side_panels Fleet UI: More icons updated (#13270) 2023-08-28 13:09:21 -04:00
SidePanelContent implement macOS update content (#9469) 2023-01-27 16:25:53 -06:00
Spinner Fleet Frontend: Integration test for Add hosts modal (#12064) 2023-06-08 11:15:31 -04:00
StackedWhiteBoxes Fleet UI: No role = no access, refactor jsx class components to typescript functional components (#12953) 2023-08-02 11:29:49 -04:00
StatusIndicator UI – capitalize and align status icon in Automations column (#14095) 2023-09-22 16:27:45 -05:00
StatusIndicatorWithIcon maintenance merge of main into feature branch (#14393) 2023-10-09 14:28:35 -07:00
TableContainer Merge branch 'main' into 7766-main-merge 2023-10-11 12:56:52 -07:00
TabsWrapper Fleet UI: Improvements to highlighting while tabbing and not clicking (#13508) 2023-08-25 12:26:03 -04:00
TeamsDropdown Adjust teams dropdown arrow position (#14117) 2023-09-25 13:09:58 -05:00
Textarea fix formatting on the script content and output UI (#14048) 2023-09-22 12:52:27 +01:00
TooltipWrapper Frontend: Step 1 for query caching (organize FE directories, build save modals, modify routes/URLs) (#13908) 2023-10-02 12:26:53 -07:00
top_nav Fleet UI: Link improvements (Back links and dashboard tiles right clickable, fix queries link on nav bar) (#13361) 2023-08-23 08:56:32 -04:00
ViewAllHostsLink Fleet UI: More icons updated (#13270) 2023-08-28 13:09:21 -04:00
YamlAce add components to storybook (#11500) 2023-05-03 17:51:33 +01:00
generate Create UI component generator (#11644) 2023-05-11 12:00:27 -07:00