Skip to content

Commit

Permalink
Refactor: Remove react-timeago (#7943)
Browse files Browse the repository at this point in the history
Remove dependency 🫡
  • Loading branch information
Tymek authored Aug 21, 2024
1 parent 43100f9 commit 6c5ce52
Show file tree
Hide file tree
Showing 20 changed files with 352 additions and 330 deletions.
16 changes: 4 additions & 12 deletions frontend/src/component/application/ApplicationChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import CheckCircle from '@mui/icons-material/CheckCircle';
import CloudCircle from '@mui/icons-material/CloudCircle';
import Flag from '@mui/icons-material/Flag';
import WarningAmberRounded from '@mui/icons-material/WarningAmberRounded';
import TimeAgo from 'react-timeago';
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import { getApplicationIssues } from './ApplicationIssues/ApplicationIssues';

Expand Down Expand Up @@ -305,17 +305,9 @@ export const ApplicationChart = ({ data }: IApplicationChartProps) => {
<tr>
<StyledCell>Last seen:</StyledCell>
<StyledCell>
{environment.lastSeen && (
<TimeAgo
key={`${environment.lastSeen}`}
minPeriod={60}
date={
new Date(
environment.lastSeen,
)
}
/>
)}
<TimeAgo
date={environment.lastSeen}
/>
</StyledCell>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ const setupApi = (application: ApplicationOverviewSchema) => {
'/api/admin/metrics/applications/my-app/overview',
application,
);
testServerRoute(server, '/api/admin/ui-config', {});
testServerRoute(server, '/api/admin/ui-config', {
flags: {
timeAgoRefactor: true,
},
});
};

test('Display application overview with environments', async () => {
Expand Down Expand Up @@ -51,7 +55,7 @@ test('Display application overview with environments', async () => {
await screen.findByText('development environment');
await screen.findByText('999');
await screen.findByText('unleash-client-node:5.5.0-beta.0');
await screen.findByText('0 seconds ago');
await screen.findByText('< 1 minute ago');
});

test('Display application overview without environments', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { VFC } from 'react';
import TimeAgo from 'react-timeago';
import type { FC } from 'react';
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';
import { Tooltip, Typography, useTheme } from '@mui/material';
import { formatDateYMD } from 'utils/formatDate';
import { TextCell } from 'component/common/Table/cells/TextCell/TextCell';
Expand All @@ -9,7 +9,7 @@ interface IFeatureArchivedCellProps {
value?: string | Date | null;
}

export const FeatureArchivedCell: VFC<IFeatureArchivedCellProps> = ({
export const FeatureArchivedCell: FC<IFeatureArchivedCellProps> = ({
value: archivedAt,
}) => {
const { locationSettings } = useLocationSettings();
Expand Down Expand Up @@ -37,12 +37,7 @@ export const FeatureArchivedCell: VFC<IFeatureArchivedCellProps> = ({
arrow
>
<Typography noWrap variant='body2' data-loading>
<TimeAgo
key={`${archivedAt}`}
date={new Date(archivedAt)}
title=''
live={false}
/>
<TimeAgo date={new Date(archivedAt)} refresh={false} />
</Typography>
</Tooltip>
</TextCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FC } from 'react';
import { Markdown } from 'component/common/Markdown/Markdown';
import Paper from '@mui/material/Paper';
import { Box, styled, Typography } from '@mui/material';
import TimeAgo from 'react-timeago';
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';
import { StyledAvatar } from './StyledAvatar';
import type { IChangeRequestComment } from '../../changeRequest.types';

Expand Down Expand Up @@ -35,12 +35,7 @@ export const ChangeRequestComment: FC<{ comment: IChangeRequestComment }> = ({
<Box>
<strong>{comment.createdBy.username}</strong>{' '}
<Typography color='text.secondary' component='span'>
commented{' '}
<TimeAgo
key={`${comment.createdAt}`}
minPeriod={60}
date={new Date(comment.createdAt)}
/>
commented <TimeAgo date={comment.createdAt} />
</Typography>
</Box>
</CommentHeader>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box } from '@mui/material';
import { type FC, useState } from 'react';
import { Typography, Tooltip } from '@mui/material';
import TimeAgo from 'react-timeago';
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';
import type { ChangeRequestType } from 'component/changeRequest/changeRequest.types';
import { ChangeRequestStatusBadge } from 'component/changeRequest/ChangeRequestStatusBadge/ChangeRequestStatusBadge';
import {
Expand Down Expand Up @@ -38,13 +38,7 @@ export const ChangeRequestHeader: FC<{ changeRequest: ChangeRequestType }> = ({
margin: theme.spacing('auto', 0, 'auto', 2),
})}
>
Created{' '}
<TimeAgo
key={`${changeRequest.createdAt}`}
minPeriod={60}
date={new Date(changeRequest.createdAt)}
/>{' '}
by
Created <TimeAgo date={changeRequest.createdAt} /> by
</Typography>
<Box
sx={(theme) => ({
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/component/common/Notifications/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
NotificationsSchemaItemNotificationType,
} from 'openapi';
import { ReactComponent as ChangesAppliedIcon } from 'assets/icons/merge.svg';
import TimeAgo from 'react-timeago';
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';
import ToggleOffOutlined from '@mui/icons-material/ToggleOffOutlined';
import { flexRow } from 'themes/themeStyles';

Expand Down Expand Up @@ -157,11 +157,7 @@ export const Notification = ({
</StyledUserContainer>

<StyledTimeAgoTypography>
<TimeAgo
key={`${notification.createdAt}`}
date={new Date(notification.createdAt)}
minPeriod={60}
/>
<TimeAgo date={notification.createdAt} />
</StyledTimeAgoTypography>
</StyledSecondaryInfoBox>
</StyledNotificationMessageBox>
Expand Down

This file was deleted.

Loading

0 comments on commit 6c5ce52

Please sign in to comment.