Skip to content

Commit

Permalink
[Gitar] Cleaning up stale flag: timeAgoRefactor with value true (#7997)
Browse files Browse the repository at this point in the history
Co-authored-by: Gitar <[email protected]>
Co-authored-by: Tymoteusz Czech <[email protected]>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent 3a9b9e9 commit 031a2e8
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 54 deletions.
2 changes: 0 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"@types/react-router-dom": "5.3.3",
"@types/react-table": "7.7.20",
"@types/react-test-renderer": "18.3.0",
"@types/react-timeago": "4.1.7",
"@types/semver": "7.5.8",
"@types/uuid": "^9.0.0",
"@uiw/codemirror-theme-duotone": "4.23.0",
Expand Down Expand Up @@ -111,7 +110,6 @@
"react-router-dom": "6.16.0",
"react-table": "7.8.0",
"react-test-renderer": "18.3.1",
"react-timeago": "7.2.0",
"sass": "1.77.8",
"semver": "7.6.3",
"swr": "2.2.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const setupApi = (application: ApplicationOverviewSchema) => {
application,
);
testServerRoute(server, '/api/admin/ui-config', {
flags: {
timeAgoRefactor: true,
},
flags: {},
});
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/common/TimeAgo/TimeAgo.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi } from 'vitest';
import { act, render, screen } from '@testing-library/react';
import { NewTimeAgo as TimeAgo } from './TimeAgo';
import { TimeAgo } from './TimeAgo';

const h = 3_600_000 as const;
const min = 60_000 as const;
Expand Down
17 changes: 1 addition & 16 deletions frontend/src/component/common/TimeAgo/TimeAgo.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { useEffect, useState, type FC } from 'react';
import { formatDistanceToNow, secondsToMilliseconds } from 'date-fns';
import { default as LegacyTimeAgo } from 'react-timeago';
import { useUiFlag } from 'hooks/useUiFlag';

type TimeAgoProps = {
date: Date | number | string | null | undefined;
Expand All @@ -17,18 +15,7 @@ const formatTimeAgo = (date: string | number | Date) =>
.replace('about ', '')
.replace('less than a minute ago', '< 1 minute ago');

export const TimeAgo: FC<TimeAgoProps> = ({ ...props }) => {
const { date, fallback, refresh } = props;
const timeAgoRefactorEnabled = useUiFlag('timeAgoRefactor');

if (timeAgoRefactorEnabled) return <NewTimeAgo {...props} />;
if (!date) return fallback;
return (
<LegacyTimeAgo key={`${date}`} date={new Date(date)} live={refresh} />
);
};

export const NewTimeAgo: FC<TimeAgoProps> = ({
export const TimeAgo: FC<TimeAgoProps> = ({
date,
fallback = '',
refresh = true,
Expand Down Expand Up @@ -69,5 +56,3 @@ export const NewTimeAgo: FC<TimeAgoProps> = ({
<time dateTime={state.dateTime.toISOString()}>{state.description}</time>
);
};

export default TimeAgo;
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import CheckIcon from '@mui/icons-material/Check';
import { Link as RouterLink } from 'react-router-dom';
import ReportProblemOutlinedIcon from '@mui/icons-material/ReportProblemOutlined';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import ReactTimeAgo from 'react-timeago';
import type { IProjectHealthReport } from 'interfaces/project';
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
import InfoOutlined from '@mui/icons-material/InfoOutlined';
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';

const StyledBoxActive = styled(Box)(({ theme }) => ({
display: 'flex',
Expand Down Expand Up @@ -142,9 +142,9 @@ export const ReportCard = ({ healthReport }: IReportCardProps) => {
</StyledHealthRating>
<StyledLastUpdated>
Last updated:{' '}
<ReactTimeAgo
<TimeAgo
date={healthReport.updatedAt}
live={false}
refresh={false}
/>
</StyledLastUpdated>
</>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/interfaces/uiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export type UiFlags = {
newEventSearch?: boolean;
archiveProjects?: boolean;
projectListImprovements?: boolean;
timeAgoRefactor?: boolean;
};

export interface IVersionInfo {
Expand Down
20 changes: 0 additions & 20 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2881,15 +2881,6 @@ __metadata:
languageName: node
linkType: hard

"@types/react-timeago@npm:4.1.7":
version: 4.1.7
resolution: "@types/react-timeago@npm:4.1.7"
dependencies:
"@types/react": "npm:*"
checksum: 10c0/0f5965a0cdcced841889b45003c91643392caffc47470ed6e84784b940b3e8fe2031bce44a6c135e3adf6b5c21f46eb20c3b9211f1ec93c86f8e67ca732aed71
languageName: node
linkType: hard

"@types/react-transition-group@npm:^4.4.10":
version: 4.4.10
resolution: "@types/react-transition-group@npm:4.4.10"
Expand Down Expand Up @@ -8359,15 +8350,6 @@ __metadata:
languageName: node
linkType: hard

"react-timeago@npm:7.2.0":
version: 7.2.0
resolution: "react-timeago@npm:7.2.0"
peerDependencies:
react: ^16.0.0 || ^17.0.0 || ^18.0.0
checksum: 10c0/89051a12296934e3400319ca7887a0f3ae5a779fd9456769b526ac4771c47a431fb4c68f56ac9726e23d65aad55538f7e2f1c6adfa83224bc8f6278775c26fa3
languageName: node
linkType: hard

"react-transition-group@npm:^4.4.5":
version: 4.4.5
resolution: "react-transition-group@npm:4.4.5"
Expand Down Expand Up @@ -9814,7 +9796,6 @@ __metadata:
"@types/react-router-dom": "npm:5.3.3"
"@types/react-table": "npm:7.7.20"
"@types/react-test-renderer": "npm:18.3.0"
"@types/react-timeago": "npm:4.1.7"
"@types/semver": "npm:7.5.8"
"@types/uuid": "npm:^9.0.0"
"@uiw/codemirror-theme-duotone": "npm:4.23.0"
Expand Down Expand Up @@ -9863,7 +9844,6 @@ __metadata:
react-router-dom: "npm:6.16.0"
react-table: "npm:7.8.0"
react-test-renderer: "npm:18.3.1"
react-timeago: "npm:7.2.0"
sass: "npm:1.77.8"
semver: "npm:7.6.3"
swr: "npm:2.2.5"
Expand Down
1 change: 0 additions & 1 deletion src/lib/__snapshots__/create-config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ exports[`should create default config 1`] = `
"showInactiveUsers": false,
"signals": false,
"strictSchemaValidation": false,
"timeAgoRefactor": false,
"useMemoizedActiveTokens": false,
"useProjectReadModel": false,
"userAccessUIEnabled": false,
Expand Down
7 changes: 1 addition & 6 deletions src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ export type IFlagKey =
| 'archiveProjects'
| 'projectListImprovements'
| 'useProjectReadModel'
| 'addonUsageMetrics'
| 'timeAgoRefactor';
| 'addonUsageMetrics';

export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;

Expand Down Expand Up @@ -309,10 +308,6 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_ADDON_USAGE_METRICS,
false,
),
timeAgoRefactor: parseEnvVarBoolean(
process.env.UNLEASH_TIMEAGO_REFACTOR,
false,
),
};

export const defaultExperimentalOptions: IExperimentalOptions = {
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ process.nextTick(async () => {
projectListImprovements: true,
useProjectReadModel: true,
addonUsageMetrics: true,
timeAgoRefactor: true,
},
},
authentication: {
Expand Down

0 comments on commit 031a2e8

Please sign in to comment.