Update the API Tokens UI for new token format and status.

Review Request #12527 — Created Aug. 10, 2022 and submitted — Latest diff uploaded

Review Board

This change updates the API tokens config page for most of the
features supported by the new API token generator:

  • Long API tokens are displayed nicely, inside an <input> element with
    a copy button.
  • A label shows when each token was last used.
  • Tokens which are expired or invalidated will show when that happened,
    and in the case of invalidation, will show the message.
  • Tokens with an expiration date will show the time left.

There's still some future work left to do in later changes:

  • Allow people to set the expiration date.
  • Show a warning when a token was created with a deprecated generator

Based on work by Michelle Aubin at /r/12492/

  • Ran unit tests.
  • Ran js-tests.
  • Set up a bunch of different API tokens with various expiration dates
    and validity settings. Checked that everything displayed correctly.
  • Checked that the copy button functioned as expected.