Skip to content

Support custom format in getTimeago

What does this MR do and why?

This MR adds support for custom date and time formats for getTimeago utility function, which respects the user preference (whether to use relative or absolute time) and respects browser locale.

In order to match the desired mockups in Security Policies table, we need to be able to only display the date portion, while still respecting the user preference.

Mockup:

Screenshots or screen recordings

Before:

image

After, with en-US locale:

image

With en-GB locale:

image

With "Use relative times" enabled:

image

Tooltips with absolute datetime:

CleanShot_2023-04-25_at_14.00.38_2x

Tooltips with relative datetime:

CleanShot_2023-04-25_at_14.01.22_2x

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Under http://gdk.test:3000/-/profile/preferences, disable "Use relative times"
  2. Go to Security & Compliance -> Policies
  3. (optional) Create any policy if there's no data
  4. Different locale can be tested with Locale Switcher browser extension

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #345244 (closed)

Edited by Martin Čavoj

Merge request reports