Skip to content

fix: Replace calls to timeAgo with formatDateAsTimeAgo #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2025

Conversation

andreaskienle
Copy link
Contributor

This PR adds formatDateAsTimeAgo as a replacement for timeAgo.format(new Date(…)), so we can more gracefully handle transition times that are missing or formatted in unexpected ways.

@andreaskienle andreaskienle requested a review from Copilot August 11, 2025 09:54
@andreaskienle andreaskienle changed the title Replace calls to timeAgo with formatDateAsTimeAgo fix: Replace calls to timeAgo with formatDateAsTimeAgo Aug 11, 2025
@andreaskienle andreaskienle marked this pull request as ready for review August 11, 2025 10:01
Copilot

This comment was marked as outdated.

@andreaskienle andreaskienle requested a review from Copilot August 11, 2025 10:10
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new utility function formatDateAsTimeAgo to replace direct usage of the timeAgo instance, providing better error handling for invalid or missing date strings. The function gracefully handles edge cases by returning an empty string for invalid dates instead of throwing errors.

  • Added formatDateAsTimeAgo function with input validation and error handling
  • Updated all existing usages of timeAgo.format(new Date(...)) to use the new function
  • Added comprehensive test coverage for the new utility function

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/i18n/timeAgo.ts Adds new formatDateAsTimeAgo function and makes timeAgo instance private
src/utils/i18n/timeAgo.spec.ts Comprehensive test suite for the new utility function
src/components/Shared/ResourceStatusCell.tsx Updates timeAgo usage in status cell component
src/components/ControlPlane/ProvidersConfig.tsx Updates timeAgo usage in providers configuration
src/components/ControlPlane/Providers.tsx Updates timeAgo usage in providers list
src/components/ControlPlane/ManagedResources.tsx Updates timeAgo usage in managed resources
src/components/ControlPlane/FluxList.tsx Updates timeAgo usage in flux list component

@andreaskienle andreaskienle merged commit 5e8708f into main Aug 11, 2025
5 checks passed
@andreaskienle andreaskienle deleted the fix-time-ago branch August 11, 2025 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants